@polkadot/util
Advanced tools
Comparing version 12.6.2 to 13.0.1
@@ -11,2 +11,3 @@ /** | ||
export * from './compact/index.js'; | ||
export * from './detectPackage.js'; | ||
export * from './extractTime.js'; | ||
@@ -29,2 +30,1 @@ export * from './float/index.js'; | ||
export * from './u8a/index.js'; | ||
export * from './versionDetect.js'; |
@@ -11,2 +11,3 @@ /** | ||
export * from './compact/index.js'; | ||
export * from './detectPackage.js'; | ||
export * from './extractTime.js'; | ||
@@ -29,2 +30,1 @@ export * from './float/index.js'; | ||
export * from './u8a/index.js'; | ||
export * from './versionDetect.js'; |
@@ -16,2 +16,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./compact/index.js"), exports); | ||
tslib_1.__exportStar(require("./detectPackage.js"), exports); | ||
tslib_1.__exportStar(require("./extractTime.js"), exports); | ||
@@ -34,2 +35,1 @@ tslib_1.__exportStar(require("./float/index.js"), exports); | ||
tslib_1.__exportStar(require("./u8a/index.js"), exports); | ||
tslib_1.__exportStar(require("./versionDetect.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const detectOther_js_1 = tslib_1.__importDefault(require("./detectOther.js")); | ||
const packageInfo_js_1 = require("./packageInfo.js"); | ||
const versionDetect_js_1 = require("./versionDetect.js"); | ||
(0, versionDetect_js_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default); | ||
exports.detectPackage = exports.POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG = void 0; | ||
const x_global_1 = require("@polkadot/x-global"); | ||
const function_js_1 = require("./is/function.js"); | ||
const DEDUPE = 'Either remove and explicitly install matching versions or dedupe using your package manager.\nThe following conflicting packages were found:'; | ||
exports.POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG = 'POLKADOTJS_DISABLE_ESM_CJS_WARNING'; | ||
/** @internal */ | ||
function getEntry(name) { | ||
const _global = x_global_1.xglobal; | ||
if (!_global.__polkadotjs) { | ||
_global.__polkadotjs = {}; | ||
} | ||
if (!_global.__polkadotjs[name]) { | ||
_global.__polkadotjs[name] = []; | ||
} | ||
return _global.__polkadotjs[name]; | ||
} | ||
/** @internal */ | ||
function formatDisplay(all, fmt) { | ||
let max = 0; | ||
for (let i = 0, count = all.length; i < count; i++) { | ||
max = Math.max(max, all[i].version.length); | ||
} | ||
return all | ||
.map((d) => `\t${fmt(d.version.padEnd(max), d).join('\t')}`) | ||
.join('\n'); | ||
} | ||
/** @internal */ | ||
function formatInfo(version, { name }) { | ||
return [ | ||
version, | ||
name | ||
]; | ||
} | ||
/** @internal */ | ||
function formatVersion(version, { path, type }) { | ||
let extracted; | ||
if (path && path.length >= 5) { | ||
const nmIndex = path.indexOf('node_modules'); | ||
extracted = nmIndex === -1 | ||
? path | ||
: path.substring(nmIndex); | ||
} | ||
else { | ||
extracted = '<unknown>'; | ||
} | ||
return [ | ||
`${`${type || ''}`.padStart(3)} ${version}`, | ||
extracted | ||
]; | ||
} | ||
/** @internal */ | ||
function getPath(infoPath, pathOrFn) { | ||
if (infoPath) { | ||
return infoPath; | ||
} | ||
else if ((0, function_js_1.isFunction)(pathOrFn)) { | ||
try { | ||
return pathOrFn() || ''; | ||
} | ||
catch { | ||
return ''; | ||
} | ||
} | ||
return pathOrFn || ''; | ||
} | ||
/** @internal */ | ||
function warn(pre, all, fmt) { | ||
console.warn(`${pre}\n${DEDUPE}\n${formatDisplay(all, fmt)}`); | ||
} | ||
/** | ||
* @name detectPackage | ||
* @summary Checks that a specific package is only imported once | ||
* @description A `@polkadot/*` version detection utility, checking for one occurrence of a package in addition to checking for dependency versions. | ||
*/ | ||
function detectPackage({ name, path, type, version }, pathOrFn, deps = []) { | ||
if (!name.startsWith('@polkadot')) { | ||
throw new Error(`Invalid package descriptor ${name}`); | ||
} | ||
const entry = getEntry(name); | ||
entry.push({ path: getPath(path, pathOrFn), type, version }); | ||
// if we have more than one entry at DIFFERENT version types then warn. If there is | ||
// more than one entry at the same version and ESM/CJS dual warnings are disabled, | ||
// then do not display warnings | ||
const entriesSameVersion = entry.every((e) => e.version === version); | ||
const esmCjsWarningDisabled = x_global_1.xglobal.process?.env?.[exports.POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG] === '1'; | ||
const multipleEntries = entry.length !== 1; | ||
const disableWarnings = esmCjsWarningDisabled && entriesSameVersion; | ||
if (multipleEntries && !disableWarnings) { | ||
warn(`${name} has multiple versions, ensure that there is only one installed.`, entry, formatVersion); | ||
} | ||
else { | ||
const mismatches = deps.filter((d) => d && d.version !== version); | ||
if (mismatches.length) { | ||
warn(`${name} requires direct dependencies exactly matching version ${version}.`, mismatches, formatInfo); | ||
} | ||
} | ||
} | ||
exports.detectPackage = detectPackage; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
require("./detectPackage.js"); | ||
require("./packageDetect.js"); | ||
tslib_1.__exportStar(require("./bundle.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.packageInfo = void 0; | ||
exports.packageInfo = { name: '@polkadot/util', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.6.2' }; | ||
exports.packageInfo = { name: '@polkadot/util', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '13.0.1' }; |
@@ -0,1 +1,17 @@ | ||
interface VersionPath { | ||
path: string; | ||
type: string; | ||
version: string; | ||
} | ||
interface PackageInfo extends VersionPath { | ||
name: string; | ||
} | ||
type FnString = () => string | undefined; | ||
export declare const POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG = "POLKADOTJS_DISABLE_ESM_CJS_WARNING"; | ||
/** | ||
* @name detectPackage | ||
* @summary Checks that a specific package is only imported once | ||
* @description A `@polkadot/*` version detection utility, checking for one occurrence of a package in addition to checking for dependency versions. | ||
*/ | ||
export declare function detectPackage({ name, path, type, version }: PackageInfo, pathOrFn?: FnString | string | false | null, deps?: PackageInfo[]): void; | ||
export {}; |
@@ -1,4 +0,96 @@ | ||
import others from './detectOther.js'; | ||
import { packageInfo } from './packageInfo.js'; | ||
import { detectPackage } from './versionDetect.js'; | ||
detectPackage(packageInfo, null, others); | ||
import { xglobal } from '@polkadot/x-global'; | ||
import { isFunction } from './is/function.js'; | ||
const DEDUPE = 'Either remove and explicitly install matching versions or dedupe using your package manager.\nThe following conflicting packages were found:'; | ||
export const POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG = 'POLKADOTJS_DISABLE_ESM_CJS_WARNING'; | ||
/** @internal */ | ||
function getEntry(name) { | ||
const _global = xglobal; | ||
if (!_global.__polkadotjs) { | ||
_global.__polkadotjs = {}; | ||
} | ||
if (!_global.__polkadotjs[name]) { | ||
_global.__polkadotjs[name] = []; | ||
} | ||
return _global.__polkadotjs[name]; | ||
} | ||
/** @internal */ | ||
function formatDisplay(all, fmt) { | ||
let max = 0; | ||
for (let i = 0, count = all.length; i < count; i++) { | ||
max = Math.max(max, all[i].version.length); | ||
} | ||
return all | ||
.map((d) => `\t${fmt(d.version.padEnd(max), d).join('\t')}`) | ||
.join('\n'); | ||
} | ||
/** @internal */ | ||
function formatInfo(version, { name }) { | ||
return [ | ||
version, | ||
name | ||
]; | ||
} | ||
/** @internal */ | ||
function formatVersion(version, { path, type }) { | ||
let extracted; | ||
if (path && path.length >= 5) { | ||
const nmIndex = path.indexOf('node_modules'); | ||
extracted = nmIndex === -1 | ||
? path | ||
: path.substring(nmIndex); | ||
} | ||
else { | ||
extracted = '<unknown>'; | ||
} | ||
return [ | ||
`${`${type || ''}`.padStart(3)} ${version}`, | ||
extracted | ||
]; | ||
} | ||
/** @internal */ | ||
function getPath(infoPath, pathOrFn) { | ||
if (infoPath) { | ||
return infoPath; | ||
} | ||
else if (isFunction(pathOrFn)) { | ||
try { | ||
return pathOrFn() || ''; | ||
} | ||
catch { | ||
return ''; | ||
} | ||
} | ||
return pathOrFn || ''; | ||
} | ||
/** @internal */ | ||
function warn(pre, all, fmt) { | ||
console.warn(`${pre}\n${DEDUPE}\n${formatDisplay(all, fmt)}`); | ||
} | ||
/** | ||
* @name detectPackage | ||
* @summary Checks that a specific package is only imported once | ||
* @description A `@polkadot/*` version detection utility, checking for one occurrence of a package in addition to checking for dependency versions. | ||
*/ | ||
export function detectPackage({ name, path, type, version }, pathOrFn, deps = []) { | ||
if (!name.startsWith('@polkadot')) { | ||
throw new Error(`Invalid package descriptor ${name}`); | ||
} | ||
const entry = getEntry(name); | ||
entry.push({ path: getPath(path, pathOrFn), type, version }); | ||
// if we have more than one entry at DIFFERENT version types then warn. If there is | ||
// more than one entry at the same version and ESM/CJS dual warnings are disabled, | ||
// then do not display warnings | ||
const entriesSameVersion = entry.every((e) => e.version === version); | ||
const esmCjsWarningDisabled = xglobal.process?.env?.[POLKADOTJS_DISABLE_ESM_CJS_WARNING_FLAG] === '1'; | ||
const multipleEntries = entry.length !== 1; | ||
const disableWarnings = esmCjsWarningDisabled && entriesSameVersion; | ||
if (multipleEntries && !disableWarnings) { | ||
warn(`${name} has multiple versions, ensure that there is only one installed.`, entry, formatVersion); | ||
} | ||
else { | ||
const mismatches = deps.filter((d) => d && d.version !== version); | ||
if (mismatches.length) { | ||
warn(`${name} requires direct dependencies exactly matching version ${version}.`, mismatches, formatInfo); | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import './detectPackage.js'; | ||
import './packageDetect.js'; | ||
export * from './bundle.js'; |
@@ -1,2 +0,2 @@ | ||
import './detectPackage.js'; | ||
import './packageDetect.js'; | ||
export * from './bundle.js'; |
@@ -17,7 +17,7 @@ { | ||
"sideEffects": [ | ||
"./detectPackage.js", | ||
"./cjs/detectPackage.js" | ||
"./packageDetect.js", | ||
"./cjs/packageDetect.js" | ||
], | ||
"type": "module", | ||
"version": "12.6.2", | ||
"version": "13.0.1", | ||
"main": "./cjs/index.js", | ||
@@ -251,8 +251,2 @@ "module": "./index.js", | ||
}, | ||
"./detectOther": { | ||
"types": "./detectOther.d.ts", | ||
"module": "./detectOther.js", | ||
"require": "./cjs/detectOther.js", | ||
"default": "./detectOther.js" | ||
}, | ||
"./detectPackage": { | ||
@@ -698,2 +692,8 @@ "types": "./detectPackage.d.ts", | ||
}, | ||
"./packageDetect": { | ||
"types": "./packageDetect.d.ts", | ||
"module": "./packageDetect.js", | ||
"require": "./cjs/packageDetect.js", | ||
"default": "./packageDetect.js" | ||
}, | ||
"./packageInfo.js": { | ||
@@ -876,15 +876,9 @@ "types": "./packageInfo.d.ts", | ||
"default": "./u8a/wrap.js" | ||
}, | ||
"./versionDetect": { | ||
"types": "./versionDetect.d.ts", | ||
"module": "./versionDetect.js", | ||
"require": "./cjs/versionDetect.js", | ||
"default": "./versionDetect.js" | ||
} | ||
}, | ||
"dependencies": { | ||
"@polkadot/x-bigint": "12.6.2", | ||
"@polkadot/x-global": "12.6.2", | ||
"@polkadot/x-textdecoder": "12.6.2", | ||
"@polkadot/x-textencoder": "12.6.2", | ||
"@polkadot/x-bigint": "13.0.1", | ||
"@polkadot/x-global": "13.0.1", | ||
"@polkadot/x-textdecoder": "13.0.1", | ||
"@polkadot/x-textencoder": "13.0.1", | ||
"@types/bn.js": "^5.1.5", | ||
@@ -891,0 +885,0 @@ "bn.js": "^5.2.1", |
@@ -1,1 +0,1 @@ | ||
export const packageInfo = { name: '@polkadot/util', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '12.6.2' }; | ||
export const packageInfo = { name: '@polkadot/util', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '13.0.1' }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
548245
419
14511
+ Added@polkadot/x-bigint@13.0.1(transitive)
+ Added@polkadot/x-global@13.0.1(transitive)
+ Added@polkadot/x-textdecoder@13.0.1(transitive)
+ Added@polkadot/x-textencoder@13.0.1(transitive)
- Removed@polkadot/x-bigint@12.6.2(transitive)
- Removed@polkadot/x-global@12.6.2(transitive)
- Removed@polkadot/x-textdecoder@12.6.2(transitive)
- Removed@polkadot/x-textencoder@12.6.2(transitive)
Updated@polkadot/x-bigint@13.0.1
Updated@polkadot/x-global@13.0.1