@aurelia/metadata
Advanced tools
Comparing version 0.8.0-dev.202007041506 to 0.8.0-dev.202007041536
@@ -473,9 +473,11 @@ /** | ||
}; | ||
function def(obj, key, value) { | ||
Reflect.defineProperty(obj, key, { | ||
writable: true, | ||
function def(obj, key, value, writable, configurable) { | ||
if (!Reflect.defineProperty(obj, key, { | ||
writable, | ||
enumerable: false, | ||
configurable: true, | ||
configurable, | ||
value, | ||
}); | ||
})) { | ||
throw new Error(`Unable to apply metadata polyfill: could not add property '${key}' to the global Reflect object`); | ||
} | ||
} | ||
@@ -486,3 +488,16 @@ const internalSlotName = '[[$au]]'; | ||
} | ||
export function applyMetadataPolyfill(reflect) { | ||
function $applyMetadataPolyfill(reflect, writable, configurable) { | ||
def(reflect, internalSlotName, metadataInternalSlot, writable, configurable); | ||
def(reflect, 'metadata', metadata, writable, configurable); | ||
def(reflect, 'decorate', decorate, writable, configurable); | ||
def(reflect, 'defineMetadata', $define, writable, configurable); | ||
def(reflect, 'hasMetadata', $has, writable, configurable); | ||
def(reflect, 'hasOwnMetadata', $hasOwn, writable, configurable); | ||
def(reflect, 'getMetadata', $get, writable, configurable); | ||
def(reflect, 'getOwnMetadata', $getOwn, writable, configurable); | ||
def(reflect, 'getMetadataKeys', $getKeys, writable, configurable); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys, writable, configurable); | ||
def(reflect, 'deleteMetadata', $delete, writable, configurable); | ||
} | ||
export function applyMetadataPolyfill(reflect, throwIfConflict = true, forceOverwrite = false, writable = true, configurable = true) { | ||
if (hasInternalSlot(reflect)) { | ||
@@ -494,26 +509,32 @@ if (reflect[internalSlotName] === metadataInternalSlot) { | ||
} | ||
if ('metadata' in reflect || | ||
'decorate' in reflect || | ||
'defineMetadata' in reflect || | ||
'hasMetadata' in reflect || | ||
'hasOwnMetadata' in reflect || | ||
'getMetadata' in reflect || | ||
'getOwnMetadata' in reflect || | ||
'getMetadataKeys' in reflect || | ||
'getOwnMetadataKeys' in reflect || | ||
'deleteMetadata' in reflect) { | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario.`); | ||
const presentProps = [ | ||
'metadata', | ||
'decorate', | ||
'defineMetadata', | ||
'hasMetadata', | ||
'hasOwnMetadata', | ||
'getMetadata', | ||
'getOwnMetadata', | ||
'getMetadataKeys', | ||
'getOwnMetadataKeys', | ||
'deleteMetadata', | ||
].filter(function (p) { | ||
return p in Reflect; | ||
}); | ||
if (presentProps.length > 0) { | ||
if (throwIfConflict) { | ||
const implementationSummary = presentProps.map(function (p) { | ||
const impl = `${Reflect[p].toString().slice(0, 100)}...`; | ||
return `${p}:\n${impl}`; | ||
}).join('\n\n'); | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario. Implementation summary:\n\n${implementationSummary}`); | ||
} | ||
else if (forceOverwrite) { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
} | ||
def(Metadata, '$Internal', metadataInternalSlot); | ||
def(reflect, 'metadata', metadata); | ||
def(reflect, 'decorate', decorate); | ||
def(reflect, 'defineMetadata', $define); | ||
def(reflect, 'hasMetadata', $has); | ||
def(reflect, 'hasOwnMetadata', $hasOwn); | ||
def(reflect, 'getMetadata', $get); | ||
def(reflect, 'getOwnMetadata', $getOwn); | ||
def(reflect, 'getMetadataKeys', $getKeys); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys); | ||
def(reflect, 'deleteMetadata', $delete); | ||
else { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -473,4 +473,4 @@ /** | ||
}; | ||
export declare function applyMetadataPolyfill(reflect: typeof Reflect): void; | ||
export declare function applyMetadataPolyfill(reflect: typeof Reflect, throwIfConflict?: boolean, forceOverwrite?: boolean, writable?: boolean, configurable?: boolean): void; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -487,9 +487,11 @@ (function (factory) { | ||
}; | ||
function def(obj, key, value) { | ||
Reflect.defineProperty(obj, key, { | ||
writable: true, | ||
function def(obj, key, value, writable, configurable) { | ||
if (!Reflect.defineProperty(obj, key, { | ||
writable, | ||
enumerable: false, | ||
configurable: true, | ||
configurable, | ||
value, | ||
}); | ||
})) { | ||
throw new Error(`Unable to apply metadata polyfill: could not add property '${key}' to the global Reflect object`); | ||
} | ||
} | ||
@@ -500,3 +502,16 @@ const internalSlotName = '[[$au]]'; | ||
} | ||
function applyMetadataPolyfill(reflect) { | ||
function $applyMetadataPolyfill(reflect, writable, configurable) { | ||
def(reflect, internalSlotName, metadataInternalSlot, writable, configurable); | ||
def(reflect, 'metadata', metadata, writable, configurable); | ||
def(reflect, 'decorate', decorate, writable, configurable); | ||
def(reflect, 'defineMetadata', $define, writable, configurable); | ||
def(reflect, 'hasMetadata', $has, writable, configurable); | ||
def(reflect, 'hasOwnMetadata', $hasOwn, writable, configurable); | ||
def(reflect, 'getMetadata', $get, writable, configurable); | ||
def(reflect, 'getOwnMetadata', $getOwn, writable, configurable); | ||
def(reflect, 'getMetadataKeys', $getKeys, writable, configurable); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys, writable, configurable); | ||
def(reflect, 'deleteMetadata', $delete, writable, configurable); | ||
} | ||
function applyMetadataPolyfill(reflect, throwIfConflict = true, forceOverwrite = false, writable = true, configurable = true) { | ||
if (hasInternalSlot(reflect)) { | ||
@@ -508,25 +523,31 @@ if (reflect[internalSlotName] === metadataInternalSlot) { | ||
} | ||
if ('metadata' in reflect || | ||
'decorate' in reflect || | ||
'defineMetadata' in reflect || | ||
'hasMetadata' in reflect || | ||
'hasOwnMetadata' in reflect || | ||
'getMetadata' in reflect || | ||
'getOwnMetadata' in reflect || | ||
'getMetadataKeys' in reflect || | ||
'getOwnMetadataKeys' in reflect || | ||
'deleteMetadata' in reflect) { | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario.`); | ||
const presentProps = [ | ||
'metadata', | ||
'decorate', | ||
'defineMetadata', | ||
'hasMetadata', | ||
'hasOwnMetadata', | ||
'getMetadata', | ||
'getOwnMetadata', | ||
'getMetadataKeys', | ||
'getOwnMetadataKeys', | ||
'deleteMetadata', | ||
].filter(function (p) { | ||
return p in Reflect; | ||
}); | ||
if (presentProps.length > 0) { | ||
if (throwIfConflict) { | ||
const implementationSummary = presentProps.map(function (p) { | ||
const impl = `${Reflect[p].toString().slice(0, 100)}...`; | ||
return `${p}:\n${impl}`; | ||
}).join('\n\n'); | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario. Implementation summary:\n\n${implementationSummary}`); | ||
} | ||
else if (forceOverwrite) { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
} | ||
def(exports.Metadata, '$Internal', metadataInternalSlot); | ||
def(reflect, 'metadata', metadata); | ||
def(reflect, 'decorate', decorate); | ||
def(reflect, 'defineMetadata', $define); | ||
def(reflect, 'hasMetadata', $has); | ||
def(reflect, 'hasOwnMetadata', $hasOwn); | ||
def(reflect, 'getMetadata', $get); | ||
def(reflect, 'getOwnMetadata', $getOwn); | ||
def(reflect, 'getMetadataKeys', $getKeys); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys); | ||
def(reflect, 'deleteMetadata', $delete); | ||
else { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
} | ||
@@ -533,0 +554,0 @@ exports.applyMetadataPolyfill = applyMetadataPolyfill; |
{ | ||
"name": "@aurelia/metadata", | ||
"version": "0.8.0-dev.202007041506", | ||
"version": "0.8.0-dev.202007041536", | ||
"main": "dist/umd/index.js", | ||
@@ -39,3 +39,3 @@ "module": "dist/esnext/index.js", | ||
}, | ||
"gitHead": "3f15eb801bac897d8c34890e1559be7b9e5b86a6" | ||
"gitHead": "9d406495e7f8b3d25d19e01a4a3c17eec9d6ce60" | ||
} |
@@ -998,9 +998,17 @@ /** | ||
function def(obj: object, key: string, value: unknown): void { | ||
Reflect.defineProperty(obj, key, { | ||
writable: true, | ||
function def( | ||
obj: object, | ||
key: string, | ||
value: unknown, | ||
writable: boolean, | ||
configurable: boolean, | ||
): void { | ||
if (!Reflect.defineProperty(obj, key, { | ||
writable, | ||
enumerable: false, | ||
configurable: true, | ||
configurable, | ||
value, | ||
}); | ||
})) { | ||
throw new Error(`Unable to apply metadata polyfill: could not add property '${key}' to the global Reflect object`); | ||
} | ||
} | ||
@@ -1013,3 +1021,28 @@ | ||
export function applyMetadataPolyfill(reflect: typeof Reflect): void { | ||
function $applyMetadataPolyfill( | ||
reflect: typeof Reflect, | ||
writable: boolean, | ||
configurable: boolean, | ||
): void { | ||
def(reflect, internalSlotName, metadataInternalSlot, writable, configurable); | ||
def(reflect, 'metadata', metadata, writable, configurable); | ||
def(reflect, 'decorate', decorate, writable, configurable); | ||
def(reflect, 'defineMetadata', $define, writable, configurable); | ||
def(reflect, 'hasMetadata', $has, writable, configurable); | ||
def(reflect, 'hasOwnMetadata', $hasOwn, writable, configurable); | ||
def(reflect, 'getMetadata', $get, writable, configurable); | ||
def(reflect, 'getOwnMetadata', $getOwn, writable, configurable); | ||
def(reflect, 'getMetadataKeys', $getKeys, writable, configurable); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys, writable, configurable); | ||
def(reflect, 'deleteMetadata', $delete, writable, configurable); | ||
} | ||
export function applyMetadataPolyfill( | ||
reflect: typeof Reflect, | ||
throwIfConflict: boolean = true, | ||
forceOverwrite: boolean = false, | ||
writable: boolean = true, | ||
configurable: boolean = true, | ||
): void { | ||
if (hasInternalSlot(reflect)) { | ||
@@ -1022,29 +1055,30 @@ if (reflect[internalSlotName] === metadataInternalSlot) { | ||
if ( | ||
'metadata' in reflect || | ||
'decorate' in reflect || | ||
'defineMetadata' in reflect || | ||
'hasMetadata' in reflect || | ||
'hasOwnMetadata' in reflect || | ||
'getMetadata' in reflect || | ||
'getOwnMetadata' in reflect || | ||
'getMetadataKeys' in reflect || | ||
'getOwnMetadataKeys' in reflect || | ||
'deleteMetadata' in reflect | ||
) { | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario.`); | ||
const presentProps = [ | ||
'metadata', | ||
'decorate', | ||
'defineMetadata', | ||
'hasMetadata', | ||
'hasOwnMetadata', | ||
'getMetadata', | ||
'getOwnMetadata', | ||
'getMetadataKeys', | ||
'getOwnMetadataKeys', | ||
'deleteMetadata', | ||
].filter(function (p) { | ||
return p in Reflect; | ||
}); | ||
if (presentProps.length > 0) { | ||
if (throwIfConflict) { | ||
const implementationSummary = presentProps.map(function (p) { | ||
const impl = `${(Reflect as { [k: string]: Function })[p].toString().slice(0, 100)}...`; | ||
return `${p}:\n${impl}`; | ||
}).join('\n\n'); | ||
throw new Error(`Conflicting reflect.metadata polyfill found. If you have 'reflect-metadata' or any other reflect polyfill imported, please remove it, if not (or if you must use a specific polyfill) please file an issue at https://github.com/aurelia/aurelia/issues so that we can look into compatibility options for this scenario. Implementation summary:\n\n${implementationSummary}`); | ||
} else if (forceOverwrite) { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
} else { | ||
$applyMetadataPolyfill(reflect, writable, configurable); | ||
} | ||
def(Metadata, '$Internal', metadataInternalSlot); | ||
def(reflect, 'metadata', metadata); | ||
def(reflect, 'decorate', decorate); | ||
def(reflect, 'defineMetadata', $define); | ||
def(reflect, 'hasMetadata', $has); | ||
def(reflect, 'hasOwnMetadata', $hasOwn); | ||
def(reflect, 'getMetadata', $get); | ||
def(reflect, 'getOwnMetadata', $getOwn); | ||
def(reflect, 'getMetadataKeys', $getKeys); | ||
def(reflect, 'getOwnMetadataKeys', $getOwnKeys); | ||
def(reflect, 'deleteMetadata', $delete); | ||
} |
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
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
139713
2539