New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@boost/common

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boost/common - npm Package Compare versions

Comparing version 2.7.2 to 2.8.0

lib/helpers/index.js

4

dts/CommonError.d.ts

@@ -8,4 +8,4 @@ declare const errors: {

export declare type CommonErrorCode = keyof typeof errors;
declare const _default: new (code: "PARSE_INVALID_EXT" | "PATH_REQUIRE_ABSOLUTE" | "PATH_RESOLVE_LOOKUPS" | "PROJECT_NO_PACKAGE", params?: unknown[] | undefined) => Error & import("@boost/internal/dts/createScopedError").ScopedError<"PARSE_INVALID_EXT" | "PATH_REQUIRE_ABSOLUTE" | "PATH_RESOLVE_LOOKUPS" | "PROJECT_NO_PACKAGE">;
export default _default;
export declare const CommonError: new (code: "PARSE_INVALID_EXT" | "PATH_REQUIRE_ABSOLUTE" | "PATH_RESOLVE_LOOKUPS" | "PROJECT_NO_PACKAGE", params?: unknown[] | undefined) => Error & import("@boost/internal").ScopedError<"PARSE_INVALID_EXT" | "PATH_REQUIRE_ABSOLUTE" | "PATH_RESOLVE_LOOKUPS" | "PROJECT_NO_PACKAGE">;
export {};
//# sourceMappingURL=CommonError.d.ts.map
import { Blueprint, Predicates } from 'optimal';
import { Optionable } from './types';
export default abstract class Contract<T extends object = {}> implements Optionable<T> {
export declare abstract class Contract<T extends object = {}> implements Optionable<T> {
readonly options: Readonly<Required<T>>;

@@ -5,0 +5,0 @@ constructor(options?: T);

@@ -1,2 +0,2 @@

export default class ExitError extends Error {
export declare class ExitError extends Error {
code: number;

@@ -3,0 +3,0 @@ constructor(message: string, code: number);

import { Blueprint } from 'optimal';
import { BlueprintFactory } from '../types';
export default function createBlueprint<T extends object>(factory: BlueprintFactory<T>): Blueprint<T>;
export declare function createBlueprint<T extends object>(factory: BlueprintFactory<T>): Blueprint<T>;
//# sourceMappingURL=createBlueprint.d.ts.map

@@ -1,2 +0,2 @@

export default function deepFreeze<T extends object = object>(obj: T): T;
export declare function deepFreeze<T extends object = object>(obj: T): T;
//# sourceMappingURL=deepFreeze.d.ts.map

@@ -5,3 +5,3 @@ export declare type MergableArray = unknown[];

export declare type InferMergeable<T> = T extends unknown[] ? MergableArray : T extends object ? MergableObject : never;
export default function deepMerge<T extends Mergeable, V extends InferMergeable<T>>(base: T, other?: V): T;
export declare function deepMerge<T extends Mergeable, V extends InferMergeable<T>>(base: T, other?: V): T;
//# sourceMappingURL=deepMerge.d.ts.map
import { Options } from 'pretty-ms';
export default function formatMs(ms: number, options?: Options): string;
export declare function formatMs(ms: number, options?: Options): string;
//# sourceMappingURL=formatMs.d.ts.map

@@ -1,15 +0,15 @@

export { default as createBlueprint } from './createBlueprint';
export { default as deepFreeze } from './deepFreeze';
export { default as deepMerge } from './deepMerge';
export { default as formatMs } from './formatMs';
export { default as instanceOf } from './instanceOf';
export { default as isEmpty } from './isEmpty';
export { default as isFilePath } from './isFilePath';
export { default as isModuleName } from './isModuleName';
export { default as isObject } from './isObject';
export { default as isPlainObject } from './isPlainObject';
export { default as parseFile } from './parseFile';
export { default as requireModule } from './requireModule';
export { default as requireTypedModule } from './requireTypedModule';
export { default as toArray } from './toArray';
export * from './createBlueprint';
export * from './deepFreeze';
export * from './deepMerge';
export * from './formatMs';
export * from './instanceOf';
export * from './isEmpty';
export * from './isFilePath';
export * from './isModuleName';
export * from './isObject';
export * from './isPlainObject';
export * from './parseFile';
export * from './requireModule';
export * from './requireTypedModule';
export * from './toArray';
//# sourceMappingURL=index.d.ts.map

@@ -7,3 +7,3 @@ import { Constructor } from '../types';

*/
export default function instanceOf<T = unknown>(object: unknown, declaration: Constructor<T>, loose?: boolean): object is T;
export declare function instanceOf<T = unknown>(object: unknown, declaration: Constructor<T>, loose?: boolean): object is T;
//# sourceMappingURL=instanceOf.d.ts.map

@@ -1,2 +0,2 @@

export default function isEmpty(value: unknown): boolean;
export declare function isEmpty(value: unknown): boolean;
//# sourceMappingURL=isEmpty.d.ts.map
import { PortablePath } from '../types';
export default function isFilePath(path: PortablePath): boolean;
export declare function isFilePath(path: PortablePath): boolean;
//# sourceMappingURL=isFilePath.d.ts.map
import { ModuleName } from '../types';
export default function isModuleName(name: ModuleName): boolean;
export declare function isModuleName(name: ModuleName): boolean;
//# sourceMappingURL=isModuleName.d.ts.map

@@ -1,2 +0,2 @@

export default function isObject<T = object>(value: unknown): value is T;
export declare function isObject<T = object>(value: unknown): value is T;
//# sourceMappingURL=isObject.d.ts.map

@@ -1,2 +0,2 @@

export default function isPlainObject<T = object>(value: unknown, loose?: boolean): value is T;
export declare function isPlainObject<T = object>(value: unknown, loose?: boolean): value is T;
//# sourceMappingURL=isPlainObject.d.ts.map
import { PortablePath } from '../types';
export default function parseFile<T>(filePath: PortablePath): T;
export declare function parseFile<T>(filePath: PortablePath): T;
//# sourceMappingURL=parseFile.d.ts.map
import { PortablePath } from '../types';
export default function requireModule<T>(path: PortablePath): T;
export declare function requireModule<T>(path: PortablePath): T;
//# sourceMappingURL=requireModule.d.ts.map

@@ -9,3 +9,3 @@ import { PortablePath } from '../types';

}
export default function requireTypedModule<T>(path: PortablePath): T;
export declare function requireTypedModule<T>(path: PortablePath): T;
//# sourceMappingURL=requireTypedModule.d.ts.map

@@ -1,2 +0,2 @@

export default function toArray<T = unknown>(value?: T | T[]): T[];
export declare function toArray<T = unknown>(value?: T | T[]): T[];
//# sourceMappingURL=toArray.d.ts.map

@@ -6,18 +6,17 @@ /**

import optimal, { Blueprint, Predicates, predicates } from 'optimal';
import type { CommonErrorCode } from './CommonError';
import CommonError from './CommonError';
import Contract from './Contract';
import ExitError from './ExitError';
import PackageGraph from './PackageGraph';
import Path from './Path';
import PathResolver from './PathResolver';
import Project from './Project';
import * as json from './serializers/json';
import * as yaml from './serializers/yaml';
export * from './CommonError';
export * from './constants';
export * from './Contract';
export * from './ExitError';
export * from './helpers';
export * from './PackageGraph';
export * from './Path';
export * from './PathResolver';
export * from './Project';
export * as json from './serializers/json';
export * as yaml from './serializers/yaml';
export * from './types';
export * from '@boost/decorators';
export { Blueprint, CommonError, Contract, ExitError, json, optimal, PackageGraph, Path, PathResolver, Predicates, predicates, Project, yaml, };
export type { CommonErrorCode };
export { optimal, predicates };
export type { Blueprint, Predicates };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

export default function interopRequireModule(path: string): unknown;
export declare function interopRequireModule(path: string): unknown;
//# sourceMappingURL=interopRequireModule.d.ts.map

@@ -8,3 +8,3 @@ import { PackageGraphTree, PackageStructure } from './types';

}
export default class PackageGraph<T extends PackageStructure = PackageStructure> {
export declare class PackageGraph<T extends PackageStructure = PackageStructure> {
protected mapped: boolean;

@@ -11,0 +11,0 @@ protected nodes: Map<string, Node>;

import { FilePath, PortablePath } from './types';
export default class Path {
export declare class Path {
static DELIMITER: string;

@@ -4,0 +4,0 @@ static SEP: string;

@@ -1,5 +0,7 @@

import Path from './Path';
import { LookupType, PortablePath } from './types';
export default class PathResolver {
import { Path } from './Path';
import { LookupType, ModuleResolver, PortablePath } from './types';
export declare class PathResolver {
private lookups;
private resolver;
constructor(resolver?: ModuleResolver);
/**

@@ -6,0 +8,0 @@ * Return a list of all lookup paths.

@@ -1,2 +0,2 @@

import Path from './Path';
import { Path } from './Path';
import { FilePath, PackageStructure, PortablePath, WorkspaceMetadata, WorkspacePackage } from './types';

@@ -6,3 +6,3 @@ export interface ProjectSearchOptions {

}
export default class Project {
export declare class Project {
readonly root: Path;

@@ -9,0 +9,0 @@ constructor(root?: PortablePath);

import { Blueprint, Predicates } from 'optimal';
import Path from './Path';
import type { Path } from './Path';
export declare type ModuleName = string;

@@ -15,2 +15,3 @@ export declare type FilePath = string;

}
export declare type ModuleResolver = (path: ModuleName) => FilePath;
export declare type AbstractConstructor<T> = Function & {

@@ -17,0 +18,0 @@ prototype: T;

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -8,3 +6,1093 @@

});
var REACT_ELEMENT_TYPE;
function _jsx(type, props, key, children) {
if (!REACT_ELEMENT_TYPE) {
REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7;
}
var defaultProps = type && type.defaultProps;
var childrenLength = arguments.length - 3;
if (!props && childrenLength !== 0) {
props = {
children: void 0
};
}
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = new Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 3];
}
props.children = childArray;
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key === undefined ? null : "" + key,
ref: null,
props: props,
_owner: null
};
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _wrapRegExp() {
_wrapRegExp = function (re, groups) {
return new BabelRegExp(re, undefined, groups);
};
var _super = RegExp.prototype;
var _groups = new WeakMap();
function BabelRegExp(re, flags, groups) {
var _this = new RegExp(re, flags);
_groups.set(_this, groups || _groups.get(re));
return _setPrototypeOf(_this, BabelRegExp.prototype);
}
_inherits(BabelRegExp, RegExp);
BabelRegExp.prototype.exec = function (str) {
var result = _super.exec.call(this, str);
if (result) result.groups = buildGroups(result, this);
return result;
};
BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
if (typeof substitution === "string") {
var groups = _groups.get(this);
return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
return "$" + groups[name];
}));
} else if (typeof substitution === "function") {
var _this = this;
return _super[Symbol.replace].call(this, str, function () {
var args = arguments;
if (typeof args[args.length - 1] !== "object") {
args = [].slice.call(args);
args.push(buildGroups(args, _this));
}
return substitution.apply(this, args);
});
} else {
return _super[Symbol.replace].call(this, str, substitution);
}
};
function buildGroups(result, re) {
var g = _groups.get(re);
return Object.keys(g).reduce(function (groups, name) {
groups[name] = result[g[name]];
return groups;
}, Object.create(null));
}
return _wrapRegExp.apply(this, arguments);
}
function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) method = iterable[Symbol.asyncIterator];
if (method == null && Symbol.iterator) method = iterable[Symbol.iterator];
}
if (method == null) method = iterable["@@asyncIterator"];
if (method == null) method = iterable["@@iterator"];
if (method == null) throw new TypeError("Object is not async iterable");
return method.call(iterable);
}
function _AwaitValue(value) {
this.wrapped = value;
}
function _AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof _AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume(key === "return" ? "return" : "next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
_AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () {
return this;
};
_AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
_AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
_AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
function _wrapAsyncGenerator(fn) {
return function () {
return new _AsyncGenerator(fn.apply(this, arguments));
};
}
function _awaitAsyncGenerator(value) {
return new _AwaitValue(value);
}
function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () {
return this;
};
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner.throw === "function") {
iter.throw = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner.return === "function") {
iter.return = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value);
};
}
return iter;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? Object(arguments[i]) : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function _newArrowCheck(innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
}
function _objectDestructuringEmpty(obj) {
if (obj == null) throw new TypeError("Cannot destructure undefined");
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function set(target, property, value, receiver) {
if (typeof Reflect !== "undefined" && Reflect.set) {
set = Reflect.set;
} else {
set = function set(target, property, value, receiver) {
var base = _superPropBase(target, property);
var desc;
if (base) {
desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.set) {
desc.set.call(receiver, value);
return true;
} else if (!desc.writable) {
return false;
}
}
desc = Object.getOwnPropertyDescriptor(receiver, property);
if (desc) {
if (!desc.writable) {
return false;
}
desc.value = value;
Object.defineProperty(receiver, property, desc);
} else {
_defineProperty(receiver, property, value);
}
return true;
};
}
return set(target, property, value, receiver);
}
function _set(target, property, value, receiver, isStrict) {
var s = set(target, property, value, receiver || target);
if (!s && isStrict) {
throw new Error('failed to set property');
}
return value;
}
function _taggedTemplateLiteral(strings, raw) {
if (!raw) {
raw = strings.slice(0);
}
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
}
function _taggedTemplateLiteralLoose(strings, raw) {
if (!raw) {
raw = strings.slice(0);
}
strings.raw = raw;
return strings;
}
function _readOnlyError(name) {
throw new TypeError("\"" + name + "\" is read-only");
}
function _writeOnlyError(name) {
throw new TypeError("\"" + name + "\" is write-only");
}
function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
function _temporalUndefined() {}
function _tdz(name) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
}
function _temporalRef(val, name) {
return val === _temporalUndefined ? _tdz(name) : val;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _slicedToArrayLoose(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toArray(arr) {
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _maybeArrayLike(next, arr, i) {
if (arr && !Array.isArray(arr) && typeof arr.length === "number") {
var len = arr.length;
return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len);
}
return next(arr, i);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _iterableToArrayLimitLoose(arr, i) {
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
if (_i == null) return;
var _arr = [];
for (_i = _i.call(arr), _step; !(_step = _i.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _skipFirstGeneratorNext(fn) {
return function () {
var it = fn.apply(this, arguments);
it.next();
return it;
};
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
function _initializerWarningHelper(descriptor, context) {
throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.');
}
function _initializerDefineProperty(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
enumerable: descriptor.enumerable,
configurable: descriptor.configurable,
writable: descriptor.writable,
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
});
}
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {

@@ -39,3 +1127,630 @@ var desc = {};

var id = 0;
function _classPrivateFieldLooseKey(name) {
return "__private_" + id++ + "_" + name;
}
function _classPrivateFieldLooseBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
return _classApplyDescriptorGet(receiver, descriptor);
}
function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
_classApplyDescriptorSet(receiver, descriptor, value);
return value;
}
function _classPrivateFieldDestructureSet(receiver, privateMap) {
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
return _classApplyDescriptorDestructureSet(receiver, descriptor);
}
function _classExtractFieldDescriptor(receiver, privateMap, action) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to " + action + " private field on non-instance");
}
return privateMap.get(receiver);
}
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
_classCheckPrivateStaticAccess(receiver, classConstructor);
_classCheckPrivateStaticFieldDescriptor(descriptor, "get");
return _classApplyDescriptorGet(receiver, descriptor);
}
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
_classCheckPrivateStaticAccess(receiver, classConstructor);
_classCheckPrivateStaticFieldDescriptor(descriptor, "set");
_classApplyDescriptorSet(receiver, descriptor, value);
return value;
}
function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
_classCheckPrivateStaticAccess(receiver, classConstructor);
return method;
}
function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
function _classApplyDescriptorGet(receiver, descriptor) {
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
function _classApplyDescriptorSet(receiver, descriptor, value) {
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
}
function _classApplyDescriptorDestructureSet(receiver, descriptor) {
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
function _classStaticPrivateFieldDestructureSet(receiver, classConstructor, descriptor) {
_classCheckPrivateStaticAccess(receiver, classConstructor);
_classCheckPrivateStaticFieldDescriptor(descriptor, "set");
return _classApplyDescriptorDestructureSet(receiver, descriptor);
}
function _classCheckPrivateStaticAccess(receiver, classConstructor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
}
function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
if (descriptor === undefined) {
throw new TypeError("attempted to " + action + " private static field before its declaration");
}
}
function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function () {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function (O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function (F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function (receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function (elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
static: [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function (element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function (element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function (elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function (element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function (elementObjects) {
if (elementObjects === undefined) return;
return _toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function (elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = _toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function (elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function (elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function (obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function (constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function (obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = _toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function (other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
exports.AsyncGenerator = _AsyncGenerator;
exports.AwaitValue = _AwaitValue;
exports.applyDecoratedDescriptor = _applyDecoratedDescriptor;
exports.arrayLikeToArray = _arrayLikeToArray;
exports.arrayWithHoles = _arrayWithHoles;
exports.arrayWithoutHoles = _arrayWithoutHoles;
exports.assertThisInitialized = _assertThisInitialized;
exports.asyncGeneratorDelegate = _asyncGeneratorDelegate;
exports.asyncIterator = _asyncIterator;
exports.asyncToGenerator = _asyncToGenerator;
exports.awaitAsyncGenerator = _awaitAsyncGenerator;
exports.classApplyDescriptorDestructureSet = _classApplyDescriptorDestructureSet;
exports.classApplyDescriptorGet = _classApplyDescriptorGet;
exports.classApplyDescriptorSet = _classApplyDescriptorSet;
exports.classCallCheck = _classCallCheck;
exports.classCheckPrivateStaticAccess = _classCheckPrivateStaticAccess;
exports.classCheckPrivateStaticFieldDescriptor = _classCheckPrivateStaticFieldDescriptor;
exports.classExtractFieldDescriptor = _classExtractFieldDescriptor;
exports.classNameTDZError = _classNameTDZError;
exports.classPrivateFieldDestructureSet = _classPrivateFieldDestructureSet;
exports.classPrivateFieldGet = _classPrivateFieldGet;
exports.classPrivateFieldLooseBase = _classPrivateFieldLooseBase;
exports.classPrivateFieldLooseKey = _classPrivateFieldLooseKey;
exports.classPrivateFieldSet = _classPrivateFieldSet;
exports.classPrivateMethodGet = _classPrivateMethodGet;
exports.classPrivateMethodSet = _classPrivateMethodSet;
exports.classStaticPrivateFieldDestructureSet = _classStaticPrivateFieldDestructureSet;
exports.classStaticPrivateFieldSpecGet = _classStaticPrivateFieldSpecGet;
exports.classStaticPrivateFieldSpecSet = _classStaticPrivateFieldSpecSet;
exports.classStaticPrivateMethodGet = _classStaticPrivateMethodGet;
exports.classStaticPrivateMethodSet = _classStaticPrivateMethodSet;
exports.construct = _construct;
exports.createClass = _createClass;
exports.createForOfIteratorHelper = _createForOfIteratorHelper;
exports.createForOfIteratorHelperLoose = _createForOfIteratorHelperLoose;
exports.createSuper = _createSuper;
exports.decorate = _decorate;
exports.defaults = _defaults;
exports.defineEnumerableProperties = _defineEnumerableProperties;
exports.defineProperty = _defineProperty;
exports.extends = _extends;
exports.get = _get;
exports.getPrototypeOf = _getPrototypeOf;
exports.inherits = _inherits;
exports.inheritsLoose = _inheritsLoose;
exports.initializerDefineProperty = _initializerDefineProperty;
exports.initializerWarningHelper = _initializerWarningHelper;
exports.instanceof = _instanceof;
exports.interopRequireDefault = _interopRequireDefault;
exports.interopRequireWildcard = _interopRequireWildcard;
exports.isNativeFunction = _isNativeFunction;
exports.isNativeReflectConstruct = _isNativeReflectConstruct;
exports.iterableToArray = _iterableToArray;
exports.iterableToArrayLimit = _iterableToArrayLimit;
exports.iterableToArrayLimitLoose = _iterableToArrayLimitLoose;
exports.jsx = _jsx;
exports.maybeArrayLike = _maybeArrayLike;
exports.newArrowCheck = _newArrowCheck;
exports.nonIterableRest = _nonIterableRest;
exports.nonIterableSpread = _nonIterableSpread;
exports.objectDestructuringEmpty = _objectDestructuringEmpty;
exports.objectSpread = _objectSpread;
exports.objectSpread2 = _objectSpread2;
exports.objectWithoutProperties = _objectWithoutProperties;
exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
exports.possibleConstructorReturn = _possibleConstructorReturn;
exports.readOnlyError = _readOnlyError;
exports.set = _set;
exports.setPrototypeOf = _setPrototypeOf;
exports.skipFirstGeneratorNext = _skipFirstGeneratorNext;
exports.slicedToArray = _slicedToArray;
exports.slicedToArrayLoose = _slicedToArrayLoose;
exports.superPropBase = _superPropBase;
exports.taggedTemplateLiteral = _taggedTemplateLiteral;
exports.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose;
exports.tdz = _tdz;
exports.temporalRef = _temporalRef;
exports.temporalUndefined = _temporalUndefined;
exports.toArray = _toArray;
exports.toConsumableArray = _toConsumableArray;
exports.toPrimitive = _toPrimitive;
exports.toPropertyKey = _toPropertyKey;
exports.typeof = _typeof;
exports.unsupportedIterableToArray = _unsupportedIterableToArray;
exports.wrapAsyncGenerator = _wrapAsyncGenerator;
exports.wrapNativeSuper = _wrapNativeSuper;
exports.wrapRegExp = _wrapRegExp;
exports.writeOnlyError = _writeOnlyError;
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var internal = require('@boost/internal');

@@ -13,4 +15,4 @@

};
var CommonError = internal.createScopedError('CMN', 'CommonError', errors);
module.exports = CommonError;
const CommonError = internal.createScopedError('CMN', 'CommonError', errors);
exports.CommonError = CommonError;
//# sourceMappingURL=CommonError.js.map

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -9,4 +7,3 @@

const MODULE_NAME_PART = /[a-z0-9]{1}[-a-z0-9_.]*/u; // eslint-disable-next-line security/detect-non-literal-regexp
const MODULE_NAME_PART = /[a-z0-9]{1}[-a-z0-9_.]*/u;
const MODULE_NAME_PATTERN = new RegExp(`^(?:@(${MODULE_NAME_PART.source})/)?(${MODULE_NAME_PART.source})$`, 'u');

@@ -13,0 +10,0 @@ exports.MODULE_NAME_PART = MODULE_NAME_PART;

@@ -1,9 +0,17 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Object.defineProperty(exports, '__esModule', {
value: true
});
var optimal = require('optimal');
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -13,3 +21,3 @@ };

var optimal__default = /*#__PURE__*/_interopDefaultLegacy(optimal);
var optimal__default = /*#__PURE__*/_interopDefault(optimal);

@@ -31,7 +39,5 @@ class Contract {

// so it's read only, but we still want to modify it with this function.
// @ts-expect-error
// @ts-expect-error Allow readonly overwrite
this.options = Object.freeze(optimal__default['default']({ ...this.options,
...nextOptions
}, this.blueprint(optimal.predicates, this.options === undefined), {
this.options = Object.freeze(optimal__default['default'](_objectSpread(_objectSpread({}, this.options), nextOptions), this.blueprint(optimal.predicates, this.options === undefined), {
name: this.constructor.name

@@ -49,3 +55,3 @@ }));

module.exports = Contract;
exports.Contract = Contract;
//# sourceMappingURL=Contract.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
class ExitError extends Error {

@@ -15,3 +17,3 @@ constructor(message, code) {

module.exports = ExitError;
exports.ExitError = ExitError;
//# sourceMappingURL=ExitError.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var optimal = require('optimal');

@@ -11,3 +13,3 @@

module.exports = createBlueprint;
exports.createBlueprint = createBlueprint;
//# sourceMappingURL=createBlueprint.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var isPlainObject = require('./isPlainObject.js');

@@ -15,3 +17,3 @@

// Only freeze plain objects
if (isPlainObject(value, true)) {
if (isPlainObject.isPlainObject(value, true)) {
nextObj[key] = deepFreeze(value);

@@ -25,3 +27,3 @@ } else {

module.exports = deepFreeze;
exports.deepFreeze = deepFreeze;
//# sourceMappingURL=deepFreeze.js.map

@@ -1,5 +0,13 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Object.defineProperty(exports, '__esModule', {
value: true
});
var isObject = require('./isObject.js');

@@ -12,5 +20,4 @@

if (isObject(prevValue) && isObject(value)) {
base[key] = merge({ ...prevValue
}, value);
if (isObject.isObject(prevValue) && isObject.isObject(value)) {
base[key] = merge(_objectSpread({}, prevValue), value);
} else if (Array.isArray(prevValue) && Array.isArray(value)) {

@@ -35,3 +42,3 @@ base[key] = merge([...prevValue], value);

module.exports = deepMerge;
exports.deepMerge = deepMerge;
//# sourceMappingURL=deepMerge.js.map

@@ -1,9 +0,17 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Object.defineProperty(exports, '__esModule', {
value: true
});
var prettyMs = require('pretty-ms');
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -13,3 +21,3 @@ };

var prettyMs__default = /*#__PURE__*/_interopDefaultLegacy(prettyMs);
var prettyMs__default = /*#__PURE__*/_interopDefault(prettyMs);

@@ -21,9 +29,8 @@ function formatMs(ms, options) {

return prettyMs__default['default'](ms, {
keepDecimalsOnWholeSeconds: true,
...options
});
return prettyMs__default['default'](ms, _objectSpread({
keepDecimalsOnWholeSeconds: true
}, options));
}
module.exports = formatMs;
exports.formatMs = formatMs;
//# sourceMappingURL=formatMs.js.map

@@ -1,4 +0,6 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
/**

@@ -42,3 +44,3 @@ * Native `instanceof` checks are problematic, as cross realm checks fail.

module.exports = instanceOf;
exports.instanceOf = instanceOf;
//# sourceMappingURL=instanceOf.js.map

@@ -1,12 +0,14 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var isObject = require('./isObject.js');
function isEmpty(value) {
return !value || Array.isArray(value) && value.length === 0 || isObject(value) && Object.keys(value).length === 0 || false;
return !value || Array.isArray(value) && value.length === 0 || isObject.isObject(value) && Object.keys(value).length === 0 || false;
}
module.exports = isEmpty;
exports.isEmpty = isEmpty;
//# sourceMappingURL=isEmpty.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var Path = require('../Path.js');

@@ -11,3 +13,3 @@

function isFilePath(path) {
const filePath = path instanceof Path ? path.path() : path;
const filePath = path instanceof Path.Path ? path.path() : path;

@@ -26,3 +28,3 @@ if (filePath === '') {

module.exports = isFilePath;
exports.isFilePath = isFilePath;
//# sourceMappingURL=isFilePath.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var module$1 = require('module');

@@ -19,3 +21,3 @@

module.exports = isModuleName;
exports.isModuleName = isModuleName;
//# sourceMappingURL=isModuleName.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
function isObject(value) {

@@ -9,3 +11,3 @@ return typeof value === 'object' && value !== null && !Array.isArray(value);

module.exports = isObject;
exports.isObject = isObject;
//# sourceMappingURL=isObject.js.map

@@ -1,9 +0,11 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var isObject = require('./isObject.js');
function isPlainObject(value, loose = false) {
if (!isObject(value)) {
if (!isObject.isObject(value)) {
return false;

@@ -22,3 +24,3 @@ }

module.exports = isPlainObject;
exports.isPlainObject = isPlainObject;
//# sourceMappingURL=isPlainObject.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var fs = require('fs');

@@ -19,4 +21,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -26,9 +28,9 @@ };

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var fs__default = /*#__PURE__*/_interopDefault(fs);
function parseFile(filePath) {
const path = Path.create(filePath);
const path = Path.Path.create(filePath);
if (!path.isAbsolute()) {
throw new CommonError('PATH_REQUIRE_ABSOLUTE');
throw new CommonError.CommonError('PATH_REQUIRE_ABSOLUTE');
}

@@ -39,7 +41,7 @@

case '.jsx':
return requireModule(path);
return requireModule.requireModule(path);
case '.ts':
case '.tsx':
return requireTypedModule(path);
return requireTypedModule.requireTypedModule(path);

@@ -55,7 +57,7 @@ case '.json':

default:
throw new CommonError('PARSE_INVALID_EXT', [path.name()]);
throw new CommonError.CommonError('PARSE_INVALID_EXT', [path.name()]);
}
}
module.exports = parseFile;
exports.parseFile = parseFile;
//# sourceMappingURL=parseFile.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var interopRequireModule = require('../internal/interopRequireModule.js');

@@ -13,9 +15,9 @@

if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
return requireTypedModule(filePath);
return requireTypedModule.requireTypedModule(filePath);
}
return interopRequireModule(filePath);
return interopRequireModule.interopRequireModule(filePath);
}
module.exports = requireModule;
exports.requireModule = requireModule;
//# sourceMappingURL=requireModule.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var fs = require('fs');

@@ -9,4 +11,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -16,3 +18,3 @@ };

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var fs__default = /*#__PURE__*/_interopDefault(fs);
/* eslint-disable no-underscore-dangle, node/no-deprecated-api */

@@ -24,3 +26,3 @@

try {
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ts = require('typescript');

@@ -82,3 +84,3 @@ } catch {// Ignore and check at runtime

registerExtensions();
const result = interopRequireModule(filePath);
const result = interopRequireModule.interopRequireModule(filePath);
unregisterExtensions();

@@ -88,3 +90,3 @@ return result;

module.exports = requireTypedModule;
exports.requireTypedModule = requireTypedModule;
//# sourceMappingURL=requireTypedModule.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
function toArray(value) {

@@ -13,3 +15,3 @@ if (typeof value === 'undefined') {

module.exports = toArray;
exports.toArray = toArray;
//# sourceMappingURL=toArray.js.map

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -13,2 +11,4 @@

var constants = require('./constants.js');
var Contract = require('./Contract.js');

@@ -18,2 +18,4 @@

require('./helpers/index.js');
var PackageGraph = require('./PackageGraph.js');

@@ -27,8 +29,10 @@

var json = require('./serializers/json.js');
var json$1 = require('./serializers/json.js');
var yaml = require('./serializers/yaml.js');
var yaml$1 = require('./serializers/yaml.js');
var constants = require('./constants.js');
var types = require('./types.js');
var decorators = require('@boost/decorators');
var createBlueprint = require('./helpers/createBlueprint.js');

@@ -62,8 +66,4 @@

var types = require('./types.js');
var decorators = require('@boost/decorators');
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -73,16 +73,9 @@ };

var optimal__default = /*#__PURE__*/_interopDefaultLegacy(optimal);
var optimal__default = /*#__PURE__*/_interopDefault(optimal);
/**
* @copyright 2020, Miles Johnson
* @license https://opensource.org/licenses/MIT
*/
Object.defineProperty(exports, 'Blueprint', {
enumerable: true,
get: function () {
return optimal.Blueprint;
}
});
Object.defineProperty(exports, 'Predicates', {
enumerable: true,
get: function () {
return optimal.Predicates;
}
});
Object.defineProperty(exports, 'optimal', {

@@ -100,27 +93,13 @@ enumerable: true,

});
exports.CommonError = CommonError;
exports.Contract = Contract;
exports.ExitError = ExitError;
exports.PackageGraph = PackageGraph;
exports.Path = Path;
exports.PathResolver = PathResolver;
exports.Project = Project;
exports.json = json;
exports.yaml = yaml;
exports.CommonError = CommonError.CommonError;
exports.MODULE_NAME_PART = constants.MODULE_NAME_PART;
exports.MODULE_NAME_PATTERN = constants.MODULE_NAME_PATTERN;
exports.createBlueprint = createBlueprint;
exports.deepFreeze = deepFreeze;
exports.deepMerge = deepMerge;
exports.formatMs = formatMs;
exports.instanceOf = instanceOf;
exports.isEmpty = isEmpty;
exports.isFilePath = isFilePath;
exports.isModuleName = isModuleName;
exports.isObject = isObject;
exports.isPlainObject = isPlainObject;
exports.parseFile = parseFile;
exports.requireModule = requireModule;
exports.requireTypedModule = requireTypedModule;
exports.toArray = toArray;
exports.Contract = Contract.Contract;
exports.ExitError = ExitError.ExitError;
exports.PackageGraph = PackageGraph.PackageGraph;
exports.Path = Path.Path;
exports.PathResolver = PathResolver.PathResolver;
exports.Project = Project.Project;
exports.json = json$1;
exports.yaml = yaml$1;
Object.defineProperty(exports, 'LookupType', {

@@ -132,2 +111,16 @@ enumerable: true,

});
exports.createBlueprint = createBlueprint.createBlueprint;
exports.deepFreeze = deepFreeze.deepFreeze;
exports.deepMerge = deepMerge.deepMerge;
exports.formatMs = formatMs.formatMs;
exports.instanceOf = instanceOf.instanceOf;
exports.isEmpty = isEmpty.isEmpty;
exports.isFilePath = isFilePath.isFilePath;
exports.isModuleName = isModuleName.isModuleName;
exports.isObject = isObject.isObject;
exports.isPlainObject = isPlainObject.isPlainObject;
exports.parseFile = parseFile.parseFile;
exports.requireModule = requireModule.requireModule;
exports.requireTypedModule = requireTypedModule.requireTypedModule;
exports.toArray = toArray.toArray;
Object.keys(decorators).forEach(function (k) {

@@ -134,0 +127,0 @@ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {

@@ -1,8 +0,9 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
/* eslint-disable no-underscore-dangle */
function interopRequireModule(path) {
// eslint-disable-next-line
const result = require(path); // Not a Babel/TypeScript transpiled module

@@ -27,3 +28,3 @@

module.exports = interopRequireModule;
exports.interopRequireModule = interopRequireModule;
//# sourceMappingURL=interopRequireModule.js.map

@@ -1,4 +0,12 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Object.defineProperty(exports, '__esModule', {
value: true
});
/* eslint-disable max-classes-per-file */

@@ -129,3 +137,3 @@

const addBatch = () => {
const nextBatch = Array.from(this.nodes.values()).filter(node => !seen.has(node) && (node.requirements.size === 0 || Array.from(node.requirements.values()).filter(dep => !seen.has(dep)).length === 0)); // Some nodes are missing, so they must be a cycle
const nextBatch = [...this.nodes.values()].filter(node => !seen.has(node) && (node.requirements.size === 0 || [...node.requirements.values()].filter(dep => !seen.has(dep)).length === 0)); // Some nodes are missing, so they must be a cycle

@@ -164,3 +172,3 @@ if (nextBatch.length === 0) {

if (cycle.has(node)) {
const path = [...Array.from(cycle), node].map(n => n.name).join(' -> ');
const path = [...[...cycle], node].map(n => n.name).join(' -> ');
throw new Error(`Circular dependency detected: ${path}`);

@@ -193,3 +201,3 @@ }

if (rootNodes.length === 0 && this.nodes.size !== 0) {
if (rootNodes.length === 0 && this.nodes.size > 0) {
this.detectCycle();

@@ -212,5 +220,3 @@ }

this.packages.forEach(pkg => {
Object.keys({ ...pkg.dependencies,
...pkg.peerDependencies
}).forEach(depName => {
Object.keys(_objectSpread(_objectSpread({}, pkg.dependencies), pkg.peerDependencies)).forEach(depName => {
this.mapDependency(pkg.name, depName);

@@ -258,3 +264,3 @@ });

sortByDependedOn(nodes) {
return Array.from(nodes).sort((a, b) => {
return [...nodes].sort((a, b) => {
const diff = b.dependents.size - a.dependents.size;

@@ -272,3 +278,3 @@

module.exports = PackageGraph;
exports.PackageGraph = PackageGraph;
//# sourceMappingURL=PackageGraph.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var fs = require('fs');

@@ -9,4 +11,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -16,5 +18,5 @@ };

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var fs__default = /*#__PURE__*/_interopDefault(fs);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var path__default = /*#__PURE__*/_interopDefault(path);

@@ -166,3 +168,3 @@ class Path {

resolve(cwd) {
return new Path(path__default['default'].resolve(String(cwd || process.cwd()), this.internalPath));
return new Path(path__default['default'].resolve(String(cwd !== null && cwd !== void 0 ? cwd : process.cwd()), this.internalPath));
}

@@ -182,3 +184,3 @@

Path.SEP = '/';
module.exports = Path;
exports.Path = Path;
//# sourceMappingURL=Path.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var CommonError = require('./CommonError.js');

@@ -12,4 +14,6 @@

class PathResolver {
constructor() {
constructor(resolver) {
this.lookups = [];
this.resolver = void 0;
this.resolver = resolver !== null && resolver !== void 0 ? resolver : require.resolve;
}

@@ -32,4 +36,4 @@ /**

this.lookups.push({
path: Path.resolve(filePath, cwd),
raw: Path.create(filePath),
path: Path.Path.resolve(filePath, cwd),
raw: Path.Path.create(filePath),
type: types.LookupType.FILE_SYSTEM

@@ -45,3 +49,3 @@ });

lookupNodeModule(modulePath) {
const path = Path.create(modulePath);
const path = Path.Path.create(modulePath);
this.lookups.push({

@@ -77,5 +81,5 @@ path,

try {
resolvedPath = require.resolve(lookup.path.path());
resolvedPath = this.resolver(lookup.path.path());
resolvedLookup = lookup;
} catch (error) {
} catch {
return false;

@@ -89,3 +93,3 @@ }

if (!resolvedPath || !resolvedLookup) {
throw new CommonError('PATH_RESOLVE_LOOKUPS', [this.lookups.map(lookup => ` - ${lookup.path} (${lookup.type})`).join('\n')]);
throw new CommonError.CommonError('PATH_RESOLVE_LOOKUPS', [this.lookups.map(lookup => ` - ${lookup.path} (${lookup.type})`).join('\n')]);
}

@@ -95,3 +99,3 @@

originalPath: resolvedLookup.raw,
resolvedPath: Path.create(resolvedPath),
resolvedPath: Path.Path.create(resolvedPath),
type: resolvedLookup.type

@@ -111,3 +115,3 @@ };

module.exports = PathResolver;
exports.PathResolver = PathResolver;
//# sourceMappingURL=PathResolver.js.map

@@ -1,5 +0,7 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');

@@ -17,4 +19,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -24,3 +26,3 @@ };

var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
var glob__default = /*#__PURE__*/_interopDefault(glob);

@@ -32,3 +34,3 @@ var _dec, _dec2, _dec3, _class;

this.root = void 0;
this.root = Path.create(root);
this.root = Path.Path.create(root);
}

@@ -42,3 +44,3 @@ /**

const metadata = {};
const filePath = Path.create(jsonPath);
const filePath = Path.Path.create(jsonPath);
const pkgPath = filePath.parent();

@@ -62,6 +64,6 @@ const wsPath = pkgPath.parent();

if (!pkgPath.exists()) {
throw new CommonError('PROJECT_NO_PACKAGE');
throw new CommonError.CommonError('PROJECT_NO_PACKAGE');
}
return parseFile(pkgPath);
return parseFile.parseFile(pkgPath);
}

@@ -82,3 +84,3 @@ /**

if (pkgPath.exists()) {
const pkg = parseFile(pkgPath);
const pkg = parseFile.parseFile(pkgPath);

@@ -96,3 +98,3 @@ if (pkg.workspaces) {

if (workspacePaths.length === 0 && lernaPath.exists()) {
const lerna = parseFile(lernaPath);
const lerna = parseFile.parseFile(lernaPath);

@@ -106,3 +108,3 @@ if (Array.isArray(lerna.packages)) {

if (workspacePaths.length === 0 && pnpmPath.exists()) {
const pnpm = parseFile(pnpmPath);
const pnpm = parseFile.parseFile(pnpmPath);

@@ -134,6 +136,6 @@ if (Array.isArray(pnpm.packages)) {

}).map(pkgPath => {
const filePath = new Path(pkgPath, 'package.json');
const filePath = new Path.Path(pkgPath, 'package.json');
return {
metadata: this.createWorkspaceMetadata(filePath),
package: parseFile(filePath)
package: parseFile.parseFile(filePath)
};

@@ -159,3 +161,3 @@ });

}, (_rollupPluginBabelHelpers.applyDecoratedDescriptor(_class.prototype, "getWorkspaceGlobs", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "getWorkspaceGlobs"), _class.prototype), _rollupPluginBabelHelpers.applyDecoratedDescriptor(_class.prototype, "getWorkspacePackages", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "getWorkspacePackages"), _class.prototype), _rollupPluginBabelHelpers.applyDecoratedDescriptor(_class.prototype, "getWorkspacePackagePaths", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "getWorkspacePackagePaths"), _class.prototype)), _class));
module.exports = Project;
exports.Project = Project;
//# sourceMappingURL=Project.js.map

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -11,4 +9,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -18,3 +16,3 @@ };

var JSON__default = /*#__PURE__*/_interopDefaultLegacy(JSON);
var JSON__default = /*#__PURE__*/_interopDefault(JSON);

@@ -21,0 +19,0 @@ function parse(content, reviver) {

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -11,4 +9,4 @@

function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : {
function _interopDefault(e) {
return e && e.__esModule ? e : {
'default': e

@@ -18,3 +16,3 @@ };

var YAML__default = /*#__PURE__*/_interopDefaultLegacy(YAML);
var YAML__default = /*#__PURE__*/_interopDefault(YAML);

@@ -21,0 +19,0 @@ function parse(content, options) {

@@ -1,3 +0,1 @@

// Generated with Packemon: https://packemon.dev
// Platform: node, Support: stable, Format: lib
'use strict';

@@ -4,0 +2,0 @@

{
"name": "@boost/common",
"version": "2.7.2",
"version": "2.8.0",
"release": "1594765247526",

@@ -34,5 +34,5 @@ "description": "A collection of common utilities, classes, and helpers.",

"dependencies": {
"@boost/decorators": "^2.1.2",
"@boost/internal": "^2.2.2",
"fast-glob": "^3.2.4",
"@boost/decorators": "^2.1.3",
"@boost/internal": "^2.2.3",
"fast-glob": "^3.2.7",
"json5": "^2.2.0",

@@ -44,7 +44,12 @@ "optimal": "^4.3.0",

"devDependencies": {
"@boost/test-utils": "^2.3.1"
"@boost/test-utils": "^2.3.2"
},
"optionalPeerDependencies": {
"peerDependencies": {
"typescript": "^4.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"funding": {

@@ -55,5 +60,7 @@ "type": "ko-fi",

"packemon": {
"format": "lib",
"support": "legacy",
"platform": "node"
},
"gitHead": "f9eb83de54fa41334f1a1e487216004a03caf662"
"gitHead": "34f5c1131c16dd22e9f95bcc19e19b9a5dee1fc7"
}
import { createScopedError } from '@boost/internal';
const errors = {
PARSE_INVALID_EXT: 'Unable to parse file "{0}". Unsupported file extension.',
PATH_REQUIRE_ABSOLUTE: 'An absolute file path is required.',
PATH_RESOLVE_LOOKUPS: 'Failed to resolve a path using the following lookups (in order):\n{0}\n',
PROJECT_NO_PACKAGE: 'No `package.json` found within project root.',
PARSE_INVALID_EXT: 'Unable to parse file "{0}". Unsupported file extension.',
PATH_REQUIRE_ABSOLUTE: 'An absolute file path is required.',
PATH_RESOLVE_LOOKUPS: 'Failed to resolve a path using the following lookups (in order):\n{0}\n',
PROJECT_NO_PACKAGE: 'No `package.json` found within project root.',
};

@@ -12,2 +12,2 @@

export default createScopedError<CommonErrorCode>('CMN', 'CommonError', errors);
export const CommonError = createScopedError<CommonErrorCode>('CMN', 'CommonError', errors);
// https://github.com/npm/validate-npm-package-name
export const MODULE_NAME_PART = /[a-z0-9]{1}[-a-z0-9_.]*/u;
// eslint-disable-next-line security/detect-non-literal-regexp
export const MODULE_NAME_PATTERN = new RegExp(
`^(?:@(${MODULE_NAME_PART.source})/)?(${MODULE_NAME_PART.source})$`,
'u',
`^(?:@(${MODULE_NAME_PART.source})/)?(${MODULE_NAME_PART.source})$`,
'u',
);
import optimal, { Blueprint, Predicates, predicates } from 'optimal';
import { Optionable } from './types';
export default abstract class Contract<T extends object = {}> implements Optionable<T> {
readonly options: Readonly<Required<T>>;
export abstract class Contract<T extends object = {}> implements Optionable<T> {
readonly options: Readonly<Required<T>>;
constructor(options?: T) {
this.options = this.configure(options);
}
constructor(options?: T) {
this.options = this.configure(options);
}
/**
* Set an options object by merging the new partial and existing options
* with the defined blueprint, while running all validation checks.
* Freeze and return the options object.
*/
configure(options?: Partial<T> | ((options: Required<T>) => Partial<T>)): Readonly<Required<T>> {
const nextOptions = typeof options === 'function' ? options(this.options) : options;
/**
* Set an options object by merging the new partial and existing options
* with the defined blueprint, while running all validation checks.
* Freeze and return the options object.
*/
configure(options?: Partial<T> | ((options: Required<T>) => Partial<T>)): Readonly<Required<T>> {
const nextOptions = typeof options === 'function' ? options(this.options) : options;
// We don't want the options property to be modified directly,
// so it's read only, but we still want to modify it with this function.
// @ts-expect-error
this.options = Object.freeze(
optimal(
{ ...this.options, ...nextOptions },
this.blueprint(predicates, this.options === undefined) as Blueprint<T>,
{
name: this.constructor.name,
},
),
);
// We don't want the options property to be modified directly,
// so it's read only, but we still want to modify it with this function.
// @ts-expect-error Allow readonly overwrite
this.options = Object.freeze(
optimal(
{ ...this.options, ...nextOptions },
this.blueprint(predicates, this.options === undefined) as Blueprint<T>,
{
name: this.constructor.name,
},
),
);
return this.options;
}
return this.options;
}
/**
* Define an optimal blueprint in which to validate and build the
* options object passed to the constructor, or when manual setting.
*/
abstract blueprint(predicates: Predicates, onConstruction?: boolean): Blueprint<object>;
/**
* Define an optimal blueprint in which to validate and build the
* options object passed to the constructor, or when manual setting.
*/
abstract blueprint(predicates: Predicates, onConstruction?: boolean): Blueprint<object>;
}

@@ -1,10 +0,10 @@

export default class ExitError extends Error {
code: number;
export class ExitError extends Error {
code: number;
constructor(message: string, code: number) {
super(message);
constructor(message: string, code: number) {
super(message);
this.code = code;
this.name = 'ExitError';
}
this.code = code;
this.name = 'ExitError';
}
}
import { Blueprint, predicates } from 'optimal';
import { BlueprintFactory } from '../types';
export default function createBlueprint<T extends object>(
factory: BlueprintFactory<T>,
): Blueprint<T> {
return factory(predicates);
export function createBlueprint<T extends object>(factory: BlueprintFactory<T>): Blueprint<T> {
return factory(predicates);
}

@@ -1,20 +0,20 @@

import isPlainObject from './isPlainObject';
import { isPlainObject } from './isPlainObject';
export default function deepFreeze<T extends object = object>(obj: T): T {
if (Object.isFrozen(obj)) {
return obj;
}
export function deepFreeze<T extends object = object>(obj: T): T {
if (Object.isFrozen(obj)) {
return obj;
}
const nextObj: Record<string, unknown> = {};
const nextObj: Record<string, unknown> = {};
Object.entries(obj).forEach(([key, value]) => {
// Only freeze plain objects
if (isPlainObject(value, true)) {
nextObj[key] = deepFreeze(value);
} else {
nextObj[key] = value;
}
});
Object.entries(obj).forEach(([key, value]) => {
// Only freeze plain objects
if (isPlainObject(value, true)) {
nextObj[key] = deepFreeze(value);
} else {
nextObj[key] = value;
}
});
return Object.freeze(nextObj) as T;
return Object.freeze(nextObj) as T;
}

@@ -1,2 +0,2 @@

import isObject from './isObject';
import { isObject } from './isObject';

@@ -7,38 +7,35 @@ export type MergableArray = unknown[];

export type InferMergeable<T> = T extends unknown[]
? MergableArray
: T extends object
? MergableObject
: never;
? MergableArray
: T extends object
? MergableObject
: never;
function merge<T extends Mergeable>(prev: T, next: unknown): T {
const base = prev as MergableObject;
const base = prev as MergableObject;
Object.entries(next as Mergeable).forEach(([key, value]) => {
const prevValue = base[key];
Object.entries(next as Mergeable).forEach(([key, value]) => {
const prevValue = base[key];
if (isObject(prevValue) && isObject(value)) {
base[key] = merge({ ...prevValue }, value);
} else if (Array.isArray(prevValue) && Array.isArray(value)) {
base[key] = merge([...(prevValue as MergableArray)], value);
} else {
base[key] = value;
}
});
if (isObject(prevValue) && isObject(value)) {
base[key] = merge({ ...prevValue }, value);
} else if (Array.isArray(prevValue) && Array.isArray(value)) {
base[key] = merge([...(prevValue as MergableArray)], value);
} else {
base[key] = value;
}
});
return base as T;
return base as T;
}
export default function deepMerge<T extends Mergeable, V extends InferMergeable<T>>(
base: T,
other?: V,
): T {
const next = Array.isArray(base)
? merge<MergableArray>([], base)
: merge<MergableObject>({}, base);
export function deepMerge<T extends Mergeable, V extends InferMergeable<T>>(base: T, other?: V): T {
const next = Array.isArray(base)
? merge<MergableArray>([], base)
: merge<MergableObject>({}, base);
if (other) {
merge(next, other);
}
if (other) {
merge(next, other);
}
return next as T;
return next as T;
}
import prettyMs, { Options } from 'pretty-ms';
export default function formatMs(ms: number, options?: Options): string {
if (!Number.isFinite(ms) || ms === 0) {
return '0s';
}
export function formatMs(ms: number, options?: Options): string {
if (!Number.isFinite(ms) || ms === 0) {
return '0s';
}
return prettyMs(ms, { keepDecimalsOnWholeSeconds: true, ...options });
return prettyMs(ms, { keepDecimalsOnWholeSeconds: true, ...options });
}

@@ -1,14 +0,14 @@

export { default as createBlueprint } from './createBlueprint';
export { default as deepFreeze } from './deepFreeze';
export { default as deepMerge } from './deepMerge';
export { default as formatMs } from './formatMs';
export { default as instanceOf } from './instanceOf';
export { default as isEmpty } from './isEmpty';
export { default as isFilePath } from './isFilePath';
export { default as isModuleName } from './isModuleName';
export { default as isObject } from './isObject';
export { default as isPlainObject } from './isPlainObject';
export { default as parseFile } from './parseFile';
export { default as requireModule } from './requireModule';
export { default as requireTypedModule } from './requireTypedModule';
export { default as toArray } from './toArray';
export * from './createBlueprint';
export * from './deepFreeze';
export * from './deepMerge';
export * from './formatMs';
export * from './instanceOf';
export * from './isEmpty';
export * from './isFilePath';
export * from './isModuleName';
export * from './isObject';
export * from './isPlainObject';
export * from './parseFile';
export * from './requireModule';
export * from './requireTypedModule';
export * from './toArray';

@@ -8,39 +8,39 @@ import { Constructor } from '../types';

*/
export default function instanceOf<T = unknown>(
object: unknown,
declaration: Constructor<T>,
loose: boolean = true,
export function instanceOf<T = unknown>(
object: unknown,
declaration: Constructor<T>,
loose: boolean = true,
): object is T {
if (!object || typeof object !== 'object') {
return false;
}
if (!object || typeof object !== 'object') {
return false;
}
if (object instanceof declaration) {
return true;
}
if (object instanceof declaration) {
return true;
}
if (!loose) {
return false;
}
if (!loose) {
return false;
}
let current = object;
let current = object;
while (current) {
if (current.constructor.name === 'Object') {
break;
}
while (current) {
if (current.constructor.name === 'Object') {
break;
}
if (
current.constructor.name === declaration.name ||
// istanbul ignore next
(current instanceof Error && current.name === declaration.name)
) {
return true;
}
if (
current.constructor.name === declaration.name ||
// istanbul ignore next
(current instanceof Error && current.name === declaration.name)
) {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
current = Object.getPrototypeOf(current);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
current = Object.getPrototypeOf(current);
}
return false;
return false;
}

@@ -1,10 +0,10 @@

import isObject from './isObject';
import { isObject } from './isObject';
export default function isEmpty(value: unknown): boolean {
return (
!value ||
(Array.isArray(value) && value.length === 0) ||
(isObject<object>(value) && Object.keys(value).length === 0) ||
false
);
export function isEmpty(value: unknown): boolean {
return (
!value ||
(Array.isArray(value) && value.length === 0) ||
(isObject<object>(value) && Object.keys(value).length === 0) ||
false
);
}

@@ -1,2 +0,2 @@

import Path from '../Path';
import { Path } from '../Path';
import { PortablePath } from '../types';

@@ -7,15 +7,15 @@

export default function isFilePath(path: PortablePath): boolean {
const filePath = path instanceof Path ? path.path() : path;
export function isFilePath(path: PortablePath): boolean {
const filePath = path instanceof Path ? path.path() : path;
if (filePath === '') {
return false;
}
if (filePath === '') {
return false;
}
// istanbul ignore next
if (process.platform === 'win32') {
return WIN_START.test(filePath) || filePath.includes('/') || filePath.includes('\\');
}
// istanbul ignore next
if (process.platform === 'win32') {
return WIN_START.test(filePath) || filePath.includes('/') || filePath.includes('\\');
}
return NIX_START.test(filePath) || filePath.includes('/');
return NIX_START.test(filePath) || filePath.includes('/');
}

@@ -7,8 +7,8 @@ import { builtinModules } from 'module';

export default function isModuleName(name: ModuleName): boolean {
if (RESERVED.has(name)) {
return false;
}
export function isModuleName(name: ModuleName): boolean {
if (RESERVED.has(name)) {
return false;
}
return MODULE_NAME_PATTERN.test(name);
return MODULE_NAME_PATTERN.test(name);
}

@@ -1,3 +0,3 @@

export default function isObject<T = object>(value: unknown): value is T {
return typeof value === 'object' && value !== null && !Array.isArray(value);
export function isObject<T = object>(value: unknown): value is T {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}

@@ -1,24 +0,21 @@

import isObject from './isObject';
import { isObject } from './isObject';
export default function isPlainObject<T = object>(
value: unknown,
loose: boolean = false,
): value is T {
if (!isObject(value)) {
return false;
}
export function isPlainObject<T = object>(value: unknown, loose: boolean = false): value is T {
if (!isObject(value)) {
return false;
}
const proto = Object.getPrototypeOf(value) as unknown;
const proto = Object.getPrototypeOf(value) as unknown;
if (
value.constructor === Object ||
proto === Object.prototype ||
proto === null ||
// This is to support cross-realm checks
(loose && value.constructor.name === 'Object')
) {
return true;
}
if (
value.constructor === Object ||
proto === Object.prototype ||
proto === null ||
// This is to support cross-realm checks
(loose && value.constructor.name === 'Object')
) {
return true;
}
return false;
return false;
}
import fs from 'fs';
import CommonError from '../CommonError';
import Path from '../Path';
import { CommonError } from '../CommonError';
import { Path } from '../Path';
import { parse as parseJSON } from '../serializers/json';
import { parse as parseYAML } from '../serializers/yaml';
import { PortablePath } from '../types';
import requireModule from './requireModule';
import requireTypedModule from './requireTypedModule';
import { requireModule } from './requireModule';
import { requireTypedModule } from './requireTypedModule';
export default function parseFile<T>(filePath: PortablePath): T {
const path = Path.create(filePath);
export function parseFile<T>(filePath: PortablePath): T {
const path = Path.create(filePath);
if (!path.isAbsolute()) {
throw new CommonError('PATH_REQUIRE_ABSOLUTE');
}
if (!path.isAbsolute()) {
throw new CommonError('PATH_REQUIRE_ABSOLUTE');
}
switch (path.ext()) {
case '.js':
case '.jsx':
return requireModule(path);
switch (path.ext()) {
case '.js':
case '.jsx':
return requireModule(path);
case '.ts':
case '.tsx':
return requireTypedModule(path);
case '.ts':
case '.tsx':
return requireTypedModule(path);
case '.json':
case '.json5':
return parseJSON(fs.readFileSync(path.path(), 'utf8'));
case '.json':
case '.json5':
return parseJSON(fs.readFileSync(path.path(), 'utf8'));
case '.yml':
case '.yaml':
return parseYAML(fs.readFileSync(path.path(), 'utf8'));
case '.yml':
case '.yaml':
return parseYAML(fs.readFileSync(path.path(), 'utf8'));
default:
throw new CommonError('PARSE_INVALID_EXT', [path.name()]);
}
default:
throw new CommonError('PARSE_INVALID_EXT', [path.name()]);
}
}

@@ -1,13 +0,13 @@

import interopRequireModule from '../internal/interopRequireModule';
import { interopRequireModule } from '../internal/interopRequireModule';
import { PortablePath } from '../types';
import requireTypedModule from './requireTypedModule';
import { requireTypedModule } from './requireTypedModule';
export default function requireModule<T>(path: PortablePath): T {
const filePath = String(path);
export function requireModule<T>(path: PortablePath): T {
const filePath = String(path);
if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
return requireTypedModule(filePath);
}
if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
return requireTypedModule(filePath);
}
return interopRequireModule(filePath) as T;
return interopRequireModule(filePath) as T;
}

@@ -5,12 +5,11 @@ /* eslint-disable no-underscore-dangle, node/no-deprecated-api */

import type Module from 'module';
import interopRequireModule from '../internal/interopRequireModule';
import { interopRequireModule } from '../internal/interopRequireModule';
import { PortablePath } from '../types';
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface Module {
_compile: (code: string, file: string) => unknown;
}
}
namespace NodeJS {
interface Module {
_compile: (code: string, file: string) => unknown;
}
}
}

@@ -21,6 +20,6 @@

try {
// eslint-disable-next-line
ts = require('typescript');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ts = require('typescript');
} catch {
// Ignore and check at runtime
// Ignore and check at runtime
}

@@ -31,29 +30,29 @@

function transform(contents: string, fileName: string): string {
if (!ts) {
throw new Error(`\`typescript\` package required for importing file "${fileName}".`);
}
if (!ts) {
throw new Error(`\`typescript\` package required for importing file "${fileName}".`);
}
return ts.transpileModule(contents, {
compilerOptions: {
allowJs: true,
allowSyntheticDefaultImports: true,
esModuleInterop: true,
module: ts.ModuleKind.CommonJS,
noEmit: true,
resolveJsonModule: true,
target: ts.ScriptTarget.ES2016,
},
fileName,
}).outputText;
return ts.transpileModule(contents, {
compilerOptions: {
allowJs: true,
allowSyntheticDefaultImports: true,
esModuleInterop: true,
module: ts.ModuleKind.CommonJS,
noEmit: true,
resolveJsonModule: true,
target: ts.ScriptTarget.ES2016,
},
fileName,
}).outputText;
}
function transformHandler(mod: Module, filePath: string) {
let code = transformCache.get(filePath);
let code = transformCache.get(filePath);
if (!code) {
code = transform(fs.readFileSync(filePath, 'utf8'), filePath);
transformCache.set(filePath, code);
}
if (!code) {
code = transform(fs.readFileSync(filePath, 'utf8'), filePath);
transformCache.set(filePath, code);
}
mod._compile(code, filePath);
mod._compile(code, filePath);
}

@@ -64,27 +63,27 @@

function registerExtensions() {
require.extensions['.ts'] = transformHandler;
require.extensions['.tsx'] = transformHandler;
require.extensions['.ts'] = transformHandler;
require.extensions['.tsx'] = transformHandler;
}
function unregisterExtensions() {
delete require.extensions['.ts'];
delete require.extensions['.tsx'];
delete require.extensions['.ts'];
delete require.extensions['.tsx'];
}
export default function requireTypedModule<T>(path: PortablePath): T {
const filePath = String(path);
export function requireTypedModule<T>(path: PortablePath): T {
const filePath = String(path);
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx')) {
throw new Error(
`Unable to import non-TypeScript file "${filePath}", use \`requireModule\` instead.`,
);
}
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx')) {
throw new Error(
`Unable to import non-TypeScript file "${filePath}", use \`requireModule\` instead.`,
);
}
registerExtensions();
registerExtensions();
const result = interopRequireModule(filePath);
const result = interopRequireModule(filePath);
unregisterExtensions();
unregisterExtensions();
return result as T;
return result as T;
}

@@ -1,7 +0,7 @@

export default function toArray<T = unknown>(value?: T | T[]): T[] {
if (typeof value === 'undefined') {
return [];
}
export function toArray<T = unknown>(value?: T | T[]): T[] {
if (typeof value === 'undefined') {
return [];
}
return Array.isArray(value) ? value : [value];
return Array.isArray(value) ? value : [value];
}

@@ -7,34 +7,18 @@ /**

import optimal, { Blueprint, Predicates, predicates } from 'optimal';
import type { CommonErrorCode } from './CommonError';
import CommonError from './CommonError';
import Contract from './Contract';
import ExitError from './ExitError';
import PackageGraph from './PackageGraph';
import Path from './Path';
import PathResolver from './PathResolver';
import Project from './Project';
import * as json from './serializers/json';
import * as yaml from './serializers/yaml';
export * from './CommonError';
export * from './constants';
export * from './Contract';
export * from './ExitError';
export * from './helpers';
export * from './PackageGraph';
export * from './Path';
export * from './PathResolver';
export * from './Project';
export * as json from './serializers/json';
export * as yaml from './serializers/yaml';
export * from './types';
export * from '@boost/decorators';
export {
Blueprint,
CommonError,
Contract,
ExitError,
json,
optimal,
PackageGraph,
Path,
PathResolver,
Predicates,
predicates,
Project,
yaml,
};
export type { CommonErrorCode };
export { optimal, predicates };
export type { Blueprint, Predicates };
/* eslint-disable no-underscore-dangle */
export default function interopRequireModule(path: string): unknown {
// eslint-disable-next-line
const result = require(path) as {
[named: string]: unknown;
default?: unknown;
__esModule?: boolean;
};
export function interopRequireModule(path: string): unknown {
const result = require(path) as {
[named: string]: unknown;
default?: unknown;
__esModule?: boolean;
};
// Not a Babel/TypeScript transpiled module
if (!result.__esModule) {
return result;
}
// Not a Babel/TypeScript transpiled module
if (!result.__esModule) {
return result;
}
const hasDefaultExport = 'default' in result;
const namedExports = Object.keys(result).filter(
(key) => key !== '__esModule' && key !== 'default',
);
const hasDefaultExport = 'default' in result;
const namedExports = Object.keys(result).filter(
(key) => key !== '__esModule' && key !== 'default',
);
// Default export only
if (hasDefaultExport && namedExports.length === 0) {
return result.default;
}
// Default export only
if (hasDefaultExport && namedExports.length === 0) {
return result.default;
}
// Default AND named exports
// Named exports only
return result;
// Default AND named exports
// Named exports only
return result;
}

@@ -6,273 +6,273 @@ /* eslint-disable max-classes-per-file */

class Node {
name: string;
name: string;
dependents: Set<Node> = new Set();
dependents: Set<Node> = new Set();
requirements: Set<Node> = new Set();
requirements: Set<Node> = new Set();
constructor(name: string) {
this.name = name;
}
constructor(name: string) {
this.name = name;
}
}
export default class PackageGraph<T extends PackageStructure = PackageStructure> {
protected mapped: boolean = false;
export class PackageGraph<T extends PackageStructure = PackageStructure> {
protected mapped: boolean = false;
protected nodes = new Map<string, Node>();
protected nodes = new Map<string, Node>();
protected packages = new Map<string, T>();
protected packages = new Map<string, T>();
constructor(packages: T[] = []) {
this.addPackages(packages);
}
constructor(packages: T[] = []) {
this.addPackages(packages);
}
/**
* Add a package by name with an associated `package.json` object.
* Will map a dependency between the package and its dependees
* found in `dependencies` and `peerDependencies`.
*/
addPackage(pkg: T): this {
if (this.mapped) {
this.resetNodes();
}
/**
* Add a package by name with an associated `package.json` object.
* Will map a dependency between the package and its dependees
* found in `dependencies` and `peerDependencies`.
*/
addPackage(pkg: T): this {
if (this.mapped) {
this.resetNodes();
}
// Cache package data for later use
this.packages.set(pkg.name, pkg);
// Cache package data for later use
this.packages.set(pkg.name, pkg);
// Add node to the graph
this.addNode(pkg.name);
// Add node to the graph
this.addNode(pkg.name);
return this;
}
return this;
}
/**
* Add multiple packages.
*/
addPackages(packages: T[] = []): this {
packages.forEach((pkg) => {
this.addPackage(pkg);
});
/**
* Add multiple packages.
*/
addPackages(packages: T[] = []): this {
packages.forEach((pkg) => {
this.addPackage(pkg);
});
return this;
}
return this;
}
/**
* Resolve the dependency graph and return a list of all
* `package.json` objects in the order they are depended on.
*/
resolveList(): T[] {
return this.resolveBatchList().reduce((flatList, batchList) => {
flatList.push(...batchList);
/**
* Resolve the dependency graph and return a list of all
* `package.json` objects in the order they are depended on.
*/
resolveList(): T[] {
return this.resolveBatchList().reduce((flatList, batchList) => {
flatList.push(...batchList);
return flatList;
}, []);
}
return flatList;
}, []);
}
/**
* Resolve the dependency graph and return a tree of nodes for all
* `package.json` objects and their dependency mappings.
*/
resolveTree(): PackageGraphTree<T> {
this.mapDependencies();
/**
* Resolve the dependency graph and return a tree of nodes for all
* `package.json` objects and their dependency mappings.
*/
resolveTree(): PackageGraphTree<T> {
this.mapDependencies();
const seen: Set<string> = new Set();
const resolve = (node: Node, tree: PackageGraphTree<T> | PackageGraphTreeNode<T>) => {
if (seen.has(node.name)) {
return;
}
const seen: Set<string> = new Set();
const resolve = (node: Node, tree: PackageGraphTree<T> | PackageGraphTreeNode<T>) => {
if (seen.has(node.name)) {
return;
}
// Only include nodes that have package data
const pkg = this.packages.get(node.name);
// Only include nodes that have package data
const pkg = this.packages.get(node.name);
if (!pkg) {
return;
}
if (!pkg) {
return;
}
const branch: PackageGraphTreeNode<T> = {
package: pkg,
};
const branch: PackageGraphTreeNode<T> = {
package: pkg,
};
this.sortByDependedOn(node.dependents).forEach((child) => {
resolve(child, branch);
});
this.sortByDependedOn(node.dependents).forEach((child) => {
resolve(child, branch);
});
if (tree.nodes) {
tree.nodes.push(branch);
} else {
// eslint-disable-next-line no-param-reassign
tree.nodes = [branch];
}
if (tree.nodes) {
tree.nodes.push(branch);
} else {
// eslint-disable-next-line no-param-reassign
tree.nodes = [branch];
}
seen.add(node.name);
};
seen.add(node.name);
};
const trunk: PackageGraphTree<T> = {
nodes: [],
root: true,
};
const trunk: PackageGraphTree<T> = {
nodes: [],
root: true,
};
this.sortByDependedOn(this.getRootNodes()).forEach((node) => {
resolve(node, trunk);
});
this.sortByDependedOn(this.getRootNodes()).forEach((node) => {
resolve(node, trunk);
});
// Some nodes are missing, so they must be a cycle
if (seen.size !== this.nodes.size) {
this.detectCycle();
}
// Some nodes are missing, so they must be a cycle
if (seen.size !== this.nodes.size) {
this.detectCycle();
}
return trunk;
}
return trunk;
}
/**
* Resolve the dependency graph and return a list of batched
* `package.json` objects in the order they are depended on.
*/
resolveBatchList(): T[][] {
this.mapDependencies();
/**
* Resolve the dependency graph and return a list of batched
* `package.json` objects in the order they are depended on.
*/
resolveBatchList(): T[][] {
this.mapDependencies();
const batches: T[][] = [];
const seen: Set<Node> = new Set();
const addBatch = () => {
const nextBatch = Array.from(this.nodes.values()).filter(
(node) =>
!seen.has(node) &&
(node.requirements.size === 0 ||
Array.from(node.requirements.values()).filter((dep) => !seen.has(dep)).length === 0),
);
const batches: T[][] = [];
const seen: Set<Node> = new Set();
const addBatch = () => {
const nextBatch = [...this.nodes.values()].filter(
(node) =>
!seen.has(node) &&
(node.requirements.size === 0 ||
[...node.requirements.values()].filter((dep) => !seen.has(dep)).length === 0),
);
// Some nodes are missing, so they must be a cycle
if (nextBatch.length === 0) {
this.detectCycle();
}
// Some nodes are missing, so they must be a cycle
if (nextBatch.length === 0) {
this.detectCycle();
}
batches.push(this.sortByDependedOn(nextBatch).map((node) => this.packages.get(node.name)!));
batches.push(this.sortByDependedOn(nextBatch).map((node) => this.packages.get(node.name)!));
nextBatch.forEach((node) => seen.add(node));
nextBatch.forEach((node) => seen.add(node));
if (seen.size !== this.nodes.size) {
addBatch();
}
};
if (seen.size !== this.nodes.size) {
addBatch();
}
};
addBatch();
addBatch();
return batches;
}
return batches;
}
/**
* Add a node for the defined package name.
*/
protected addNode(name: string) {
// Cache node for constant lookups
this.nodes.set(name, new Node(name));
}
/**
* Add a node for the defined package name.
*/
protected addNode(name: string) {
// Cache node for constant lookups
this.nodes.set(name, new Node(name));
}
/**
* Dig through all nodes and attempt to find a circular dependency cycle.
*/
protected detectCycle() {
const dig = (node: Node, cycle: Set<Node>) => {
if (cycle.has(node)) {
const path = [...Array.from(cycle), node].map((n) => n.name).join(' -> ');
/**
* Dig through all nodes and attempt to find a circular dependency cycle.
*/
protected detectCycle() {
const dig = (node: Node, cycle: Set<Node>) => {
if (cycle.has(node)) {
const path = [...[...cycle], node].map((n) => n.name).join(' -> ');
throw new Error(`Circular dependency detected: ${path}`);
}
throw new Error(`Circular dependency detected: ${path}`);
}
cycle.add(node);
cycle.add(node);
node.dependents.forEach((child) => {
dig(child, new Set(cycle));
});
};
node.dependents.forEach((child) => {
dig(child, new Set(cycle));
});
};
this.nodes.forEach((node) => {
dig(node, new Set());
});
}
this.nodes.forEach((node) => {
dig(node, new Set());
});
}
/**
* Return all nodes that can be considered "root",
* as determined by having no requirements.
*/
protected getRootNodes(): Node[] {
const rootNodes: Node[] = [];
/**
* Return all nodes that can be considered "root",
* as determined by having no requirements.
*/
protected getRootNodes(): Node[] {
const rootNodes: Node[] = [];
this.nodes.forEach((node) => {
if (node.requirements.size === 0) {
rootNodes.push(node);
}
});
this.nodes.forEach((node) => {
if (node.requirements.size === 0) {
rootNodes.push(node);
}
});
// If no root nodes are found, but nodes exist, then we have a cycle
if (rootNodes.length === 0 && this.nodes.size !== 0) {
this.detectCycle();
}
// If no root nodes are found, but nodes exist, then we have a cycle
if (rootNodes.length === 0 && this.nodes.size > 0) {
this.detectCycle();
}
return rootNodes;
}
return rootNodes;
}
/**
* Map dependencies between all currently registered packages.
*/
protected mapDependencies() {
if (this.mapped) {
return;
}
/**
* Map dependencies between all currently registered packages.
*/
protected mapDependencies() {
if (this.mapped) {
return;
}
this.mapped = true;
this.packages.forEach((pkg) => {
Object.keys({
...pkg.dependencies,
...pkg.peerDependencies,
}).forEach((depName) => {
this.mapDependency(pkg.name, depName);
});
});
}
this.mapped = true;
this.packages.forEach((pkg) => {
Object.keys({
...pkg.dependencies,
...pkg.peerDependencies,
}).forEach((depName) => {
this.mapDependency(pkg.name, depName);
});
});
}
/**
* Map a dependency link for a dependent (child) depending on a requirement (parent).
* Will link the parent and child accordingly, and will remove the child
* from the root if it exists.
*/
protected mapDependency(dependentName: string, requirementName: string) {
const requirement = this.nodes.get(requirementName);
const dependent = this.nodes.get(dependentName);
/**
* Map a dependency link for a dependent (child) depending on a requirement (parent).
* Will link the parent and child accordingly, and will remove the child
* from the root if it exists.
*/
protected mapDependency(dependentName: string, requirementName: string) {
const requirement = this.nodes.get(requirementName);
const dependent = this.nodes.get(dependentName);
if (!requirement || !dependent) {
return;
}
if (!requirement || !dependent) {
return;
}
// Child depends on parent
dependent.requirements.add(requirement);
// Child depends on parent
dependent.requirements.add(requirement);
// Parent is a dependee of child
requirement.dependents.add(dependent);
}
// Parent is a dependee of child
requirement.dependents.add(dependent);
}
/**
* Remove all current nodes in the graph and add new root nodes for each package.
*/
protected resetNodes() {
this.mapped = false;
this.nodes.clear();
this.packages.forEach((pkg) => {
this.addNode(pkg.name);
});
}
/**
* Remove all current nodes in the graph and add new root nodes for each package.
*/
protected resetNodes() {
this.mapped = false;
this.nodes.clear();
this.packages.forEach((pkg) => {
this.addNode(pkg.name);
});
}
/**
* Sort a set of nodes by most depended on, fall back to alpha sort as tie breaker
*/
protected sortByDependedOn(nodes: Node[] | Set<Node>): Node[] {
return Array.from(nodes).sort((a, b) => {
const diff = b.dependents.size - a.dependents.size;
/**
* Sort a set of nodes by most depended on, fall back to alpha sort as tie breaker
*/
protected sortByDependedOn(nodes: Node[] | Set<Node>): Node[] {
return [...nodes].sort((a, b) => {
const diff = b.dependents.size - a.dependents.size;
if (diff === 0) {
return a.name > b.name ? 1 : -1;
}
if (diff === 0) {
return a.name > b.name ? 1 : -1;
}
return diff;
});
}
return diff;
});
}
}

@@ -5,147 +5,147 @@ import fs from 'fs';

export default class Path {
static DELIMITER = path.delimiter;
export class Path {
static DELIMITER = path.delimiter;
static SEP = '/';
static SEP = '/';
private internalPath: string = '';
private internalPath: string = '';
constructor(...parts: PortablePath[]) {
// Always use forward slashes for better interop
this.internalPath = path.normalize(path.join(...parts.map(String))).replace(/\\/gu, Path.SEP);
}
constructor(...parts: PortablePath[]) {
// Always use forward slashes for better interop
this.internalPath = path.normalize(path.join(...parts.map(String))).replace(/\\/gu, Path.SEP);
}
/**
* Create and return a new `Path` instance if a string.
* If already a `Path`, return as is.
*/
static create(filePath: PortablePath): Path {
return filePath instanceof Path ? filePath : new Path(filePath);
}
/**
* Create and return a new `Path` instance if a string.
* If already a `Path`, return as is.
*/
static create(filePath: PortablePath): Path {
return filePath instanceof Path ? filePath : new Path(filePath);
}
/**
* Like `create()` but also resolves the path against CWD.
*/
static resolve(filePath: PortablePath, cwd?: PortablePath): Path {
return Path.create(filePath).resolve(cwd);
}
/**
* Like `create()` but also resolves the path against CWD.
*/
static resolve(filePath: PortablePath, cwd?: PortablePath): Path {
return Path.create(filePath).resolve(cwd);
}
/**
* Append path parts to the end of the current path
* and return a new `Path` instance.
*/
append(...parts: PortablePath[]): Path {
return new Path(this.internalPath, ...parts);
}
/**
* Append path parts to the end of the current path
* and return a new `Path` instance.
*/
append(...parts: PortablePath[]): Path {
return new Path(this.internalPath, ...parts);
}
/**
* Returns true if both paths are equal using strict equality.
*/
equals(filePath: PortablePath): boolean {
return this.path() === Path.create(filePath).path();
}
/**
* Returns true if both paths are equal using strict equality.
*/
equals(filePath: PortablePath): boolean {
return this.path() === Path.create(filePath).path();
}
/**
* Return the extension (if applicable) with or without leading period.
*/
ext(withoutPeriod: boolean = false): string {
const ext = path.extname(this.internalPath);
/**
* Return the extension (if applicable) with or without leading period.
*/
ext(withoutPeriod: boolean = false): string {
const ext = path.extname(this.internalPath);
return withoutPeriod && ext.startsWith('.') ? ext.slice(1) : ext;
}
return withoutPeriod && ext.startsWith('.') ? ext.slice(1) : ext;
}
/**
* Return true if the current path exists.
*/
exists(): boolean {
return fs.existsSync(this.internalPath);
}
/**
* Return true if the current path exists.
*/
exists(): boolean {
return fs.existsSync(this.internalPath);
}
/**
* Return true if the current path is absolute.
*/
isAbsolute(): boolean {
return path.isAbsolute(this.internalPath);
}
/**
* Return true if the current path is absolute.
*/
isAbsolute(): boolean {
return path.isAbsolute(this.internalPath);
}
/**
* Return true if the current path is a folder.
*/
isDirectory(): boolean {
return fs.statSync(this.internalPath).isDirectory();
}
/**
* Return true if the current path is a folder.
*/
isDirectory(): boolean {
return fs.statSync(this.internalPath).isDirectory();
}
/**
* Return true if the current path is a file.
*/
isFile(): boolean {
return fs.statSync(this.internalPath).isFile();
}
/**
* Return true if the current path is a file.
*/
isFile(): boolean {
return fs.statSync(this.internalPath).isFile();
}
/**
* Return the file name (with optional extension) or folder name.
*/
name(withoutExtension: boolean = false): string {
let name = path.basename(this.internalPath);
/**
* Return the file name (with optional extension) or folder name.
*/
name(withoutExtension: boolean = false): string {
let name = path.basename(this.internalPath);
if (withoutExtension) {
name = name.replace(this.ext(), '');
}
if (withoutExtension) {
name = name.replace(this.ext(), '');
}
return name;
}
return name;
}
/**
* Return the parent folder as a new `Path` instance.
*/
parent(): Path {
return new Path(path.dirname(this.internalPath));
}
/**
* Return the parent folder as a new `Path` instance.
*/
parent(): Path {
return new Path(path.dirname(this.internalPath));
}
/**
* Return the current path as a normalized string.
*/
path(): FilePath {
return this.internalPath;
}
/**
* Return the current path as a normalized string.
*/
path(): FilePath {
return this.internalPath;
}
/**
* Prepend path parts to the beginning of the current path
* and return a new `Path` instance.
*/
prepend(...parts: PortablePath[]): Path {
return new Path(...parts, this.internalPath);
}
/**
* Prepend path parts to the beginning of the current path
* and return a new `Path` instance.
*/
prepend(...parts: PortablePath[]): Path {
return new Path(...parts, this.internalPath);
}
/**
* Returns a canonical path by resolving directories and symlinks.
*/
// istanbul ignore next
realPath(): FilePath {
return fs.realpathSync.native(this.path());
}
/**
* Returns a canonical path by resolving directories and symlinks.
*/
// istanbul ignore next
realPath(): FilePath {
return fs.realpathSync.native(this.path());
}
/**
* Return a new relative `Path` instance from the current
* "from" path to the defined "to" path.
*/
relativeTo(to: PortablePath): Path {
return new Path(path.relative(this.path(), String(to)));
}
/**
* Return a new relative `Path` instance from the current
* "from" path to the defined "to" path.
*/
relativeTo(to: PortablePath): Path {
return new Path(path.relative(this.path(), String(to)));
}
/**
* Return a new `Path` instance where the current path is accurately
* resolved against the defined current working directory.
*/
resolve(cwd?: PortablePath): Path {
return new Path(path.resolve(String(cwd || process.cwd()), this.internalPath));
}
/**
* Return a new `Path` instance where the current path is accurately
* resolved against the defined current working directory.
*/
resolve(cwd?: PortablePath): Path {
return new Path(path.resolve(String(cwd ?? process.cwd()), this.internalPath));
}
toJSON(): FilePath {
return this.path();
}
toJSON(): FilePath {
return this.path();
}
toString(): FilePath {
return this.path();
}
toString(): FilePath {
return this.path();
}
}

@@ -1,100 +0,106 @@

import CommonError from './CommonError';
import Path from './Path';
import { Lookup, LookupType, PortablePath } from './types';
import { CommonError } from './CommonError';
import { Path } from './Path';
import { Lookup, LookupType, ModuleResolver, PortablePath } from './types';
export default class PathResolver {
private lookups: Lookup[] = [];
export class PathResolver {
private lookups: Lookup[] = [];
/**
* Return a list of all lookup paths.
*/
getLookupPaths(): string[] {
return this.lookups.map((lookup) => lookup.path.path());
}
private resolver: ModuleResolver;
/**
* Add a file system path to look for, resolved against the defined current
* working directory (or `process.cwd()` otherwise).
*/
lookupFilePath(filePath: PortablePath, cwd?: PortablePath): this {
this.lookups.push({
path: Path.resolve(filePath, cwd),
raw: Path.create(filePath),
type: LookupType.FILE_SYSTEM,
});
constructor(resolver?: ModuleResolver) {
this.resolver = resolver ?? require.resolve;
}
return this;
}
/**
* Return a list of all lookup paths.
*/
getLookupPaths(): string[] {
return this.lookups.map((lookup) => lookup.path.path());
}
/**
* Add a Node.js module, either by name or relative path, to look for.
*/
lookupNodeModule(modulePath: PortablePath): this {
const path = Path.create(modulePath);
/**
* Add a file system path to look for, resolved against the defined current
* working directory (or `process.cwd()` otherwise).
*/
lookupFilePath(filePath: PortablePath, cwd?: PortablePath): this {
this.lookups.push({
path: Path.resolve(filePath, cwd),
raw: Path.create(filePath),
type: LookupType.FILE_SYSTEM,
});
this.lookups.push({
path,
raw: path,
type: LookupType.NODE_MODULE,
});
return this;
}
return this;
}
/**
* Add a Node.js module, either by name or relative path, to look for.
*/
lookupNodeModule(modulePath: PortablePath): this {
const path = Path.create(modulePath);
/**
* Given a list of lookups, attempt to find the first real/existing path and
* return a resolved absolute path. If a file system path, will check using `fs.exists`.
* If a node module path, will check using `require.resolve`.
*/
resolve(): {
originalPath: Path;
resolvedPath: Path;
type: LookupType;
} {
let resolvedPath: PortablePath = '';
let resolvedLookup: Lookup | undefined;
this.lookups.push({
path,
raw: path,
type: LookupType.NODE_MODULE,
});
this.lookups.some((lookup) => {
// Check that the file exists on the file system.
if (lookup.type === LookupType.FILE_SYSTEM) {
if (lookup.path.exists()) {
resolvedPath = lookup.path;
resolvedLookup = lookup;
} else {
return false;
}
return this;
}
// Check that the module path exists using Node's module resolution.
// The `require.resolve` function will throw an error if not found.
} else if (lookup.type === LookupType.NODE_MODULE) {
try {
resolvedPath = require.resolve(lookup.path.path());
resolvedLookup = lookup;
} catch (error) {
return false;
}
}
/**
* Given a list of lookups, attempt to find the first real/existing path and
* return a resolved absolute path. If a file system path, will check using `fs.exists`.
* If a node module path, will check using `require.resolve`.
*/
resolve(): {
originalPath: Path;
resolvedPath: Path;
type: LookupType;
} {
let resolvedPath: PortablePath = '';
let resolvedLookup: Lookup | undefined;
return true;
});
this.lookups.some((lookup) => {
// Check that the file exists on the file system.
if (lookup.type === LookupType.FILE_SYSTEM) {
if (lookup.path.exists()) {
resolvedPath = lookup.path;
resolvedLookup = lookup;
} else {
return false;
}
if (!resolvedPath || !resolvedLookup) {
throw new CommonError('PATH_RESOLVE_LOOKUPS', [
this.lookups.map((lookup) => ` - ${lookup.path} (${lookup.type})`).join('\n'),
]);
}
// Check that the module path exists using Node's module resolution.
// The `require.resolve` function will throw an error if not found.
} else if (lookup.type === LookupType.NODE_MODULE) {
try {
resolvedPath = this.resolver(lookup.path.path());
resolvedLookup = lookup;
} catch {
return false;
}
}
return {
originalPath: resolvedLookup.raw,
resolvedPath: Path.create(resolvedPath),
type: resolvedLookup.type,
};
}
return true;
});
/**
* Like `resolve()` but only returns the resolved path.
*/
resolvePath(): Path {
return this.resolve().resolvedPath;
}
if (!resolvedPath || !resolvedLookup) {
throw new CommonError('PATH_RESOLVE_LOOKUPS', [
this.lookups.map((lookup) => ` - ${lookup.path} (${lookup.type})`).join('\n'),
]);
}
return {
originalPath: resolvedLookup.raw,
resolvedPath: Path.create(resolvedPath),
type: resolvedLookup.type,
};
}
/**
* Like `resolve()` but only returns the resolved path.
*/
resolvePath(): Path {
return this.resolve().resolvedPath;
}
}

@@ -5,139 +5,139 @@ /* eslint-disable @typescript-eslint/member-ordering */

import { Memoize } from '@boost/decorators';
import CommonError from './CommonError';
import parseFile from './helpers/parseFile';
import Path from './Path';
import { CommonError } from './CommonError';
import { parseFile } from './helpers/parseFile';
import { Path } from './Path';
import {
FilePath,
PackageStructure,
PortablePath,
WorkspaceMetadata,
WorkspacePackage,
FilePath,
PackageStructure,
PortablePath,
WorkspaceMetadata,
WorkspacePackage,
} from './types';
export interface ProjectSearchOptions {
relative?: boolean;
relative?: boolean;
}
export default class Project {
readonly root: Path;
export class Project {
readonly root: Path;
constructor(root: PortablePath = process.cwd()) {
this.root = Path.create(root);
}
constructor(root: PortablePath = process.cwd()) {
this.root = Path.create(root);
}
/**
* Create a workspace metadata object composed of absolute file paths.
*/
createWorkspaceMetadata(jsonPath: PortablePath): WorkspaceMetadata {
const metadata: Partial<WorkspaceMetadata> = {};
const filePath = Path.create(jsonPath);
const pkgPath = filePath.parent();
const wsPath = pkgPath.parent();
/**
* Create a workspace metadata object composed of absolute file paths.
*/
createWorkspaceMetadata(jsonPath: PortablePath): WorkspaceMetadata {
const metadata: Partial<WorkspaceMetadata> = {};
const filePath = Path.create(jsonPath);
const pkgPath = filePath.parent();
const wsPath = pkgPath.parent();
metadata.jsonPath = filePath.path();
metadata.packagePath = pkgPath.path();
metadata.packageName = pkgPath.name();
metadata.workspacePath = wsPath.path();
metadata.workspaceName = wsPath.name();
metadata.jsonPath = filePath.path();
metadata.packagePath = pkgPath.path();
metadata.packageName = pkgPath.name();
metadata.workspacePath = wsPath.path();
metadata.workspaceName = wsPath.name();
return metadata as WorkspaceMetadata;
}
return metadata as WorkspaceMetadata;
}
/**
* Return the contents of the root `package.json`.
*/
getPackage<T extends PackageStructure>(): T {
const pkgPath = this.root.append('package.json');
/**
* Return the contents of the root `package.json`.
*/
getPackage<T extends PackageStructure>(): T {
const pkgPath = this.root.append('package.json');
if (!pkgPath.exists()) {
throw new CommonError('PROJECT_NO_PACKAGE');
}
if (!pkgPath.exists()) {
throw new CommonError('PROJECT_NO_PACKAGE');
}
return parseFile<T>(pkgPath);
}
return parseFile<T>(pkgPath);
}
/**
* Return a list of all workspace globs as they are configured
* in `package.json` or `lerna.json`.
*/
@Memoize()
// eslint-disable-next-line complexity
getWorkspaceGlobs(options: ProjectSearchOptions = {}): FilePath[] {
const pkgPath = this.root.append('package.json');
const lernaPath = this.root.append('lerna.json');
const pnpmPath = this.root.append('pnpm-workspace.yaml');
const workspacePaths = [];
/**
* Return a list of all workspace globs as they are configured
* in `package.json` or `lerna.json`.
*/
@Memoize()
// eslint-disable-next-line complexity
getWorkspaceGlobs(options: ProjectSearchOptions = {}): FilePath[] {
const pkgPath = this.root.append('package.json');
const lernaPath = this.root.append('lerna.json');
const pnpmPath = this.root.append('pnpm-workspace.yaml');
const workspacePaths = [];
// Yarn
if (pkgPath.exists()) {
const pkg = parseFile<PackageStructure>(pkgPath);
// Yarn
if (pkgPath.exists()) {
const pkg = parseFile<PackageStructure>(pkgPath);
if (pkg.workspaces) {
if (Array.isArray(pkg.workspaces)) {
workspacePaths.push(...pkg.workspaces);
} else if (Array.isArray(pkg.workspaces.packages)) {
workspacePaths.push(...pkg.workspaces.packages);
}
}
}
if (pkg.workspaces) {
if (Array.isArray(pkg.workspaces)) {
workspacePaths.push(...pkg.workspaces);
} else if (Array.isArray(pkg.workspaces.packages)) {
workspacePaths.push(...pkg.workspaces.packages);
}
}
}
// Lerna
if (workspacePaths.length === 0 && lernaPath.exists()) {
const lerna = parseFile<{ packages: string[] }>(lernaPath);
// Lerna
if (workspacePaths.length === 0 && lernaPath.exists()) {
const lerna = parseFile<{ packages: string[] }>(lernaPath);
if (Array.isArray(lerna.packages)) {
workspacePaths.push(...lerna.packages);
}
}
if (Array.isArray(lerna.packages)) {
workspacePaths.push(...lerna.packages);
}
}
// PNPM
if (workspacePaths.length === 0 && pnpmPath.exists()) {
const pnpm = parseFile<{ packages: string[] }>(pnpmPath);
// PNPM
if (workspacePaths.length === 0 && pnpmPath.exists()) {
const pnpm = parseFile<{ packages: string[] }>(pnpmPath);
if (Array.isArray(pnpm.packages)) {
workspacePaths.push(...pnpm.packages);
}
}
if (Array.isArray(pnpm.packages)) {
workspacePaths.push(...pnpm.packages);
}
}
if (options.relative) {
return workspacePaths;
}
if (options.relative) {
return workspacePaths;
}
return workspacePaths.map((workspace) => this.root.append(workspace).path());
}
return workspacePaths.map((workspace) => this.root.append(workspace).path());
}
/**
* Return all `package.json`s across all workspaces and their packages.
* Once loaded, append workspace path metadata.
*/
@Memoize()
getWorkspacePackages<T extends PackageStructure>(): WorkspacePackage<T>[] {
return glob
.sync(this.getWorkspaceGlobs({ relative: true }), {
absolute: true,
cwd: this.root.path(),
onlyDirectories: true,
})
.map((pkgPath) => {
const filePath = new Path(pkgPath, 'package.json');
/**
* Return all `package.json`s across all workspaces and their packages.
* Once loaded, append workspace path metadata.
*/
@Memoize()
getWorkspacePackages<T extends PackageStructure>(): WorkspacePackage<T>[] {
return glob
.sync(this.getWorkspaceGlobs({ relative: true }), {
absolute: true,
cwd: this.root.path(),
onlyDirectories: true,
})
.map((pkgPath) => {
const filePath = new Path(pkgPath, 'package.json');
return {
metadata: this.createWorkspaceMetadata(filePath),
package: parseFile<T>(filePath),
};
});
}
return {
metadata: this.createWorkspaceMetadata(filePath),
package: parseFile<T>(filePath),
};
});
}
/**
* Return a list of all workspace package paths, resolved against the file system.
*/
@Memoize()
getWorkspacePackagePaths(options: ProjectSearchOptions = {}): FilePath[] {
return glob.sync(this.getWorkspaceGlobs({ relative: true }), {
absolute: !options.relative,
cwd: this.root.path(),
onlyDirectories: true,
onlyFiles: false,
});
}
/**
* Return a list of all workspace package paths, resolved against the file system.
*/
@Memoize()
getWorkspacePackagePaths(options: ProjectSearchOptions = {}): FilePath[] {
return glob.sync(this.getWorkspaceGlobs({ relative: true }), {
absolute: !options.relative,
cwd: this.root.path(),
onlyDirectories: true,
onlyFiles: false,
});
}
}

@@ -6,13 +6,13 @@ import JSON from 'json5';

export interface JSONStringifyOptions {
space?: number | string | null;
quote?: string | null;
replacer?: (number | string)[] | ((key: string, value: unknown) => unknown) | null;
space?: number | string | null;
quote?: string | null;
replacer?: (number | string)[] | ((key: string, value: unknown) => unknown) | null;
}
export function parse<T = object>(content: string, reviver?: JSONReviver): T {
return JSON.parse(content, reviver);
return JSON.parse(content, reviver);
}
export function stringify(content: unknown, options: JSONStringifyOptions = {}): string {
return JSON.stringify(content, options);
return JSON.stringify(content, options);
}
import YAML from 'yaml';
export function parse<T = object>(content: string, options?: YAML.Options): T {
return YAML.parse(content, options);
return YAML.parse(content, options) as T;
}
export function stringify(content: unknown, options?: YAML.Options): string {
return YAML.stringify(content, options);
return YAML.stringify(content, options);
}
import { Blueprint, Predicates } from 'optimal';
import Path from './Path';
import type { Path } from './Path';

@@ -15,12 +15,14 @@ // NODE

export enum LookupType {
FILE_SYSTEM = 'FILE_SYSTEM',
NODE_MODULE = 'NODE_MODULE',
FILE_SYSTEM = 'FILE_SYSTEM',
NODE_MODULE = 'NODE_MODULE',
}
export interface Lookup {
path: Path;
raw: Path;
type: LookupType;
path: Path;
raw: Path;
type: LookupType;
}
export type ModuleResolver = (path: ModuleName) => FilePath;
// CLASSES

@@ -37,14 +39,14 @@

export type BlueprintFactory<T extends object> = (
predicates: Predicates,
onConstruction?: boolean,
predicates: Predicates,
onConstruction?: boolean,
) => Blueprint<T>;
export interface Optionable<T extends object = {}> {
readonly options: Required<T>;
readonly options: Required<T>;
blueprint: BlueprintFactory<object>;
blueprint: BlueprintFactory<object>;
}
export interface Toolable {
name: string;
name: string;
}

@@ -57,4 +59,4 @@

export interface BugSetting {
url?: string;
email?: string;
url?: string;
email?: string;
}

@@ -65,78 +67,78 @@

export interface TypeSetting {
type: string;
url: string;
type: string;
url: string;
}
export interface PeopleSetting {
name: string;
email?: string;
url?: string;
name: string;
email?: string;
url?: string;
}
export interface RepositorySetting extends TypeSetting {
directory?: string;
directory?: string;
}
export interface PackageStructure {
author?: PeopleSetting | string;
bin?: SettingMap | string;
browser?: string;
browserslist?: string[];
bugs?: BugSetting | string;
bundledDependencies?: string[];
config?: SettingMap;
contributors?: PeopleSetting[] | string[];
cpu?: string[];
dependencies?: DependencyMap;
description?: string;
devDependencies?: DependencyMap;
directories?: SettingMap<'bin' | 'doc' | 'example' | 'lib' | 'man' | 'test'>;
engines?: SettingMap;
exports?: Record<string, SettingMap | string[] | string> | string;
files?: string[];
funding?: (TypeSetting | string)[] | TypeSetting | string;
homepage?: string;
imports?: Record<string, SettingMap>;
keywords?: string[];
license?: TypeSetting | TypeSetting[] | string;
main?: string;
man?: string[] | string;
name: string;
optionalDependencies?: DependencyMap;
os?: string[];
peerDependencies?: DependencyMap;
private?: boolean;
publishConfig?: {
access?: 'public' | 'restricted';
registry?: string;
tag?: string;
};
repository?: RepositorySetting | string;
scripts?: SettingMap;
type?: 'commonjs' | 'module';
version: string;
// TypeScript
types?: string;
typesVersions?: Record<string, Record<string, string[]>>;
typings?: string;
// Webpack
module?: string;
sideEffects?: string[] | boolean;
// Yarn
workspaces?:
| string[]
| {
packages?: string[];
nohoist?: string[];
};
author?: PeopleSetting | string;
bin?: SettingMap | string;
browser?: string;
browserslist?: string[];
bugs?: BugSetting | string;
bundledDependencies?: string[];
config?: SettingMap;
contributors?: PeopleSetting[] | string[];
cpu?: string[];
dependencies?: DependencyMap;
description?: string;
devDependencies?: DependencyMap;
directories?: SettingMap<'bin' | 'doc' | 'example' | 'lib' | 'man' | 'test'>;
engines?: SettingMap;
exports?: Record<string, SettingMap | string[] | string> | string;
files?: string[];
funding?: (TypeSetting | string)[] | TypeSetting | string;
homepage?: string;
imports?: Record<string, SettingMap>;
keywords?: string[];
license?: TypeSetting | TypeSetting[] | string;
main?: string;
man?: string[] | string;
name: string;
optionalDependencies?: DependencyMap;
os?: string[];
peerDependencies?: DependencyMap;
private?: boolean;
publishConfig?: {
access?: 'public' | 'restricted';
registry?: string;
tag?: string;
};
repository?: RepositorySetting | string;
scripts?: SettingMap;
type?: 'commonjs' | 'module';
version: string;
// TypeScript
types?: string;
typesVersions?: Record<string, Record<string, string[]>>;
typings?: string;
// Webpack
module?: string;
sideEffects?: string[] | boolean;
// Yarn
workspaces?:
| string[]
| {
packages?: string[];
nohoist?: string[];
};
}
export interface PackageGraphTreeNode<T extends PackageStructure> {
nodes?: PackageGraphTreeNode<T>[];
package: T;
nodes?: PackageGraphTreeNode<T>[];
package: T;
}
export interface PackageGraphTree<T extends PackageStructure> {
nodes: PackageGraphTreeNode<T>[];
root: boolean;
nodes: PackageGraphTreeNode<T>[];
root: boolean;
}

@@ -147,12 +149,12 @@

export interface WorkspaceMetadata {
jsonPath: string;
packagePath: string;
packageName: string;
workspacePath: string;
workspaceName: string;
jsonPath: string;
packagePath: string;
packageName: string;
workspacePath: string;
workspaceName: string;
}
export interface WorkspacePackage<T extends PackageStructure = PackageStructure> {
metadata: WorkspaceMetadata;
package: T;
metadata: WorkspaceMetadata;
package: T;
}

@@ -163,6 +165,6 @@

declare global {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface TypedPropertyDescriptor<T> {
initializer?: Function;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface TypedPropertyDescriptor<T> {
initializer?: Function;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc