@jsenv/core 36.2.1 → 36.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +45 -35
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -3
- package/dist/babel_helpers/applyDecoratedDescriptor/applyDecoratedDescriptor.js +13 -13
- package/dist/babel_helpers/applyDecs/applyDecs.js +227 -42
- package/dist/babel_helpers/applyDecs2203/applyDecs2203.js +559 -418
- package/dist/babel_helpers/applyDecs2203R/applyDecs2203R.js +235 -87
- package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +591 -456
- package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +681 -0
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +5 -5
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +3 -3
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +4 -4
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +4 -4
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +12 -4
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +13 -11
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +18 -17
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +2 -1
- package/dist/babel_helpers/checkInRHS/checkInRHS.js +8 -5
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +7 -7
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +3 -3
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +4 -4
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +2 -2
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +2 -2
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +2 -2
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +3 -3
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +2 -2
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -5
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -5
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +3 -3
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +3 -3
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -6
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +3 -3
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +2 -2
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -7
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -9
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -4
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +2 -2
- package/dist/babel_helpers/construct/construct.js +10 -9
- package/dist/babel_helpers/createClass/createClass.js +2 -3
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +30 -29
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +18 -16
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +23 -17
- package/dist/babel_helpers/createSuper/createSuper.js +14 -12
- package/dist/babel_helpers/decorate/decorate.js +242 -210
- package/dist/babel_helpers/defaults/defaults.js +6 -6
- package/dist/babel_helpers/defineAccessor/defineAccessor.js +1 -4
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +12 -12
- package/dist/babel_helpers/defineProperty/defineProperty.js +7 -6
- package/dist/babel_helpers/extends/extends.js +5 -4
- package/dist/babel_helpers/get/get.js +2 -1
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +4 -3
- package/dist/babel_helpers/inherits/inherits.js +3 -4
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -5
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +4 -4
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +5 -2
- package/dist/babel_helpers/instanceof/instanceof.js +3 -3
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +2 -4
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +19 -21
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +2 -2
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +7 -7
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +6 -2
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +6 -1
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +6 -2
- package/dist/babel_helpers/jsx/jsx.js +14 -7
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +6 -5
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +2 -2
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +5 -3
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +5 -3
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +2 -2
- package/dist/babel_helpers/objectSpread/objectSpread.js +15 -12
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +7 -2
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +15 -13
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +11 -11
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +7 -6
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +2 -2
- package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +124 -73
- package/dist/babel_helpers/set/set.js +23 -20
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +6 -5
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +5 -5
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +10 -5
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +12 -6
- package/dist/babel_helpers/superPropBase/superPropBase.js +6 -5
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +7 -7
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +4 -4
- package/dist/babel_helpers/tdz/tdz.js +2 -2
- package/dist/babel_helpers/temporalRef/temporalRef.js +5 -4
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +1 -1
- package/dist/babel_helpers/toArray/toArray.js +10 -5
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +10 -5
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +7 -7
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -4
- package/dist/babel_helpers/typeof/typeof.js +14 -5
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -8
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +5 -4
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +17 -15
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +19 -8
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +2 -2
- package/dist/js/autoreload.js +148 -133
- package/dist/js/import_meta_hot.js +19 -13
- package/dist/js/inline_content.js +1 -3
- package/dist/js/new_stylesheet.js +119 -60
- package/dist/js/regenerator_runtime.js +204 -102
- package/dist/js/ribbon.js +11 -6
- package/dist/js/server_events_client.js +122 -98
- package/dist/js/ws.js +968 -265
- package/dist/jsenv_core.js +8513 -6162
- package/package.json +9 -9
- package/src/build/build.js +497 -486
- package/src/build/version_mappings_injection.js +21 -44
- package/src/kitchen/errors.js +2 -2
- package/src/kitchen/fetched_content_compliance.js +6 -2
- package/src/kitchen/kitchen.js +285 -80
- package/src/kitchen/prepend_content.js +135 -0
- package/src/kitchen/url_graph/url_graph_visitor.js +99 -0
- package/src/kitchen/url_graph/url_info_transformations.js +140 -21
- package/src/kitchen/url_graph.js +59 -29
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +1 -2
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +2 -2
- package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -2
- package/src/plugins/inlining/jsenv_plugin_inlining_as_data_url.js +1 -1
- package/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js +44 -23
- package/src/plugins/reference_analysis/js/jsenv_plugin_js_reference_analysis.js +2 -1
- package/dist/js/global_this_js_classic.js +0 -24
- package/dist/js/global_this_js_module.js +0 -20
- package/src/build/graph_utils.js +0 -34
|
@@ -20,556 +20,691 @@ import checkInRHS from "../checkInRHS/checkInRHS.js";
|
|
|
20
20
|
CLASS = 10; // only used in assertValidReturnValue
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
function assertInstanceIfPrivate(has, target) {
|
|
31
|
-
if (!has(target)) {
|
|
32
|
-
throw new TypeError("Attempted to access private element on non-instance");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value, hasPrivateBrand) {
|
|
36
|
-
var kindStr;
|
|
37
|
-
switch (kind) {
|
|
38
|
-
case 1 /* ACCESSOR */:
|
|
39
|
-
kindStr = "accessor";
|
|
40
|
-
break;
|
|
41
|
-
case 2 /* METHOD */:
|
|
42
|
-
kindStr = "method";
|
|
43
|
-
break;
|
|
44
|
-
case 3 /* GETTER */:
|
|
45
|
-
kindStr = "getter";
|
|
46
|
-
break;
|
|
47
|
-
case 4 /* SETTER */:
|
|
48
|
-
kindStr = "setter";
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
kindStr = "field";
|
|
23
|
+
function applyDecs2301Factory() {
|
|
24
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
25
|
+
return function addInitializer(initializer) {
|
|
26
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
27
|
+
assertCallable(initializer, "An initializer");
|
|
28
|
+
initializers.push(initializer);
|
|
29
|
+
};
|
|
52
30
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
v: false
|
|
61
|
-
};
|
|
62
|
-
if (kind !== 0 /* FIELD */) {
|
|
63
|
-
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
31
|
+
|
|
32
|
+
function assertInstanceIfPrivate(has, target) {
|
|
33
|
+
if (!has(target)) {
|
|
34
|
+
throw new TypeError(
|
|
35
|
+
"Attempted to access private element on non-instance"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
64
38
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
|
|
40
|
+
function memberDec(
|
|
41
|
+
dec,
|
|
42
|
+
name,
|
|
43
|
+
desc,
|
|
44
|
+
initializers,
|
|
45
|
+
kind,
|
|
46
|
+
isStatic,
|
|
47
|
+
isPrivate,
|
|
48
|
+
value,
|
|
49
|
+
hasPrivateBrand
|
|
50
|
+
) {
|
|
51
|
+
var kindStr;
|
|
52
|
+
|
|
53
|
+
switch (kind) {
|
|
54
|
+
case 1 /* ACCESSOR */:
|
|
55
|
+
kindStr = "accessor";
|
|
56
|
+
break;
|
|
57
|
+
case 2 /* METHOD */:
|
|
58
|
+
kindStr = "method";
|
|
59
|
+
break;
|
|
60
|
+
case 3 /* GETTER */:
|
|
61
|
+
kindStr = "getter";
|
|
62
|
+
break;
|
|
63
|
+
case 4 /* SETTER */:
|
|
64
|
+
kindStr = "setter";
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
kindStr = "field";
|
|
74
68
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
|
|
70
|
+
var ctx = {
|
|
71
|
+
kind: kindStr,
|
|
72
|
+
name: isPrivate ? "#" + name : name,
|
|
73
|
+
static: isStatic,
|
|
74
|
+
private: isPrivate,
|
|
80
75
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
|
|
77
|
+
var decoratorFinishedRef = { v: false };
|
|
78
|
+
|
|
79
|
+
if (kind !== 0 /* FIELD */) {
|
|
80
|
+
ctx.addInitializer = createAddInitializerMethod(
|
|
81
|
+
initializers,
|
|
82
|
+
decoratorFinishedRef
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var get, set;
|
|
87
|
+
if (!isPrivate && (kind === 0 /* FIELD */ || kind === 2) /* METHOD */) {
|
|
88
|
+
get = function (target) {
|
|
89
|
+
return target[name];
|
|
90
|
+
};
|
|
91
|
+
if (kind === 0 /* FIELD */) {
|
|
92
|
+
set = function (target, v) {
|
|
93
|
+
target[name] = v;
|
|
93
94
|
};
|
|
94
95
|
}
|
|
96
|
+
} else if (kind === 2 /* METHOD */) {
|
|
97
|
+
// Assert: isPrivate is true.
|
|
98
|
+
get = function (target) {
|
|
99
|
+
assertInstanceIfPrivate(hasPrivateBrand, target);
|
|
100
|
+
return desc.value;
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
// Assert: If kind === 0, then isPrivate is true.
|
|
104
|
+
var t = kind === 0 /* FIELD */ || kind === 1; /* ACCESSOR */
|
|
105
|
+
if (t || kind === 3 /* GETTER */) {
|
|
106
|
+
if (isPrivate) {
|
|
107
|
+
get = function (target) {
|
|
108
|
+
assertInstanceIfPrivate(hasPrivateBrand, target);
|
|
109
|
+
return desc.get.call(target);
|
|
110
|
+
};
|
|
111
|
+
} else {
|
|
112
|
+
get = function (target) {
|
|
113
|
+
return desc.get.call(target);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (t || kind === 4 /* SETTER */) {
|
|
118
|
+
if (isPrivate) {
|
|
119
|
+
set = function (target, value) {
|
|
120
|
+
assertInstanceIfPrivate(hasPrivateBrand, target);
|
|
121
|
+
desc.set.call(target, value);
|
|
122
|
+
};
|
|
123
|
+
} else {
|
|
124
|
+
set = function (target, value) {
|
|
125
|
+
desc.set.call(target, value);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
95
129
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
desc.set.call(target, value);
|
|
101
|
-
};
|
|
102
|
-
} else {
|
|
103
|
-
set = function (target, value) {
|
|
104
|
-
desc.set.call(target, value);
|
|
130
|
+
var has = isPrivate
|
|
131
|
+
? hasPrivateBrand.bind()
|
|
132
|
+
: function (target) {
|
|
133
|
+
return name in target;
|
|
105
134
|
};
|
|
106
|
-
|
|
135
|
+
ctx.access =
|
|
136
|
+
get && set
|
|
137
|
+
? { get: get, set: set, has: has }
|
|
138
|
+
: get
|
|
139
|
+
? { get: get, has: has }
|
|
140
|
+
: { set: set, has: has };
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
return dec(value, ctx);
|
|
144
|
+
} finally {
|
|
145
|
+
decoratorFinishedRef.v = true;
|
|
107
146
|
}
|
|
108
147
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
has: has
|
|
116
|
-
} : get ? {
|
|
117
|
-
get: get,
|
|
118
|
-
has: has
|
|
119
|
-
} : {
|
|
120
|
-
set: set,
|
|
121
|
-
has: has
|
|
122
|
-
};
|
|
123
|
-
try {
|
|
124
|
-
return dec(value, ctx);
|
|
125
|
-
} finally {
|
|
126
|
-
decoratorFinishedRef.v = true;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
130
|
-
if (decoratorFinishedRef.v) {
|
|
131
|
-
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function assertCallable(fn, hint) {
|
|
135
|
-
if (typeof fn !== "function") {
|
|
136
|
-
throw new TypeError(hint + " must be a function");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function assertValidReturnValue(kind, value) {
|
|
140
|
-
var type = typeof value;
|
|
141
|
-
if (kind === 1 /* ACCESSOR */) {
|
|
142
|
-
if (type !== "object" || value === null) {
|
|
143
|
-
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
144
|
-
}
|
|
145
|
-
if (value.get !== undefined) {
|
|
146
|
-
assertCallable(value.get, "accessor.get");
|
|
147
|
-
}
|
|
148
|
-
if (value.set !== undefined) {
|
|
149
|
-
assertCallable(value.set, "accessor.set");
|
|
150
|
-
}
|
|
151
|
-
if (value.init !== undefined) {
|
|
152
|
-
assertCallable(value.init, "accessor.init");
|
|
148
|
+
|
|
149
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
150
|
+
if (decoratorFinishedRef.v) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
"attempted to call " + fnName + " after decoration was finished"
|
|
153
|
+
);
|
|
153
154
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
hint = "class";
|
|
160
|
-
} else {
|
|
161
|
-
hint = "method";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function assertCallable(fn, hint) {
|
|
158
|
+
if (typeof fn !== "function") {
|
|
159
|
+
throw new TypeError(hint + " must be a function");
|
|
162
160
|
}
|
|
163
|
-
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
164
161
|
}
|
|
165
|
-
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (kind ===
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else if (kind === 4 /* SETTER */) {
|
|
191
|
-
desc = {
|
|
192
|
-
set: decInfo[3]
|
|
193
|
-
};
|
|
162
|
+
|
|
163
|
+
function assertValidReturnValue(kind, value) {
|
|
164
|
+
var type = typeof value;
|
|
165
|
+
|
|
166
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
167
|
+
if (type !== "object" || value === null) {
|
|
168
|
+
throw new TypeError(
|
|
169
|
+
"accessor decorators must return an object with get, set, or init properties or void 0"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
if (value.get !== undefined) {
|
|
173
|
+
assertCallable(value.get, "accessor.get");
|
|
174
|
+
}
|
|
175
|
+
if (value.set !== undefined) {
|
|
176
|
+
assertCallable(value.set, "accessor.set");
|
|
177
|
+
}
|
|
178
|
+
if (value.init !== undefined) {
|
|
179
|
+
assertCallable(value.init, "accessor.init");
|
|
180
|
+
}
|
|
181
|
+
} else if (type !== "function") {
|
|
182
|
+
var hint;
|
|
183
|
+
if (kind === 0 /* FIELD */) {
|
|
184
|
+
hint = "field";
|
|
185
|
+
} else if (kind === 10 /* CLASS */) {
|
|
186
|
+
hint = "class";
|
|
194
187
|
} else {
|
|
195
|
-
|
|
196
|
-
value: decInfo[3]
|
|
197
|
-
};
|
|
188
|
+
hint = "method";
|
|
198
189
|
}
|
|
190
|
+
throw new TypeError(
|
|
191
|
+
hint + " decorators must return a function or void 0"
|
|
192
|
+
);
|
|
199
193
|
}
|
|
200
|
-
} else if (kind !== 0 /* FIELD */) {
|
|
201
|
-
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
202
194
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
195
|
+
|
|
196
|
+
function curryThis1(fn) {
|
|
197
|
+
return function () {
|
|
198
|
+
return fn(this);
|
|
207
199
|
};
|
|
208
|
-
} else if (kind === 2 /* METHOD */) {
|
|
209
|
-
value = desc.value;
|
|
210
|
-
} else if (kind === 3 /* GETTER */) {
|
|
211
|
-
value = desc.get;
|
|
212
|
-
} else if (kind === 4 /* SETTER */) {
|
|
213
|
-
value = desc.set;
|
|
214
200
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
201
|
+
function curryThis2(fn) {
|
|
202
|
+
return function (value) {
|
|
203
|
+
fn(this, value);
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function applyMemberDec(
|
|
208
|
+
ret,
|
|
209
|
+
base,
|
|
210
|
+
decInfo,
|
|
211
|
+
name,
|
|
212
|
+
kind,
|
|
213
|
+
isStatic,
|
|
214
|
+
isPrivate,
|
|
215
|
+
initializers,
|
|
216
|
+
hasPrivateBrand
|
|
217
|
+
) {
|
|
218
|
+
var decs = decInfo[0];
|
|
219
|
+
|
|
220
|
+
var desc, init, value;
|
|
221
|
+
|
|
222
|
+
if (isPrivate) {
|
|
223
|
+
if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
|
|
224
|
+
desc = {
|
|
225
|
+
get: curryThis1(decInfo[3]),
|
|
226
|
+
set: curryThis2(decInfo[4]),
|
|
229
227
|
};
|
|
230
228
|
} else {
|
|
231
|
-
|
|
229
|
+
if (kind === 3 /* GETTER */) {
|
|
230
|
+
desc = {
|
|
231
|
+
get: decInfo[3],
|
|
232
|
+
};
|
|
233
|
+
} else if (kind === 4 /* SETTER */) {
|
|
234
|
+
desc = {
|
|
235
|
+
set: decInfo[3],
|
|
236
|
+
};
|
|
237
|
+
} else {
|
|
238
|
+
desc = {
|
|
239
|
+
value: decInfo[3],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
232
242
|
}
|
|
243
|
+
} else if (kind !== 0 /* FIELD */) {
|
|
244
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
248
|
+
value = {
|
|
249
|
+
get: desc.get,
|
|
250
|
+
set: desc.set,
|
|
251
|
+
};
|
|
252
|
+
} else if (kind === 2 /* METHOD */) {
|
|
253
|
+
value = desc.value;
|
|
254
|
+
} else if (kind === 3 /* GETTER */) {
|
|
255
|
+
value = desc.get;
|
|
256
|
+
} else if (kind === 4 /* SETTER */) {
|
|
257
|
+
value = desc.set;
|
|
233
258
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
259
|
+
|
|
260
|
+
var newValue, get, set;
|
|
261
|
+
|
|
262
|
+
if (typeof decs === "function") {
|
|
263
|
+
newValue = memberDec(
|
|
264
|
+
decs,
|
|
265
|
+
name,
|
|
266
|
+
desc,
|
|
267
|
+
initializers,
|
|
268
|
+
kind,
|
|
269
|
+
isStatic,
|
|
270
|
+
isPrivate,
|
|
271
|
+
value,
|
|
272
|
+
hasPrivateBrand
|
|
273
|
+
);
|
|
274
|
+
|
|
238
275
|
if (newValue !== void 0) {
|
|
239
276
|
assertValidReturnValue(kind, newValue);
|
|
240
|
-
|
|
277
|
+
|
|
241
278
|
if (kind === 0 /* FIELD */) {
|
|
242
|
-
|
|
279
|
+
init = newValue;
|
|
243
280
|
} else if (kind === 1 /* ACCESSOR */) {
|
|
244
|
-
|
|
281
|
+
init = newValue.init;
|
|
245
282
|
get = newValue.get || value.get;
|
|
246
283
|
set = newValue.set || value.set;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
set: set
|
|
250
|
-
};
|
|
284
|
+
|
|
285
|
+
value = { get: get, set: set };
|
|
251
286
|
} else {
|
|
252
287
|
value = newValue;
|
|
253
288
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
for (var i = decs.length - 1; i >= 0; i--) {
|
|
292
|
+
var dec = decs[i];
|
|
293
|
+
|
|
294
|
+
newValue = memberDec(
|
|
295
|
+
dec,
|
|
296
|
+
name,
|
|
297
|
+
desc,
|
|
298
|
+
initializers,
|
|
299
|
+
kind,
|
|
300
|
+
isStatic,
|
|
301
|
+
isPrivate,
|
|
302
|
+
value,
|
|
303
|
+
hasPrivateBrand
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
if (newValue !== void 0) {
|
|
307
|
+
assertValidReturnValue(kind, newValue);
|
|
308
|
+
var newInit;
|
|
309
|
+
|
|
310
|
+
if (kind === 0 /* FIELD */) {
|
|
311
|
+
newInit = newValue;
|
|
312
|
+
} else if (kind === 1 /* ACCESSOR */) {
|
|
313
|
+
newInit = newValue.init;
|
|
314
|
+
get = newValue.get || value.get;
|
|
315
|
+
set = newValue.set || value.set;
|
|
316
|
+
|
|
317
|
+
value = { get: get, set: set };
|
|
259
318
|
} else {
|
|
260
|
-
|
|
319
|
+
value = newValue;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (newInit !== void 0) {
|
|
323
|
+
if (init === void 0) {
|
|
324
|
+
init = newInit;
|
|
325
|
+
} else if (typeof init === "function") {
|
|
326
|
+
init = [init, newInit];
|
|
327
|
+
} else {
|
|
328
|
+
init.push(newInit);
|
|
329
|
+
}
|
|
261
330
|
}
|
|
262
331
|
}
|
|
263
332
|
}
|
|
264
333
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
} else if (kind === 2 /* METHOD */) {
|
|
294
|
-
desc.value = value;
|
|
295
|
-
} else if (kind === 3 /* GETTER */) {
|
|
296
|
-
desc.get = value;
|
|
297
|
-
} else if (kind === 4 /* SETTER */) {
|
|
298
|
-
desc.set = value;
|
|
334
|
+
|
|
335
|
+
if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
|
|
336
|
+
if (init === void 0) {
|
|
337
|
+
// If the initializer was void 0, sub in a dummy initializer
|
|
338
|
+
init = function (instance, init) {
|
|
339
|
+
return init;
|
|
340
|
+
};
|
|
341
|
+
} else if (typeof init !== "function") {
|
|
342
|
+
var ownInitializers = init;
|
|
343
|
+
|
|
344
|
+
init = function (instance, init) {
|
|
345
|
+
var value = init;
|
|
346
|
+
|
|
347
|
+
for (var i = 0; i < ownInitializers.length; i++) {
|
|
348
|
+
value = ownInitializers[i].call(instance, value);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return value;
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
var originalInitializer = init;
|
|
355
|
+
|
|
356
|
+
init = function (instance, init) {
|
|
357
|
+
return originalInitializer.call(instance, init);
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
ret.push(init);
|
|
299
362
|
}
|
|
300
|
-
|
|
363
|
+
|
|
364
|
+
if (kind !== 0 /* FIELD */) {
|
|
301
365
|
if (kind === 1 /* ACCESSOR */) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
});
|
|
305
|
-
ret.push(function (instance, args) {
|
|
306
|
-
return value.set.call(instance, args);
|
|
307
|
-
});
|
|
366
|
+
desc.get = value.get;
|
|
367
|
+
desc.set = value.set;
|
|
308
368
|
} else if (kind === 2 /* METHOD */) {
|
|
309
|
-
|
|
369
|
+
desc.value = value;
|
|
370
|
+
} else if (kind === 3 /* GETTER */) {
|
|
371
|
+
desc.get = value;
|
|
372
|
+
} else if (kind === 4 /* SETTER */) {
|
|
373
|
+
desc.set = value;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (isPrivate) {
|
|
377
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
378
|
+
ret.push(function (instance, args) {
|
|
379
|
+
return value.get.call(instance, args);
|
|
380
|
+
});
|
|
381
|
+
ret.push(function (instance, args) {
|
|
382
|
+
return value.set.call(instance, args);
|
|
383
|
+
});
|
|
384
|
+
} else if (kind === 2 /* METHOD */) {
|
|
385
|
+
ret.push(value);
|
|
386
|
+
} else {
|
|
387
|
+
ret.push(function (instance, args) {
|
|
388
|
+
return value.call(instance, args);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
310
391
|
} else {
|
|
311
|
-
|
|
312
|
-
return value.call(instance, args);
|
|
313
|
-
});
|
|
392
|
+
Object.defineProperty(base, name, desc);
|
|
314
393
|
}
|
|
315
|
-
} else {
|
|
316
|
-
Object.defineProperty(base, name, desc);
|
|
317
394
|
}
|
|
318
395
|
}
|
|
319
|
-
|
|
320
|
-
function applyMemberDecs(Class, decInfos, instanceBrand) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
base
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
initializers = protoInitializers;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
if (kind !== 0 /* FIELD */ && !isPrivate) {
|
|
362
|
-
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
363
|
-
var existingKind = existingNonFields.get(name) || 0;
|
|
364
|
-
if (existingKind === true || existingKind === 3 /* GETTER */ && kind !== 4 /* SETTER */ || existingKind === 4 /* SETTER */ && kind !== 3 /* GETTER */) {
|
|
365
|
-
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
366
|
-
} else if (!existingKind && kind > 2 /* METHOD */) {
|
|
367
|
-
existingNonFields.set(name, kind);
|
|
396
|
+
|
|
397
|
+
function applyMemberDecs(Class, decInfos, instanceBrand) {
|
|
398
|
+
var ret = [];
|
|
399
|
+
var protoInitializers;
|
|
400
|
+
var staticInitializers;
|
|
401
|
+
var staticBrand;
|
|
402
|
+
|
|
403
|
+
var existingProtoNonFields = new Map();
|
|
404
|
+
var existingStaticNonFields = new Map();
|
|
405
|
+
|
|
406
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
407
|
+
var decInfo = decInfos[i];
|
|
408
|
+
|
|
409
|
+
// skip computed property names
|
|
410
|
+
if (!Array.isArray(decInfo)) continue;
|
|
411
|
+
|
|
412
|
+
var kind = decInfo[1];
|
|
413
|
+
var name = decInfo[2];
|
|
414
|
+
var isPrivate = decInfo.length > 3;
|
|
415
|
+
|
|
416
|
+
var isStatic = kind >= 5; /* STATIC */
|
|
417
|
+
var base;
|
|
418
|
+
var initializers;
|
|
419
|
+
var hasPrivateBrand = instanceBrand;
|
|
420
|
+
|
|
421
|
+
if (isStatic) {
|
|
422
|
+
base = Class;
|
|
423
|
+
kind = kind - 5 /* STATIC */;
|
|
424
|
+
// initialize staticInitializers when we see a non-field static member
|
|
425
|
+
if (kind !== 0 /* FIELD */) {
|
|
426
|
+
staticInitializers = staticInitializers || [];
|
|
427
|
+
initializers = staticInitializers;
|
|
428
|
+
}
|
|
429
|
+
if (isPrivate && !staticBrand) {
|
|
430
|
+
staticBrand = function (_) {
|
|
431
|
+
return checkInRHS(_) === Class;
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
hasPrivateBrand = staticBrand;
|
|
368
435
|
} else {
|
|
369
|
-
|
|
436
|
+
base = Class.prototype;
|
|
437
|
+
// initialize protoInitializers when we see a non-field member
|
|
438
|
+
if (kind !== 0 /* FIELD */) {
|
|
439
|
+
protoInitializers = protoInitializers || [];
|
|
440
|
+
initializers = protoInitializers;
|
|
441
|
+
}
|
|
370
442
|
}
|
|
443
|
+
|
|
444
|
+
if (kind !== 0 /* FIELD */ && !isPrivate) {
|
|
445
|
+
var existingNonFields = isStatic
|
|
446
|
+
? existingStaticNonFields
|
|
447
|
+
: existingProtoNonFields;
|
|
448
|
+
|
|
449
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
450
|
+
|
|
451
|
+
if (
|
|
452
|
+
existingKind === true ||
|
|
453
|
+
(existingKind === 3 /* GETTER */ && kind !== 4) /* SETTER */ ||
|
|
454
|
+
(existingKind === 4 /* SETTER */ && kind !== 3) /* GETTER */
|
|
455
|
+
) {
|
|
456
|
+
throw new Error(
|
|
457
|
+
"Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " +
|
|
458
|
+
name
|
|
459
|
+
);
|
|
460
|
+
} else if (!existingKind && kind > 2 /* METHOD */) {
|
|
461
|
+
existingNonFields.set(name, kind);
|
|
462
|
+
} else {
|
|
463
|
+
existingNonFields.set(name, true);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
applyMemberDec(
|
|
468
|
+
ret,
|
|
469
|
+
base,
|
|
470
|
+
decInfo,
|
|
471
|
+
name,
|
|
472
|
+
kind,
|
|
473
|
+
isStatic,
|
|
474
|
+
isPrivate,
|
|
475
|
+
initializers,
|
|
476
|
+
hasPrivateBrand
|
|
477
|
+
);
|
|
371
478
|
}
|
|
372
|
-
|
|
479
|
+
|
|
480
|
+
pushInitializers(ret, protoInitializers);
|
|
481
|
+
pushInitializers(ret, staticInitializers);
|
|
482
|
+
return ret;
|
|
373
483
|
}
|
|
374
|
-
|
|
375
|
-
pushInitializers(ret,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return instance;
|
|
385
|
-
});
|
|
484
|
+
|
|
485
|
+
function pushInitializers(ret, initializers) {
|
|
486
|
+
if (initializers) {
|
|
487
|
+
ret.push(function (instance) {
|
|
488
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
489
|
+
initializers[i].call(instance);
|
|
490
|
+
}
|
|
491
|
+
return instance;
|
|
492
|
+
});
|
|
493
|
+
}
|
|
386
494
|
}
|
|
387
|
-
|
|
388
|
-
function applyClassDecs(targetClass, classDecs) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
var
|
|
395
|
-
v: false
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
495
|
+
|
|
496
|
+
function applyClassDecs(targetClass, classDecs) {
|
|
497
|
+
if (classDecs.length > 0) {
|
|
498
|
+
var initializers = [];
|
|
499
|
+
var newClass = targetClass;
|
|
500
|
+
var name = targetClass.name;
|
|
501
|
+
|
|
502
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
503
|
+
var decoratorFinishedRef = { v: false };
|
|
504
|
+
|
|
505
|
+
try {
|
|
506
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
507
|
+
kind: "class",
|
|
508
|
+
name: name,
|
|
509
|
+
addInitializer: createAddInitializerMethod(
|
|
510
|
+
initializers,
|
|
511
|
+
decoratorFinishedRef
|
|
512
|
+
),
|
|
513
|
+
});
|
|
514
|
+
} finally {
|
|
515
|
+
decoratorFinishedRef.v = true;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (nextNewClass !== undefined) {
|
|
519
|
+
assertValidReturnValue(10 /* CLASS */, nextNewClass);
|
|
520
|
+
newClass = nextNewClass;
|
|
521
|
+
}
|
|
409
522
|
}
|
|
523
|
+
|
|
524
|
+
return [
|
|
525
|
+
newClass,
|
|
526
|
+
function () {
|
|
527
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
528
|
+
initializers[i].call(newClass);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
];
|
|
410
532
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
initializers[i].call(newClass);
|
|
414
|
-
}
|
|
415
|
-
}];
|
|
533
|
+
// The transformer will not emit assignment when there are no class decorators,
|
|
534
|
+
// so we don't have to return an empty array here.
|
|
416
535
|
}
|
|
417
|
-
// The transformer will not emit assignment when there are no class decorators,
|
|
418
|
-
// so we don't have to return an empty array here.
|
|
419
|
-
}
|
|
420
536
|
|
|
421
|
-
/**
|
|
422
|
-
|
|
537
|
+
/**
|
|
538
|
+
Basic usage:
|
|
423
539
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
[
|
|
427
|
-
// member decorators
|
|
540
|
+
applyDecs(
|
|
541
|
+
Class,
|
|
428
542
|
[
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
543
|
+
// member decorators
|
|
544
|
+
[
|
|
545
|
+
dec, // dec or array of decs
|
|
546
|
+
0, // kind of value being decorated
|
|
547
|
+
'prop', // name of public prop on class containing the value being decorated,
|
|
548
|
+
'#p', // the name of the private property (if is private, void 0 otherwise),
|
|
549
|
+
]
|
|
550
|
+
],
|
|
551
|
+
[
|
|
552
|
+
// class decorators
|
|
553
|
+
dec1, dec2
|
|
433
554
|
]
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// class decorators
|
|
437
|
-
dec1, dec2
|
|
438
|
-
]
|
|
439
|
-
)
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
Fully transpiled example:
|
|
443
|
-
|
|
444
|
-
```js
|
|
445
|
-
@dec
|
|
446
|
-
class Class {
|
|
447
|
-
@dec
|
|
448
|
-
a = 123;
|
|
555
|
+
)
|
|
556
|
+
```
|
|
449
557
|
|
|
450
|
-
|
|
451
|
-
#a = 123;
|
|
558
|
+
Fully transpiled example:
|
|
452
559
|
|
|
560
|
+
```js
|
|
453
561
|
@dec
|
|
454
|
-
|
|
455
|
-
|
|
562
|
+
class Class {
|
|
563
|
+
@dec
|
|
564
|
+
a = 123;
|
|
456
565
|
|
|
457
|
-
|
|
458
|
-
|
|
566
|
+
@dec
|
|
567
|
+
#a = 123;
|
|
459
568
|
|
|
460
|
-
|
|
461
|
-
|
|
569
|
+
@dec
|
|
570
|
+
@dec2
|
|
571
|
+
accessor b = 123;
|
|
462
572
|
|
|
463
|
-
|
|
464
|
-
|
|
573
|
+
@dec
|
|
574
|
+
accessor #b = 123;
|
|
465
575
|
|
|
466
|
-
|
|
467
|
-
|
|
576
|
+
@dec
|
|
577
|
+
c() { console.log('c'); }
|
|
468
578
|
|
|
469
|
-
|
|
470
|
-
|
|
579
|
+
@dec
|
|
580
|
+
#c() { console.log('privC'); }
|
|
471
581
|
|
|
472
|
-
|
|
473
|
-
|
|
582
|
+
@dec
|
|
583
|
+
get d() { console.log('d'); }
|
|
474
584
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
585
|
+
@dec
|
|
586
|
+
get #d() { console.log('privD'); }
|
|
478
587
|
|
|
588
|
+
@dec
|
|
589
|
+
set e(v) { console.log('e'); }
|
|
479
590
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
591
|
+
@dec
|
|
592
|
+
set #e(v) { console.log('privE'); }
|
|
593
|
+
}
|
|
483
594
|
|
|
484
|
-
let initA;
|
|
485
|
-
let initPrivA;
|
|
486
595
|
|
|
487
|
-
|
|
488
|
-
|
|
596
|
+
// becomes
|
|
597
|
+
let initializeInstance;
|
|
598
|
+
let initializeClass;
|
|
489
599
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
let privE;
|
|
600
|
+
let initA;
|
|
601
|
+
let initPrivA;
|
|
493
602
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
static {
|
|
497
|
-
let ret = applyDecs(
|
|
498
|
-
this,
|
|
499
|
-
[
|
|
500
|
-
[dec, 0, 'a'],
|
|
501
|
-
[dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
|
|
502
|
-
[[dec, dec2], 1, 'b'],
|
|
503
|
-
[dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
|
|
504
|
-
[dec, 2, 'c'],
|
|
505
|
-
[dec, 2, 'c', () => console.log('privC')],
|
|
506
|
-
[dec, 3, 'd'],
|
|
507
|
-
[dec, 3, 'd', () => console.log('privD')],
|
|
508
|
-
[dec, 4, 'e'],
|
|
509
|
-
[dec, 4, 'e', () => console.log('privE')],
|
|
510
|
-
],
|
|
511
|
-
[
|
|
512
|
-
dec
|
|
513
|
-
]
|
|
514
|
-
)
|
|
603
|
+
let initB;
|
|
604
|
+
let initPrivB, getPrivB, setPrivB;
|
|
515
605
|
|
|
516
|
-
|
|
606
|
+
let privC;
|
|
607
|
+
let privD;
|
|
608
|
+
let privE;
|
|
517
609
|
|
|
518
|
-
|
|
610
|
+
let Class;
|
|
611
|
+
class _Class {
|
|
612
|
+
static {
|
|
613
|
+
let ret = applyDecs(
|
|
614
|
+
this,
|
|
615
|
+
[
|
|
616
|
+
[dec, 0, 'a'],
|
|
617
|
+
[dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
|
|
618
|
+
[[dec, dec2], 1, 'b'],
|
|
619
|
+
[dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
|
|
620
|
+
[dec, 2, 'c'],
|
|
621
|
+
[dec, 2, 'c', () => console.log('privC')],
|
|
622
|
+
[dec, 3, 'd'],
|
|
623
|
+
[dec, 3, 'd', () => console.log('privD')],
|
|
624
|
+
[dec, 4, 'e'],
|
|
625
|
+
[dec, 4, 'e', () => console.log('privE')],
|
|
626
|
+
],
|
|
627
|
+
[
|
|
628
|
+
dec
|
|
629
|
+
]
|
|
630
|
+
)
|
|
519
631
|
|
|
520
|
-
|
|
632
|
+
initA = ret[0];
|
|
521
633
|
|
|
522
|
-
|
|
523
|
-
getPrivB = ret[4];
|
|
524
|
-
setPrivB = ret[5];
|
|
634
|
+
initPrivA = ret[1];
|
|
525
635
|
|
|
526
|
-
|
|
636
|
+
initB = ret[2];
|
|
527
637
|
|
|
528
|
-
|
|
638
|
+
initPrivB = ret[3];
|
|
639
|
+
getPrivB = ret[4];
|
|
640
|
+
setPrivB = ret[5];
|
|
529
641
|
|
|
530
|
-
|
|
642
|
+
privC = ret[6];
|
|
531
643
|
|
|
532
|
-
|
|
644
|
+
privD = ret[7];
|
|
533
645
|
|
|
534
|
-
|
|
646
|
+
privE = ret[8];
|
|
535
647
|
|
|
536
|
-
|
|
537
|
-
}
|
|
648
|
+
initializeInstance = ret[9];
|
|
538
649
|
|
|
539
|
-
|
|
650
|
+
Class = ret[10]
|
|
540
651
|
|
|
541
|
-
|
|
652
|
+
initializeClass = ret[11];
|
|
653
|
+
}
|
|
542
654
|
|
|
543
|
-
|
|
544
|
-
get b() { return this.#bData }
|
|
545
|
-
set b(v) { this.#bData = v }
|
|
655
|
+
a = (initializeInstance(this), initA(this, 123));
|
|
546
656
|
|
|
547
|
-
|
|
548
|
-
get #b() { return getPrivB(this); }
|
|
549
|
-
set #b(v) { setPrivB(this, v); }
|
|
657
|
+
#a = initPrivA(this, 123);
|
|
550
658
|
|
|
551
|
-
|
|
659
|
+
#bData = initB(this, 123);
|
|
660
|
+
get b() { return this.#bData }
|
|
661
|
+
set b(v) { this.#bData = v }
|
|
552
662
|
|
|
553
|
-
|
|
663
|
+
#privBData = initPrivB(this, 123);
|
|
664
|
+
get #b() { return getPrivB(this); }
|
|
665
|
+
set #b(v) { setPrivB(this, v); }
|
|
554
666
|
|
|
555
|
-
|
|
667
|
+
c() { console.log('c'); }
|
|
556
668
|
|
|
557
|
-
|
|
669
|
+
#c(...args) { return privC(this, ...args) }
|
|
558
670
|
|
|
559
|
-
|
|
671
|
+
get d() { console.log('d'); }
|
|
560
672
|
|
|
561
|
-
|
|
562
|
-
}
|
|
673
|
+
get #d() { return privD(this); }
|
|
563
674
|
|
|
564
|
-
|
|
565
|
-
*/
|
|
675
|
+
set e(v) { console.log('e'); }
|
|
566
676
|
|
|
567
|
-
|
|
568
|
-
return {
|
|
569
|
-
e: applyMemberDecs(targetClass, memberDecs, instanceBrand),
|
|
570
|
-
// Lazily apply class decorations so that member init locals can be properly bound.
|
|
571
|
-
get c() {
|
|
572
|
-
return applyClassDecs(targetClass, classDecs);
|
|
677
|
+
set #e(v) { privE(this, v); }
|
|
573
678
|
}
|
|
679
|
+
|
|
680
|
+
initializeClass(Class);
|
|
681
|
+
*/
|
|
682
|
+
return function applyDecs2301(
|
|
683
|
+
targetClass,
|
|
684
|
+
memberDecs,
|
|
685
|
+
classDecs,
|
|
686
|
+
instanceBrand
|
|
687
|
+
) {
|
|
688
|
+
return {
|
|
689
|
+
e: applyMemberDecs(targetClass, memberDecs, instanceBrand),
|
|
690
|
+
// Lazily apply class decorations so that member init locals can be properly bound.
|
|
691
|
+
get c() {
|
|
692
|
+
return applyClassDecs(targetClass, classDecs);
|
|
693
|
+
},
|
|
694
|
+
};
|
|
574
695
|
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export default function applyDecs2301(
|
|
699
|
+
targetClass,
|
|
700
|
+
memberDecs,
|
|
701
|
+
classDecs,
|
|
702
|
+
instanceBrand
|
|
703
|
+
) {
|
|
704
|
+
return (applyDecs2301 = applyDecs2301Factory())(
|
|
705
|
+
targetClass,
|
|
706
|
+
memberDecs,
|
|
707
|
+
classDecs,
|
|
708
|
+
instanceBrand
|
|
709
|
+
);
|
|
575
710
|
}
|