UNPKG

houdini-svelte

Version:
1,365 lines (1,361 loc) 5.96 MB
const require = conflict_free(import.meta.url); "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require3() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js var require_tslib2 = __commonJS({ "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module2) { var __extends; var __assign; var __rest; var __decorate; var __param; var __esDecorate; var __runInitializers; var __propKey; var __setFunctionName; var __metadata; var __awaiter; var __generator; var __exportStar; var __values; var __read; var __spread; var __spreadArrays; var __spreadArray; var __await; var __asyncGenerator; var __asyncDelegator; var __asyncValues; var __makeTemplateObject; var __importStar; var __importDefault; var __classPrivateFieldGet; var __classPrivateFieldSet; var __classPrivateFieldIn; var __createBinding; (function(factory) { var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; if (typeof define === "function" && define.amd) { define("tslib", ["exports"], function(exports2) { factory(createExporter(root, createExporter(exports2))); }); } else if (typeof module2 === "object" && typeof module2.exports === "object") { factory(createExporter(root, createExporter(module2.exports))); } else { factory(createExporter(root)); } function createExporter(exports2, previous) { if (exports2 !== root) { if (typeof Object.create === "function") { Object.defineProperty(exports2, "__esModule", { value: true }); } else { exports2.__esModule = true; } } return function(id, v) { return exports2[id] = previous ? previous(id, v) : v; }; } })(function(exporter) { var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { d.__proto__ = b; } || function(d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; __extends = function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; __assign = Object.assign || function(t4) { for (var s3, i3 = 1, n = arguments.length; i3 < n; i3++) { s3 = arguments[i3]; for (var p in s3) if (Object.prototype.hasOwnProperty.call(s3, p)) t4[p] = s3[p]; } return t4; }; __rest = function(s3, e3) { var t4 = {}; for (var p in s3) if (Object.prototype.hasOwnProperty.call(s3, p) && e3.indexOf(p) < 0) t4[p] = s3[p]; if (s3 != null && typeof Object.getOwnPropertySymbols === "function") for (var i3 = 0, p = Object.getOwnPropertySymbols(s3); i3 < p.length; i3++) { if (e3.indexOf(p[i3]) < 0 && Object.prototype.propertyIsEnumerable.call(s3, p[i3])) t4[p[i3]] = s3[p[i3]]; } return t4; }; __decorate = function(decorators, target, key, desc) { var c = arguments.length, r3 = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r3 = Reflect.decorate(decorators, target, key, desc); else for (var i3 = decorators.length - 1; i3 >= 0; i3--) if (d = decorators[i3]) r3 = (c < 3 ? d(r3) : c > 3 ? d(target, key, r3) : d(target, key)) || r3; return c > 3 && r3 && Object.defineProperty(target, key, r3), r3; }; __param = function(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; }; __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f4) { if (f4 !== void 0 && typeof f4 !== "function") throw new TypeError("Function expected"); return f4; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i3 = decorators.length - 1; i3 >= 0; i3--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function(f4) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f4 || null)); }; var result = (0, decorators[i3])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.push(_); } else if (_ = accept(result)) { if (kind === "field") initializers.push(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; __runInitializers = function(thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i3 = 0; i3 < initializers.length; i3++) { value = useValue ? initializers[i3].call(thisArg, value) : initializers[i3].call(thisArg); } return useValue ? value : void 0; }; __propKey = function(x3) { return typeof x3 === "symbol" ? x3 : "".concat(x3); }; __setFunctionName = function(f4, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f4, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; __metadata = function(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); }; __awaiter = function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve3) { resolve3(value); }); } return new (P || (P = Promise))(function(resolve3, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e3) { reject(e3); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e3) { reject(e3); } } function step(result) { result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; __generator = function(thisArg, body) { var _ = { label: 0, sent: function() { if (t4[0] & 1) throw t4[1]; return t4[1]; }, trys: [], ops: [] }, f4, y, t4, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f4) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f4 = 1, y && (t4 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t4 = y["return"]) && t4.call(y), 0) : y.next) && !(t4 = t4.call(y, op[1])).done) return t4; if (y = 0, t4) op = [op[0] & 2, t4.value]; switch (op[0]) { case 0: case 1: t4 = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t4 = _.trys, t4 = t4.length > 0 && t4[t4.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t4 || op[1] > t4[0] && op[1] < t4[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t4[1]) { _.label = t4[1]; t4 = op; break; } if (t4 && _.label < t4[2]) { _.label = t4[2]; _.ops.push(op); break; } if (t4[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e3) { op = [6, e3]; y = 0; } finally { f4 = t4 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; __exportStar = function(m3, o) { for (var p in m3) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m3, p); }; __createBinding = Object.create ? function(o, m3, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m3, k); if (!desc || ("get" in desc ? !m3.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m3[k]; } }; } Object.defineProperty(o, k2, desc); } : function(o, m3, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m3[k]; }; __values = function(o) { var s3 = typeof Symbol === "function" && Symbol.iterator, m3 = s3 && o[s3], i3 = 0; if (m3) return m3.call(o); if (o && typeof o.length === "number") return { next: function() { if (o && i3 >= o.length) o = void 0; return { value: o && o[i3++], done: !o }; } }; throw new TypeError(s3 ? "Object is not iterable." : "Symbol.iterator is not defined."); }; __read = function(o, n) { var m3 = typeof Symbol === "function" && o[Symbol.iterator]; if (!m3) return o; var i3 = m3.call(o), r3, ar = [], e3; try { while ((n === void 0 || n-- > 0) && !(r3 = i3.next()).done) ar.push(r3.value); } catch (error) { e3 = { error }; } finally { try { if (r3 && !r3.done && (m3 = i3["return"])) m3.call(i3); } finally { if (e3) throw e3.error; } } return ar; }; __spread = function() { for (var ar = [], i3 = 0; i3 < arguments.length; i3++) ar = ar.concat(__read(arguments[i3])); return ar; }; __spreadArrays = function() { for (var s3 = 0, i3 = 0, il = arguments.length; i3 < il; i3++) s3 += arguments[i3].length; for (var r3 = Array(s3), k = 0, i3 = 0; i3 < il; i3++) for (var a = arguments[i3], j = 0, jl = a.length; j < jl; j++, k++) r3[k] = a[j]; return r3; }; __spreadArray = function(to, from, pack) { if (pack || arguments.length === 2) for (var i3 = 0, l = from.length, ar; i3 < l; i3++) { if (ar || !(i3 in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i3); ar[i3] = from[i3]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; __await = function(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }; __asyncGenerator = function(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i3, q = []; return i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() { return this; }, i3; function verb(n) { if (g[n]) i3[n] = function(v) { return new Promise(function(a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e3) { settle(q[0][3], e3); } } function step(r3) { r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q[0][2], r3); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f4, v) { if (f4(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; __asyncDelegator = function(o) { var i3, p; return i3 = {}, verb("next"), verb("throw", function(e3) { throw e3; }), verb("return"), i3[Symbol.iterator] = function() { return this; }, i3; function verb(n, f4) { i3[n] = o[n] ? function(v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f4 ? f4(v) : v; } : f4; } }; __asyncValues = function(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m3 = o[Symbol.asyncIterator], i3; return m3 ? m3.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() { return this; }, i3); function verb(n) { i3[n] = o[n] && function(v) { return new Promise(function(resolve3, reject) { v = o[n](v), settle(resolve3, reject, v.done, v.value); }); }; } function settle(resolve3, reject, d, v) { Promise.resolve(v).then(function(v2) { resolve3({ value: v2, done: d }); }, reject); } }; __makeTemplateObject = function(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __setModuleDefault = Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }; __importStar = function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; __importDefault = function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; __classPrivateFieldGet = function(receiver, state, kind, f4) { if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f4 : kind === "a" ? f4.call(receiver) : f4 ? f4.value : state.get(receiver); }; __classPrivateFieldSet = function(receiver, state, value, kind, f4) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f4.call(receiver, value) : f4 ? f4.value = value : state.set(receiver, value), value; }; __classPrivateFieldIn = function(state, receiver) { if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object"); return typeof state === "function" ? receiver === state : state.has(receiver); }; exporter("__extends", __extends); exporter("__assign", __assign); exporter("__rest", __rest); exporter("__decorate", __decorate); exporter("__param", __param); exporter("__esDecorate", __esDecorate); exporter("__runInitializers", __runInitializers); exporter("__propKey", __propKey); exporter("__setFunctionName", __setFunctionName); exporter("__metadata", __metadata); exporter("__awaiter", __awaiter); exporter("__generator", __generator); exporter("__exportStar", __exportStar); exporter("__createBinding", __createBinding); exporter("__values", __values); exporter("__read", __read); exporter("__spread", __spread); exporter("__spreadArrays", __spreadArrays); exporter("__spreadArray", __spreadArray); exporter("__await", __await); exporter("__asyncGenerator", __asyncGenerator); exporter("__asyncDelegator", __asyncDelegator); exporter("__asyncValues", __asyncValues); exporter("__makeTemplateObject", __makeTemplateObject); exporter("__importStar", __importStar); exporter("__importDefault", __importDefault); exporter("__classPrivateFieldGet", __classPrivateFieldGet); exporter("__classPrivateFieldSet", __classPrivateFieldSet); exporter("__classPrivateFieldIn", __classPrivateFieldIn); }); } }); // ../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/shared.js var require_shared2 = __commonJS({ "../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/shared.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.maybeSetModuleExports = void 0; var tslib_1 = require_tslib2(); var types_1 = tslib_1.__importDefault(require_types2()); function default_1(fork) { var types11 = fork.use(types_1.default); var Type = types11.Type; var builtin = types11.builtInTypes; var isNumber = builtin.number; function geq(than) { return Type.from(function(value) { return isNumber.check(value) && value >= than; }, isNumber + " >= " + than); } ; var defaults3 = { "null": function() { return null; }, "emptyArray": function() { return []; }, "false": function() { return false; }, "true": function() { return true; }, "undefined": function() { }, "use strict": function() { return "use strict"; } }; var naiveIsPrimitive = Type.or(builtin.string, builtin.number, builtin.boolean, builtin.null, builtin.undefined); var isPrimitive = Type.from(function(value) { if (value === null) return true; var type = typeof value; if (type === "object" || type === "function") { return false; } return true; }, naiveIsPrimitive.toString()); return { geq, defaults: defaults3, isPrimitive }; } exports.default = default_1; function maybeSetModuleExports(moduleGetter) { try { var nodeModule = moduleGetter(); var originalExports = nodeModule.exports; var defaultExport = originalExports["default"]; } catch (_a) { return; } if (defaultExport && defaultExport !== originalExports && typeof originalExports === "object") { Object.assign(defaultExport, originalExports, { "default": defaultExport }); if (originalExports.__esModule) { Object.defineProperty(defaultExport, "__esModule", { value: true }); } nodeModule.exports = defaultExport; } } exports.maybeSetModuleExports = maybeSetModuleExports; } }); // ../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/types.js var require_types2 = __commonJS({ "../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/types.js"(exports, module2) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Def = void 0; var tslib_1 = require_tslib2(); var shared_1 = require_shared2(); var Op = Object.prototype; var objToStr = Op.toString; var hasOwn = Op.hasOwnProperty; var BaseType = function() { function BaseType2() { } BaseType2.prototype.assert = function(value, deep) { if (!this.check(value, deep)) { var str = shallowStringify(value); throw new Error(str + " does not match type " + this); } return true; }; BaseType2.prototype.arrayOf = function() { var elemType = this; return new ArrayType(elemType); }; return BaseType2; }(); var ArrayType = function(_super) { tslib_1.__extends(ArrayType2, _super); function ArrayType2(elemType) { var _this = _super.call(this) || this; _this.elemType = elemType; _this.kind = "ArrayType"; return _this; } ArrayType2.prototype.toString = function() { return "[" + this.elemType + "]"; }; ArrayType2.prototype.check = function(value, deep) { var _this = this; return Array.isArray(value) && value.every(function(elem) { return _this.elemType.check(elem, deep); }); }; return ArrayType2; }(BaseType); var IdentityType = function(_super) { tslib_1.__extends(IdentityType2, _super); function IdentityType2(value) { var _this = _super.call(this) || this; _this.value = value; _this.kind = "IdentityType"; return _this; } IdentityType2.prototype.toString = function() { return String(this.value); }; IdentityType2.prototype.check = function(value, deep) { var result = value === this.value; if (!result && typeof deep === "function") { deep(this, value); } return result; }; return IdentityType2; }(BaseType); var ObjectType = function(_super) { tslib_1.__extends(ObjectType2, _super); function ObjectType2(fields) { var _this = _super.call(this) || this; _this.fields = fields; _this.kind = "ObjectType"; return _this; } ObjectType2.prototype.toString = function() { return "{ " + this.fields.join(", ") + " }"; }; ObjectType2.prototype.check = function(value, deep) { return objToStr.call(value) === objToStr.call({}) && this.fields.every(function(field) { return field.type.check(value[field.name], deep); }); }; return ObjectType2; }(BaseType); var OrType = function(_super) { tslib_1.__extends(OrType2, _super); function OrType2(types11) { var _this = _super.call(this) || this; _this.types = types11; _this.kind = "OrType"; return _this; } OrType2.prototype.toString = function() { return this.types.join(" | "); }; OrType2.prototype.check = function(value, deep) { if (this.types.some(function(type) { return type.check(value, !!deep); })) { return true; } if (typeof deep === "function") { deep(this, value); } return false; }; return OrType2; }(BaseType); var PredicateType = function(_super) { tslib_1.__extends(PredicateType2, _super); function PredicateType2(name, predicate) { var _this = _super.call(this) || this; _this.name = name; _this.predicate = predicate; _this.kind = "PredicateType"; return _this; } PredicateType2.prototype.toString = function() { return this.name; }; PredicateType2.prototype.check = function(value, deep) { var result = this.predicate(value, deep); if (!result && typeof deep === "function") { deep(this, value); } return result; }; return PredicateType2; }(BaseType); var Def = function() { function Def2(type, typeName) { this.type = type; this.typeName = typeName; this.baseNames = []; this.ownFields = /* @__PURE__ */ Object.create(null); this.allSupertypes = /* @__PURE__ */ Object.create(null); this.supertypeList = []; this.allFields = /* @__PURE__ */ Object.create(null); this.fieldNames = []; this.finalized = false; this.buildable = false; this.buildParams = []; } Def2.prototype.isSupertypeOf = function(that) { if (that instanceof Def2) { if (this.finalized !== true || that.finalized !== true) { throw new Error(""); } return hasOwn.call(that.allSupertypes, this.typeName); } else { throw new Error(that + " is not a Def"); } }; Def2.prototype.checkAllFields = function(value, deep) { var allFields = this.allFields; if (this.finalized !== true) { throw new Error("" + this.typeName); } function checkFieldByName(name) { var field = allFields[name]; var type = field.type; var child = field.getValue(value); return type.check(child, deep); } return value !== null && typeof value === "object" && Object.keys(allFields).every(checkFieldByName); }; Def2.prototype.bases = function() { var supertypeNames = []; for (var _i = 0; _i < arguments.length; _i++) { supertypeNames[_i] = arguments[_i]; } var bases = this.baseNames; if (this.finalized) { if (supertypeNames.length !== bases.length) { throw new Error(""); } for (var i3 = 0; i3 < supertypeNames.length; i3++) { if (supertypeNames[i3] !== bases[i3]) { throw new Error(""); } } return this; } supertypeNames.forEach(function(baseName) { if (bases.indexOf(baseName) < 0) { bases.push(baseName); } }); return this; }; return Def2; }(); exports.Def = Def; var Field = function() { function Field2(name, type, defaultFn, hidden5) { this.name = name; this.type = type; this.defaultFn = defaultFn; this.hidden = !!hidden5; } Field2.prototype.toString = function() { return JSON.stringify(this.name) + ": " + this.type; }; Field2.prototype.getValue = function(obj) { var value = obj[this.name]; if (typeof value !== "undefined") { return value; } if (typeof this.defaultFn === "function") { value = this.defaultFn.call(obj); } return value; }; return Field2; }(); function shallowStringify(value) { if (Array.isArray(value)) { return "[" + value.map(shallowStringify).join(", ") + "]"; } if (value && typeof value === "object") { return "{ " + Object.keys(value).map(function(key) { return key + ": " + value[key]; }).join(", ") + " }"; } return JSON.stringify(value); } function typesPlugin(_fork) { var Type = { or: function() { var types11 = []; for (var _i = 0; _i < arguments.length; _i++) { types11[_i] = arguments[_i]; } return new OrType(types11.map(function(type) { return Type.from(type); })); }, from: function(value, name) { if (value instanceof ArrayType || value instanceof IdentityType || value instanceof ObjectType || value instanceof OrType || value instanceof PredicateType) { return value; } if (value instanceof Def) { return value.type; } if (isArray.check(value)) { if (value.length !== 1) { throw new Error("only one element type is permitted for typed arrays"); } return new ArrayType(Type.from(value[0])); } if (isObject2.check(value)) { return new ObjectType(Object.keys(value).map(function(name2) { return new Field(name2, Type.from(value[name2], name2)); })); } if (typeof value === "function") { var bicfIndex = builtInCtorFns.indexOf(value); if (bicfIndex >= 0) { return builtInCtorTypes[bicfIndex]; } if (typeof name !== "string") { throw new Error("missing name"); } return new PredicateType(name, value); } return new IdentityType(value); }, def: function(typeName) { return hasOwn.call(defCache, typeName) ? defCache[typeName] : defCache[typeName] = new DefImpl(typeName); }, hasDef: function(typeName) { return hasOwn.call(defCache, typeName); } }; var builtInCtorFns = []; var builtInCtorTypes = []; function defBuiltInType(name, example) { var objStr = objToStr.call(example); var type = new PredicateType(name, function(value) { return objToStr.call(value) === objStr; }); if (example && typeof example.constructor === "function") { builtInCtorFns.push(example.constructor); builtInCtorTypes.push(type); } return type; } var isString = defBuiltInType("string", "truthy"); var isFunction = defBuiltInType("function", function() { }); var isArray = defBuiltInType("array", []); var isObject2 = defBuiltInType("object", {}); var isRegExp = defBuiltInType("RegExp", /./); var isDate = defBuiltInType("Date", new Date()); var isNumber = defBuiltInType("number", 3); var isBoolean = defBuiltInType("boolean", true); var isNull = defBuiltInType("null", null); var isUndefined = defBuiltInType("undefined", void 0); var isBigInt = typeof BigInt === "function" ? defBuiltInType("BigInt", BigInt(1234)) : new PredicateType("BigInt", function() { return false; }); var builtInTypes = { string: isString, function: isFunction, array: isArray, object: isObject2, RegExp: isRegExp, Date: isDate, number: isNumber, boolean: isBoolean, null: isNull, undefined: isUndefined, BigInt: isBigInt }; var defCache = /* @__PURE__ */ Object.create(null); function defFromValue(value) { if (value && typeof value === "object") { var type = value.type; if (typeof type === "string" && hasOwn.call(defCache, type)) { var d = defCache[type]; if (d.finalized) { return d; } } } return null; } var DefImpl = function(_super) { tslib_1.__extends(DefImpl2, _super); function DefImpl2(typeName) { var _this = _super.call(this, new PredicateType(typeName, function(value, deep) { return _this.check(value, deep); }), typeName) || this; return _this; } DefImpl2.prototype.check = function(value, deep) { if (this.finalized !== true) { throw new Error("prematurely checking unfinalized type " + this.typeName); } if (value === null || typeof value !== "object") { return false; } var vDef = defFromValue(value); if (!vDef) { if (this.typeName === "SourceLocation" || this.typeName === "Position") { return this.checkAllFields(value, deep); } return false; } if (deep && vDef === this) { return this.checkAllFields(value, deep); } if (!this.isSupertypeOf(vDef)) { return false; } if (!deep) { return true; } return vDef.checkAllFields(value, deep) && this.checkAllFields(value, false); }; DefImpl2.prototype.build = function() { var _this = this; var buildParams = []; for (var _i = 0; _i < arguments.length; _i++) { buildParams[_i] = arguments[_i]; } this.buildParams = buildParams; if (this.buildable) { return this; } this.field("type", String, function() { return _this.typeName; }); this.buildable = true; var addParam = function(built, param, arg, isArgAvailable) { if (hasOwn.call(built, param)) return; var all = _this.allFields; if (!hasOwn.call(all, param)) { throw new Error("" + param); } var field = all[param]; var type = field.type; var value; if (isArgAvailable) { value = arg; } else if (field.defaultFn) { value = field.defaultFn.call(built); } else { var message = "no value or default function given for field " + JSON.stringify(param) + " of " + _this.typeName + "(" + _this.buildParams.map(function(name) { return all[name]; }).join(", ") + ")"; throw new Error(message); } if (!type.check(value)) { throw new Error(shallowStringify(value) + " does not match field " + field + " of type " + _this.typeName); } built[param] = value; }; var builder = function() { var args = []; for (var _i2 = 0; _i2 < arguments.length; _i2++) { args[_i2] = arguments[_i2]; } var argc = args.length; if (!_this.finalized) { throw new Error("attempting to instantiate unfinalized type " + _this.typeName); } var built = Object.create(nodePrototype); _this.buildParams.forEach(function(param, i3) { if (i3 < argc) { addParam(built, param, args[i3], true); } else { addParam(built, param, null, false); } }); Object.keys(_this.allFields).forEach(function(param) { addParam(built, param, null, false); }); if (built.type !== _this.typeName) { throw new Error(""); } return built; }; builder.from = function(obj) { if (!_this.finalized) { throw new Error("attempting to instantiate unfinalized type " + _this.typeName); } var built = Object.create(nodePrototype); Object.keys(_this.allFields).forEach(function(param) { if (hasOwn.call(obj, param)) { addParam(built, param, obj[param], true); } else { addParam(built, param, null, false); } }); if (built.type !== _this.typeName) { throw new Error(""); } return built; }; Object.defineProperty(builders, getBuilderName(this.typeName), { enumerable: true, value: builder }); return this; }; DefImpl2.prototype.field = function(name, type, defaultFn, hidden5) { if (this.finalized) { console.error("Ignoring attempt to redefine field " + JSON.stringify(name) + " of finalized type " + JSON.stringify(this.typeName)); return this; } this.ownFields[name] = new Field(name, Type.from(type), defaultFn, hidden5); return this; }; DefImpl2.prototype.finalize = function() { var _this = this; if (!this.finalized) { var allFields = this.allFields; var allSupertypes = this.allSupertypes; this.baseNames.forEach(function(name) { var def = defCache[name]; if (def instanceof Def) { def.finalize(); extend(allFields, def.allFields); extend(allSupertypes, def.allSupertypes); } else { var message = "unknown supertype name " + JSON.stringify(name) + " for subtype " + JSON.stringify(_this.typeName); throw new Error(message); } }); extend(allFields, this.ownFields); allSupertypes[this.typeName] = this; this.fieldNames.length = 0; for (var fieldName in allFields) { if (hasOwn.call(allFields, fieldName) && !allFields[fieldName].hidden) { this.fieldNames.push(fieldName); } } Object.defineProperty(namedTypes, this.typeName, { enumerable: true, value: this.type }); this.finalized = true; populateSupertypeList(this.typeName, this.supertypeList); if (this.buildable && this.supertypeList.lastIndexOf("Expression") >= 0) { wrapExpressionBuilderWithStatement(this.typeName); } } }; return DefImpl2; }(Def); function getSupertypeNames(typeName) { if (!hasOwn.call(defCache, typeName)) { throw new Error(""); } var d = defCache[typeName]; if (d.finalized !== true) { throw new Error(""); } return d.supertypeList.slice(1); } function computeSupertypeLookupTable(candidates) { var table = {}; var typeNames = Object.keys(defCache); var typeNameCount = typeNames.length; for (var i3 = 0; i3 < typeNameCount; ++i3) { var typeName = typeNames[i3]; var d = defCache[typeName]; if (d.finalized !== true) { throw new Error("" + typeName); } for (var j = 0; j < d.supertypeList.length; ++j) { var superTypeName = d.supertypeList[j]; if (hasOwn.call(candidates, superTypeName)) { table[typeName] = superTypeName; break; } } } return table; } var builders = /* @__PURE__ */ Object.create(null); var nodePrototype = {}; function defineMethod(name, func) { var old = nodePrototype[name]; if (isUndefined.check(func)) { delete nodePrototype[name]; } else { isFunction.assert(func); Object.defineProperty(nodePrototype, name, { enumerable: true, configurable: true, value: func }); } return old; } function getBuilderName(typeName) { return typeName.replace(/^[A-Z]+/, function(upperCasePrefix) { var len = upperCasePrefix.length; switch (len) { case 0: return ""; case 1: return upperCasePrefix.toLowerCase(); default: return upperCasePrefix.slice(0, len - 1).toLowerCase() + upperCasePrefix.charAt(len - 1); } }); } function getStatementBuilderName(typeName) { typeName = getBuilderName(typeName); return typeName.replace(/(Expression)?$/, "Statement"); } var namedTypes = {}; function getFieldNames(object) { var d = defFromValue(object); if (d) { return d.fieldNames.slice(0); } if ("type" in object) { throw new Error("did not recognize object of type " + JSON.stringify(object.type)); } return Object.keys(object); } function getFieldValue(object, fieldName) { var d = defFromValue(object); if (d) { var field = d.allFields[fieldName]; if (field) { return field.getValue(object); } } return object && object[fieldName]; } function eachField(object, callback, context) { getFieldNames(object).forEach(function(name) { callback.call(this, name, getFieldValue(object, name)); }, context); } function someField(object, callback, context) { return getFieldNames(object).some(function(name) { return callback.call(this, name, getFieldValue(object, name)); }, context); } function wrapExpressionBuilderWithStatement(typeName) { var wrapperName = getStatementBuilderName(typeName); if (builders[wrapperName]) return; var wrapped = builders[getBuilderName(typeName)]; if (!wrapped) return; var builder = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return builders.expressionStatement(wrapped.apply(builders, args)); }; builder.from = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return builders.expressionStatement(wrapped.from.apply(builders, args)); }; builders[wrapperName] = builder; } function populateSupertypeList(typeName, list) { list.length = 0; list.push(typeName); var lastSeen = /* @__PURE__ */ Object.create(null); for (var pos = 0; pos < list.length; ++pos) { typeName = list[pos]; var d = defCache[typeName]; if (d.finalized !== true) { throw new Error(""); } if (hasOwn.call(lastSeen, typeName)) { delete list[lastSeen[typeName]]; } lastSeen[typeName] = pos; list.push.apply(list, d.baseNames); } for (var to = 0, from = to, len = list.length; from < len; ++from) { if (hasOwn.call(list, from)) { list[to++] = list[from]; } } list.length = to; } function extend(into, from) { Object.keys(from).forEach(function(name) { into[name] = from[name]; }); return into; } function finalize() { Object.keys(defCache).forEach(function(name) { defCache[name].finalize(); }); } return { Type, builtInTypes, getSupertypeNames, computeSupertypeLookupTable, builders, defineMethod, getBuilderName, getStatementBuilderName, namedTypes, getFieldNames, getFieldValue, eachField, someField, finalize }; } exports.default = typesPlugin; (0, shared_1.maybeSetModuleExports)(function() { return module2; }); } }); // ../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/path.js var require_path3 = __commonJS({ "../../node_modules/.pnpm/ast-types@0.16.1/node_modules/ast-types/lib/path.js"(exports, module2) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require_tslib2(); var shared_1 = require_shared2(); var types_1 = tslib_1.__importDefault(require_types2()); var Op = Object.prototype; var hasOwn = Op.hasOwnProperty; function pathPlugin(fork) { var types11 = fork.use(types_1.default); var isArray = types11.builtInTypes.array; var isNumber = types11.builtInTypes.number; var Path3 = function Path4(value, parentPath, name) { if (!(this instanceof Path4)) { throw new Error("Path constructor cannot be invoked without 'new'"); } if (parentPath) { if (!(parentPath instanceof Path4)) { throw new Error(""); } } else { parentPath = null; name = null; } this.value = value; this.parentPath = parentPath; this.name = name; this.__childCache = null; }; var Pp = Path3.prototype; function getChildCache(path5) { return path5.__childCache || (path5.__childCache = /* @__PURE__ */ Object.create(null)); } function getChildPath(path5, name) { var cache = getChildCache(path5); var actualChildValue = path5.getValueProperty(name); var childPath = cache[name]; if (!hasOwn.call(cache, name) || childPath.value !== actualChildValue) { childPath = cache[name] = new path5.constructor(actualChildValue, path5, name); } return childPath; } Pp.getValueProperty = function getValueProperty(name) { return this.value[name]; }; Pp.get = function get() { var names = []; for (var _i = 0; _i < arguments.length; _i++) { names[_i] = arguments[_i]; } var path5 = this; var count = names.length; for (var i3 = 0; i3 < count; ++i3) { path5 = getChildPath(path5, names[i3]); } return path5; }; Pp.each = function each(callback, context) { var childPaths = []; var len = this.value.length; var i3 = 0; for (var i3 = 0; i3 < len; ++i3) { if (hasOwn.call(this.value, i3)) { childPaths[i3] = this.get(i3); } } context = context || this; for (i3 = 0; i3 < len; ++i3) { if (hasOwn.call(childPaths, i3)) { callback.call(context, childPaths[i3]); } } }; Pp.map = function map(callback, context) { var result = []; this.each(function(childPath) { result.push(callback.call(this, childPath)); }, context); return result; }; Pp.filter = function filter3(callback, context) { var result = []; this.each(function(childPath) { if (callback.call(this, childPath)) { result.push(childPath