@swc/helpers
Advanced tools
Comparing version 0.5.3 to 0.5.5
@@ -21,3 +21,3 @@ /* @minVersion 7.20.0 */ | ||
export function _apply_decs_2203_r(targetClass, memberDecs, classDecs) { | ||
export function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) { | ||
function createAddInitializerMethod(initializers, decoratorFinishedRef) { | ||
@@ -31,3 +31,3 @@ return function addInitializer(initializer) { | ||
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value) { | ||
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) { | ||
var kindStr; | ||
@@ -141,3 +141,3 @@ | ||
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers) { | ||
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) { | ||
var decs = decInfo[0]; | ||
@@ -174,3 +174,3 @@ | ||
if (typeof decs === "function") { | ||
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, value); | ||
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value); | ||
@@ -196,3 +196,3 @@ if (newValue !== void 0) { | ||
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value); | ||
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value); | ||
@@ -288,3 +288,3 @@ if (newValue !== void 0) { | ||
function applyMemberDecs(Class, decInfos) { | ||
function applyMemberDecs(Class, decInfos, metadata) { | ||
var ret = []; | ||
@@ -345,3 +345,3 @@ var protoInitializers; | ||
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers); | ||
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata); | ||
} | ||
@@ -363,3 +363,3 @@ | ||
function applyClassDecs(targetClass, classDecs) { | ||
function applyClassDecs(targetClass, classDecs, metadata) { | ||
if (classDecs.length > 0) { | ||
@@ -374,3 +374,3 @@ var initializers = []; | ||
try { | ||
var nextNewClass = classDecs[i](newClass, { kind: "class", name: name, addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef) }); | ||
var nextNewClass = classDecs[i](newClass, { kind: "class", name: name, addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef), metadata }); | ||
} finally { | ||
@@ -386,3 +386,3 @@ decoratorFinishedRef.v = true; | ||
return [newClass, function() { | ||
return [defineMetadata(newClass, metadata), function() { | ||
for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass); | ||
@@ -395,2 +395,6 @@ }]; | ||
function defineMetadata(Class, metadata) { | ||
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: metadata }); | ||
} | ||
/** | ||
@@ -542,8 +546,14 @@ Basic usage: | ||
_apply_decs_2203_r = function(targetClass, memberDecs, classDecs) { | ||
_apply_decs_2203_r = function(targetClass, memberDecs, classDecs, parentClass) { | ||
if (parentClass !== void 0) { | ||
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")]; | ||
} | ||
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata); | ||
var e = applyMemberDecs(targetClass, memberDecs, metadata); | ||
if (!classDecs.length) defineMetadata(targetClass, metadata); | ||
return { | ||
e: applyMemberDecs(targetClass, memberDecs), | ||
e: e, | ||
// Lazily apply class decorations so that member init locals can be properly bound. | ||
get c() { | ||
return applyClassDecs(targetClass, classDecs); | ||
return applyClassDecs(targetClass, classDecs, metadata); | ||
} | ||
@@ -553,5 +563,5 @@ }; | ||
return _apply_decs_2203_r(targetClass, memberDecs, classDecs); | ||
return _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass); | ||
} | ||
export { _apply_decs_2203_r as _ }; |
@@ -5,4 +5,4 @@ /* @minVersion 7.22.0 */ | ||
if (value === null || value === void 0) return value; | ||
if (typeof value !== "object") { | ||
throw new TypeError("using declarations can only be used with objects, null, or undefined."); | ||
if (Object(value) !== value) { | ||
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); | ||
} | ||
@@ -9,0 +9,0 @@ // core-js-pure uses Symbol.for for polyfilling well-known symbols |
{ | ||
"name": "@swc/helpers", | ||
"packageManager": "yarn@3.5.0", | ||
"version": "0.5.3", | ||
"packageManager": "yarn@4.0.2", | ||
"version": "0.5.5", | ||
"description": "External helpers for the swc project.", | ||
@@ -39,2 +39,3 @@ "module": "esm/index.js", | ||
"dependencies": { | ||
"@swc/counter": "^0.1.3", | ||
"tslib": "^2.4.0" | ||
@@ -41,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
229661
4585
2
+ Added@swc/counter@^0.1.3
+ Added@swc/counter@0.1.3(transitive)