@jsenv/core 30.4.1 → 30.4.2
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/applyDecs2203R/applyDecs2203R.js +355 -388
- package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +575 -0
- package/dist/js/s.js.map +12 -11
- package/dist/js/ws.js +30 -26
- package/dist/main.js +652 -273
- package/package.json +15 -14
|
@@ -18,191 +18,171 @@
|
|
|
18
18
|
CLASS = 10; // only used in assertValidReturnValue
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value) {
|
|
29
|
-
var kindStr;
|
|
30
|
-
switch (kind) {
|
|
31
|
-
case 1 /* ACCESSOR */:
|
|
32
|
-
kindStr = "accessor";
|
|
33
|
-
break;
|
|
34
|
-
case 2 /* METHOD */:
|
|
35
|
-
kindStr = "method";
|
|
36
|
-
break;
|
|
37
|
-
case 3 /* GETTER */:
|
|
38
|
-
kindStr = "getter";
|
|
39
|
-
break;
|
|
40
|
-
case 4 /* SETTER */:
|
|
41
|
-
kindStr = "setter";
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
kindStr = "field";
|
|
45
|
-
}
|
|
46
|
-
var ctx = {
|
|
47
|
-
kind: kindStr,
|
|
48
|
-
name: isPrivate ? "#" + name : name,
|
|
49
|
-
static: isStatic,
|
|
50
|
-
private: isPrivate
|
|
51
|
-
};
|
|
52
|
-
var decoratorFinishedRef = {
|
|
53
|
-
v: false
|
|
54
|
-
};
|
|
55
|
-
if (kind !== 0 /* FIELD */) {
|
|
56
|
-
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
21
|
+
function applyDecs2203RFactory() {
|
|
22
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
23
|
+
return function addInitializer(initializer) {
|
|
24
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
25
|
+
assertCallable(initializer, "An initializer");
|
|
26
|
+
initializers.push(initializer);
|
|
27
|
+
};
|
|
57
28
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
29
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value) {
|
|
30
|
+
var kindStr;
|
|
31
|
+
switch (kind) {
|
|
32
|
+
case 1 /* ACCESSOR */:
|
|
33
|
+
kindStr = "accessor";
|
|
34
|
+
break;
|
|
35
|
+
case 2 /* METHOD */:
|
|
36
|
+
kindStr = "method";
|
|
37
|
+
break;
|
|
38
|
+
case 3 /* GETTER */:
|
|
39
|
+
kindStr = "getter";
|
|
40
|
+
break;
|
|
41
|
+
case 4 /* SETTER */:
|
|
42
|
+
kindStr = "setter";
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
kindStr = "field";
|
|
70
46
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
var ctx = {
|
|
48
|
+
kind: kindStr,
|
|
49
|
+
name: isPrivate ? "#" + name : name,
|
|
50
|
+
static: isStatic,
|
|
51
|
+
private: isPrivate
|
|
52
|
+
};
|
|
53
|
+
var decoratorFinishedRef = {
|
|
54
|
+
v: false
|
|
74
55
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
if (kind !== 0 /* FIELD */) {
|
|
57
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
58
|
+
}
|
|
59
|
+
var get, set;
|
|
60
|
+
if (kind === 0 /* FIELD */) {
|
|
61
|
+
if (isPrivate) {
|
|
62
|
+
get = desc.get;
|
|
63
|
+
set = desc.set;
|
|
64
|
+
} else {
|
|
65
|
+
get = function () {
|
|
66
|
+
return this[name];
|
|
67
|
+
};
|
|
68
|
+
set = function (v) {
|
|
69
|
+
this[name] = v;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
} else if (kind === 2 /* METHOD */) {
|
|
78
73
|
get = function () {
|
|
79
|
-
return desc.
|
|
74
|
+
return desc.value;
|
|
80
75
|
};
|
|
76
|
+
} else {
|
|
77
|
+
// replace with values that will go through the final getter and setter
|
|
78
|
+
if (kind === 1 /* ACCESSOR */ || kind === 3 /* GETTER */) {
|
|
79
|
+
get = function () {
|
|
80
|
+
return desc.get.call(this);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (kind === 1 /* ACCESSOR */ || kind === 4 /* SETTER */) {
|
|
84
|
+
set = function (v) {
|
|
85
|
+
desc.set.call(this, v);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
ctx.access = get && set ? {
|
|
90
|
+
get: get,
|
|
91
|
+
set: set
|
|
92
|
+
} : get ? {
|
|
93
|
+
get: get
|
|
94
|
+
} : {
|
|
95
|
+
set: set
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
return dec(value, ctx);
|
|
99
|
+
} finally {
|
|
100
|
+
decoratorFinishedRef.v = true;
|
|
86
101
|
}
|
|
87
102
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} : get ? {
|
|
92
|
-
get: get
|
|
93
|
-
} : {
|
|
94
|
-
set: set
|
|
95
|
-
};
|
|
96
|
-
try {
|
|
97
|
-
return dec(value, ctx);
|
|
98
|
-
} finally {
|
|
99
|
-
decoratorFinishedRef.v = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
103
|
-
if (decoratorFinishedRef.v) {
|
|
104
|
-
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function assertCallable(fn, hint) {
|
|
108
|
-
if (typeof fn !== "function") {
|
|
109
|
-
throw new TypeError(hint + " must be a function");
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function assertValidReturnValue(kind, value) {
|
|
113
|
-
var type = typeof value;
|
|
114
|
-
if (kind === 1 /* ACCESSOR */) {
|
|
115
|
-
if (type !== "object" || value === null) {
|
|
116
|
-
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
117
|
-
}
|
|
118
|
-
if (value.get !== undefined) {
|
|
119
|
-
assertCallable(value.get, "accessor.get");
|
|
103
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
104
|
+
if (decoratorFinishedRef.v) {
|
|
105
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
120
106
|
}
|
|
121
|
-
if (value.set !== undefined) {
|
|
122
|
-
assertCallable(value.set, "accessor.set");
|
|
123
|
-
}
|
|
124
|
-
if (value.init !== undefined) {
|
|
125
|
-
assertCallable(value.init, "accessor.init");
|
|
126
|
-
}
|
|
127
|
-
} else if (type !== "function") {
|
|
128
|
-
var hint;
|
|
129
|
-
if (kind === 0 /* FIELD */) {
|
|
130
|
-
hint = "field";
|
|
131
|
-
} else if (kind === 10 /* CLASS */) {
|
|
132
|
-
hint = "class";
|
|
133
|
-
} else {
|
|
134
|
-
hint = "method";
|
|
135
|
-
}
|
|
136
|
-
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
137
107
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var desc, init, value;
|
|
142
|
-
if (isPrivate) {
|
|
143
|
-
if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
|
|
144
|
-
desc = {
|
|
145
|
-
get: decInfo[3],
|
|
146
|
-
set: decInfo[4]
|
|
147
|
-
};
|
|
148
|
-
} else if (kind === 3 /* GETTER */) {
|
|
149
|
-
desc = {
|
|
150
|
-
get: decInfo[3]
|
|
151
|
-
};
|
|
152
|
-
} else if (kind === 4 /* SETTER */) {
|
|
153
|
-
desc = {
|
|
154
|
-
set: decInfo[3]
|
|
155
|
-
};
|
|
156
|
-
} else {
|
|
157
|
-
desc = {
|
|
158
|
-
value: decInfo[3]
|
|
159
|
-
};
|
|
108
|
+
function assertCallable(fn, hint) {
|
|
109
|
+
if (typeof fn !== "function") {
|
|
110
|
+
throw new TypeError(hint + " must be a function");
|
|
160
111
|
}
|
|
161
|
-
} else if (kind !== 0 /* FIELD */) {
|
|
162
|
-
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
163
112
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
|
|
113
|
+
function assertValidReturnValue(kind, value) {
|
|
114
|
+
var type = typeof value;
|
|
115
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
116
|
+
if (type !== "object" || value === null) {
|
|
117
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
118
|
+
}
|
|
119
|
+
if (value.get !== undefined) {
|
|
120
|
+
assertCallable(value.get, "accessor.get");
|
|
121
|
+
}
|
|
122
|
+
if (value.set !== undefined) {
|
|
123
|
+
assertCallable(value.set, "accessor.set");
|
|
124
|
+
}
|
|
125
|
+
if (value.init !== undefined) {
|
|
126
|
+
assertCallable(value.init, "accessor.init");
|
|
127
|
+
}
|
|
128
|
+
} else if (type !== "function") {
|
|
129
|
+
var hint;
|
|
181
130
|
if (kind === 0 /* FIELD */) {
|
|
182
|
-
|
|
183
|
-
} else if (kind ===
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
131
|
+
hint = "field";
|
|
132
|
+
} else if (kind === 10 /* CLASS */) {
|
|
133
|
+
hint = "class";
|
|
134
|
+
} else {
|
|
135
|
+
hint = "method";
|
|
136
|
+
}
|
|
137
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers) {
|
|
141
|
+
var decs = decInfo[0];
|
|
142
|
+
var desc, init, value;
|
|
143
|
+
if (isPrivate) {
|
|
144
|
+
if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
|
|
145
|
+
desc = {
|
|
146
|
+
get: decInfo[3],
|
|
147
|
+
set: decInfo[4]
|
|
148
|
+
};
|
|
149
|
+
} else if (kind === 3 /* GETTER */) {
|
|
150
|
+
desc = {
|
|
151
|
+
get: decInfo[3]
|
|
152
|
+
};
|
|
153
|
+
} else if (kind === 4 /* SETTER */) {
|
|
154
|
+
desc = {
|
|
155
|
+
set: decInfo[3]
|
|
190
156
|
};
|
|
191
157
|
} else {
|
|
192
|
-
|
|
158
|
+
desc = {
|
|
159
|
+
value: decInfo[3]
|
|
160
|
+
};
|
|
193
161
|
}
|
|
162
|
+
} else if (kind !== 0 /* FIELD */) {
|
|
163
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
164
|
+
}
|
|
165
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
166
|
+
value = {
|
|
167
|
+
get: desc.get,
|
|
168
|
+
set: desc.set
|
|
169
|
+
};
|
|
170
|
+
} else if (kind === 2 /* METHOD */) {
|
|
171
|
+
value = desc.value;
|
|
172
|
+
} else if (kind === 3 /* GETTER */) {
|
|
173
|
+
value = desc.get;
|
|
174
|
+
} else if (kind === 4 /* SETTER */) {
|
|
175
|
+
value = desc.set;
|
|
194
176
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value);
|
|
177
|
+
var newValue, get, set;
|
|
178
|
+
if (typeof decs === "function") {
|
|
179
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, value);
|
|
199
180
|
if (newValue !== void 0) {
|
|
200
181
|
assertValidReturnValue(kind, newValue);
|
|
201
|
-
var newInit;
|
|
202
182
|
if (kind === 0 /* FIELD */) {
|
|
203
|
-
|
|
183
|
+
init = newValue;
|
|
204
184
|
} else if (kind === 1 /* ACCESSOR */) {
|
|
205
|
-
|
|
185
|
+
init = newValue.init;
|
|
206
186
|
get = newValue.get || value.get;
|
|
207
187
|
set = newValue.set || value.set;
|
|
208
188
|
value = {
|
|
@@ -212,169 +192,189 @@ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, ini
|
|
|
212
192
|
} else {
|
|
213
193
|
value = newValue;
|
|
214
194
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
for (var i = decs.length - 1; i >= 0; i--) {
|
|
198
|
+
var dec = decs[i];
|
|
199
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value);
|
|
200
|
+
if (newValue !== void 0) {
|
|
201
|
+
assertValidReturnValue(kind, newValue);
|
|
202
|
+
var newInit;
|
|
203
|
+
if (kind === 0 /* FIELD */) {
|
|
204
|
+
newInit = newValue;
|
|
205
|
+
} else if (kind === 1 /* ACCESSOR */) {
|
|
206
|
+
newInit = newValue.init;
|
|
207
|
+
get = newValue.get || value.get;
|
|
208
|
+
set = newValue.set || value.set;
|
|
209
|
+
value = {
|
|
210
|
+
get: get,
|
|
211
|
+
set: set
|
|
212
|
+
};
|
|
220
213
|
} else {
|
|
221
|
-
|
|
214
|
+
value = newValue;
|
|
215
|
+
}
|
|
216
|
+
if (newInit !== void 0) {
|
|
217
|
+
if (init === void 0) {
|
|
218
|
+
init = newInit;
|
|
219
|
+
} else if (typeof init === "function") {
|
|
220
|
+
init = [init, newInit];
|
|
221
|
+
} else {
|
|
222
|
+
init.push(newInit);
|
|
223
|
+
}
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
ret.push(init);
|
|
249
|
-
}
|
|
250
|
-
if (kind !== 0 /* FIELD */) {
|
|
251
|
-
if (kind === 1 /* ACCESSOR */) {
|
|
252
|
-
desc.get = value.get;
|
|
253
|
-
desc.set = value.set;
|
|
254
|
-
} else if (kind === 2 /* METHOD */) {
|
|
255
|
-
desc.value = value;
|
|
256
|
-
} else if (kind === 3 /* GETTER */) {
|
|
257
|
-
desc.get = value;
|
|
258
|
-
} else if (kind === 4 /* SETTER */) {
|
|
259
|
-
desc.set = value;
|
|
228
|
+
if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
|
|
229
|
+
if (init === void 0) {
|
|
230
|
+
// If the initializer was void 0, sub in a dummy initializer
|
|
231
|
+
init = function (instance, init) {
|
|
232
|
+
return init;
|
|
233
|
+
};
|
|
234
|
+
} else if (typeof init !== "function") {
|
|
235
|
+
var ownInitializers = init;
|
|
236
|
+
init = function (instance, init) {
|
|
237
|
+
var value = init;
|
|
238
|
+
for (var i = 0; i < ownInitializers.length; i++) {
|
|
239
|
+
value = ownInitializers[i].call(instance, value);
|
|
240
|
+
}
|
|
241
|
+
return value;
|
|
242
|
+
};
|
|
243
|
+
} else {
|
|
244
|
+
var originalInitializer = init;
|
|
245
|
+
init = function (instance, init) {
|
|
246
|
+
return originalInitializer.call(instance, init);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
ret.push(init);
|
|
260
250
|
}
|
|
261
|
-
if (
|
|
251
|
+
if (kind !== 0 /* FIELD */) {
|
|
262
252
|
if (kind === 1 /* ACCESSOR */) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
266
|
-
ret.push(function (instance, args) {
|
|
267
|
-
return value.set.call(instance, args);
|
|
268
|
-
});
|
|
253
|
+
desc.get = value.get;
|
|
254
|
+
desc.set = value.set;
|
|
269
255
|
} else if (kind === 2 /* METHOD */) {
|
|
270
|
-
|
|
256
|
+
desc.value = value;
|
|
257
|
+
} else if (kind === 3 /* GETTER */) {
|
|
258
|
+
desc.get = value;
|
|
259
|
+
} else if (kind === 4 /* SETTER */) {
|
|
260
|
+
desc.set = value;
|
|
261
|
+
}
|
|
262
|
+
if (isPrivate) {
|
|
263
|
+
if (kind === 1 /* ACCESSOR */) {
|
|
264
|
+
ret.push(function (instance, args) {
|
|
265
|
+
return value.get.call(instance, args);
|
|
266
|
+
});
|
|
267
|
+
ret.push(function (instance, args) {
|
|
268
|
+
return value.set.call(instance, args);
|
|
269
|
+
});
|
|
270
|
+
} else if (kind === 2 /* METHOD */) {
|
|
271
|
+
ret.push(value);
|
|
272
|
+
} else {
|
|
273
|
+
ret.push(function (instance, args) {
|
|
274
|
+
return value.call(instance, args);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
271
277
|
} else {
|
|
272
|
-
|
|
273
|
-
return value.call(instance, args);
|
|
274
|
-
});
|
|
278
|
+
Object.defineProperty(base, name, desc);
|
|
275
279
|
}
|
|
276
|
-
} else {
|
|
277
|
-
Object.defineProperty(base, name, desc);
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
} else {
|
|
307
|
-
base = Class.prototype;
|
|
308
|
-
// initialize protoInitializers when we see a non-field member
|
|
309
|
-
if (kind !== 0 /* FIELD */) {
|
|
310
|
-
protoInitializers = protoInitializers || [];
|
|
311
|
-
initializers = protoInitializers;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (kind !== 0 /* FIELD */ && !isPrivate) {
|
|
315
|
-
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
316
|
-
var existingKind = existingNonFields.get(name) || 0;
|
|
317
|
-
if (existingKind === true || existingKind === 3 /* GETTER */ && kind !== 4 /* SETTER */ || existingKind === 4 /* SETTER */ && kind !== 3 /* GETTER */) {
|
|
318
|
-
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);
|
|
319
|
-
} else if (!existingKind && kind > 2 /* METHOD */) {
|
|
320
|
-
existingNonFields.set(name, kind);
|
|
282
|
+
function applyMemberDecs(Class, decInfos) {
|
|
283
|
+
var ret = [];
|
|
284
|
+
var protoInitializers;
|
|
285
|
+
var staticInitializers;
|
|
286
|
+
var existingProtoNonFields = new Map();
|
|
287
|
+
var existingStaticNonFields = new Map();
|
|
288
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
289
|
+
var decInfo = decInfos[i];
|
|
290
|
+
|
|
291
|
+
// skip computed property names
|
|
292
|
+
if (!Array.isArray(decInfo)) continue;
|
|
293
|
+
var kind = decInfo[1];
|
|
294
|
+
var name = decInfo[2];
|
|
295
|
+
var isPrivate = decInfo.length > 3;
|
|
296
|
+
var isStatic = kind >= 5; /* STATIC */
|
|
297
|
+
var base;
|
|
298
|
+
var initializers;
|
|
299
|
+
if (isStatic) {
|
|
300
|
+
base = Class;
|
|
301
|
+
kind = kind - 5 /* STATIC */;
|
|
302
|
+
// initialize staticInitializers when we see a non-field static member
|
|
303
|
+
if (kind !== 0 /* FIELD */) {
|
|
304
|
+
staticInitializers = staticInitializers || [];
|
|
305
|
+
initializers = staticInitializers;
|
|
306
|
+
}
|
|
321
307
|
} else {
|
|
322
|
-
|
|
308
|
+
base = Class.prototype;
|
|
309
|
+
// initialize protoInitializers when we see a non-field member
|
|
310
|
+
if (kind !== 0 /* FIELD */) {
|
|
311
|
+
protoInitializers = protoInitializers || [];
|
|
312
|
+
initializers = protoInitializers;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (kind !== 0 /* FIELD */ && !isPrivate) {
|
|
316
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
317
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
318
|
+
if (existingKind === true || existingKind === 3 /* GETTER */ && kind !== 4 /* SETTER */ || existingKind === 4 /* SETTER */ && kind !== 3 /* GETTER */) {
|
|
319
|
+
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);
|
|
320
|
+
} else if (!existingKind && kind > 2 /* METHOD */) {
|
|
321
|
+
existingNonFields.set(name, kind);
|
|
322
|
+
} else {
|
|
323
|
+
existingNonFields.set(name, true);
|
|
324
|
+
}
|
|
323
325
|
}
|
|
326
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers);
|
|
324
327
|
}
|
|
325
|
-
|
|
328
|
+
pushInitializers(ret, protoInitializers);
|
|
329
|
+
pushInitializers(ret, staticInitializers);
|
|
330
|
+
return ret;
|
|
326
331
|
}
|
|
327
|
-
pushInitializers(ret,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
return instance;
|
|
338
|
-
});
|
|
332
|
+
function pushInitializers(ret, initializers) {
|
|
333
|
+
if (initializers) {
|
|
334
|
+
ret.push(function (instance) {
|
|
335
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
336
|
+
initializers[i].call(instance);
|
|
337
|
+
}
|
|
338
|
+
return instance;
|
|
339
|
+
});
|
|
340
|
+
}
|
|
339
341
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
342
|
+
function applyClassDecs(targetClass, classDecs) {
|
|
343
|
+
if (classDecs.length > 0) {
|
|
344
|
+
var initializers = [];
|
|
345
|
+
var newClass = targetClass;
|
|
346
|
+
var name = targetClass.name;
|
|
347
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
348
|
+
var decoratorFinishedRef = {
|
|
349
|
+
v: false
|
|
350
|
+
};
|
|
351
|
+
try {
|
|
352
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
353
|
+
kind: "class",
|
|
354
|
+
name: name,
|
|
355
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef)
|
|
356
|
+
});
|
|
357
|
+
} finally {
|
|
358
|
+
decoratorFinishedRef.v = true;
|
|
359
|
+
}
|
|
360
|
+
if (nextNewClass !== undefined) {
|
|
361
|
+
assertValidReturnValue(10 /* CLASS */, nextNewClass);
|
|
362
|
+
newClass = nextNewClass;
|
|
363
|
+
}
|
|
362
364
|
}
|
|
365
|
+
return [newClass, function () {
|
|
366
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
367
|
+
initializers[i].call(newClass);
|
|
368
|
+
}
|
|
369
|
+
}];
|
|
363
370
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
initializers[i].call(newClass);
|
|
367
|
-
}
|
|
368
|
-
}];
|
|
371
|
+
// The transformer will not emit assignment when there are no class decorators,
|
|
372
|
+
// so we don't have to return an empty array here.
|
|
369
373
|
}
|
|
370
|
-
// The transformer will not emit assignment when there are no class decorators,
|
|
371
|
-
// so we don't have to return an empty array here.
|
|
372
|
-
}
|
|
373
374
|
|
|
374
|
-
/**
|
|
375
|
+
/**
|
|
375
376
|
Basic usage:
|
|
376
|
-
|
|
377
|
-
applyDecs(
|
|
377
|
+
applyDecs(
|
|
378
378
|
Class,
|
|
379
379
|
[
|
|
380
380
|
// member decorators
|
|
@@ -391,60 +391,43 @@ function applyClassDecs(targetClass, classDecs) {
|
|
|
391
391
|
]
|
|
392
392
|
)
|
|
393
393
|
```
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
```js
|
|
394
|
+
Fully transpiled example:
|
|
395
|
+
```js
|
|
398
396
|
@dec
|
|
399
397
|
class Class {
|
|
400
398
|
@dec
|
|
401
399
|
a = 123;
|
|
402
|
-
|
|
403
|
-
@dec
|
|
400
|
+
@dec
|
|
404
401
|
#a = 123;
|
|
405
|
-
|
|
406
|
-
@dec
|
|
402
|
+
@dec
|
|
407
403
|
@dec2
|
|
408
404
|
accessor b = 123;
|
|
409
|
-
|
|
410
|
-
@dec
|
|
405
|
+
@dec
|
|
411
406
|
accessor #b = 123;
|
|
412
|
-
|
|
413
|
-
@dec
|
|
407
|
+
@dec
|
|
414
408
|
c() { console.log('c'); }
|
|
415
|
-
|
|
416
|
-
@dec
|
|
409
|
+
@dec
|
|
417
410
|
#c() { console.log('privC'); }
|
|
418
|
-
|
|
419
|
-
@dec
|
|
411
|
+
@dec
|
|
420
412
|
get d() { console.log('d'); }
|
|
421
|
-
|
|
422
|
-
@dec
|
|
413
|
+
@dec
|
|
423
414
|
get #d() { console.log('privD'); }
|
|
424
|
-
|
|
425
|
-
@dec
|
|
415
|
+
@dec
|
|
426
416
|
set e(v) { console.log('e'); }
|
|
427
|
-
|
|
428
|
-
@dec
|
|
417
|
+
@dec
|
|
429
418
|
set #e(v) { console.log('privE'); }
|
|
430
419
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
// becomes
|
|
420
|
+
// becomes
|
|
434
421
|
let initializeInstance;
|
|
435
422
|
let initializeClass;
|
|
436
|
-
|
|
437
|
-
let initA;
|
|
423
|
+
let initA;
|
|
438
424
|
let initPrivA;
|
|
439
|
-
|
|
440
|
-
let initB;
|
|
425
|
+
let initB;
|
|
441
426
|
let initPrivB, getPrivB, setPrivB;
|
|
442
|
-
|
|
443
|
-
let privC;
|
|
427
|
+
let privC;
|
|
444
428
|
let privD;
|
|
445
429
|
let privE;
|
|
446
|
-
|
|
447
|
-
let Class;
|
|
430
|
+
let Class;
|
|
448
431
|
class _Class {
|
|
449
432
|
static {
|
|
450
433
|
let ret = applyDecs(
|
|
@@ -465,63 +448,47 @@ function applyClassDecs(targetClass, classDecs) {
|
|
|
465
448
|
dec
|
|
466
449
|
]
|
|
467
450
|
)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
initB = ret[2];
|
|
474
|
-
|
|
475
|
-
initPrivB = ret[3];
|
|
451
|
+
initA = ret[0];
|
|
452
|
+
initPrivA = ret[1];
|
|
453
|
+
initB = ret[2];
|
|
454
|
+
initPrivB = ret[3];
|
|
476
455
|
getPrivB = ret[4];
|
|
477
456
|
setPrivB = ret[5];
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
initializeInstance = ret[9];
|
|
486
|
-
|
|
487
|
-
Class = ret[10]
|
|
488
|
-
|
|
489
|
-
initializeClass = ret[11];
|
|
457
|
+
privC = ret[6];
|
|
458
|
+
privD = ret[7];
|
|
459
|
+
privE = ret[8];
|
|
460
|
+
initializeInstance = ret[9];
|
|
461
|
+
Class = ret[10]
|
|
462
|
+
initializeClass = ret[11];
|
|
490
463
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
#a = initPrivA(this, 123);
|
|
495
|
-
|
|
496
|
-
#bData = initB(this, 123);
|
|
464
|
+
a = (initializeInstance(this), initA(this, 123));
|
|
465
|
+
#a = initPrivA(this, 123);
|
|
466
|
+
#bData = initB(this, 123);
|
|
497
467
|
get b() { return this.#bData }
|
|
498
468
|
set b(v) { this.#bData = v }
|
|
499
|
-
|
|
500
|
-
#privBData = initPrivB(this, 123);
|
|
469
|
+
#privBData = initPrivB(this, 123);
|
|
501
470
|
get #b() { return getPrivB(this); }
|
|
502
471
|
set #b(v) { setPrivB(this, v); }
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
get #d() { return privD(this); }
|
|
511
|
-
|
|
512
|
-
set e(v) { console.log('e'); }
|
|
513
|
-
|
|
514
|
-
set #e(v) { privE(this, v); }
|
|
472
|
+
c() { console.log('c'); }
|
|
473
|
+
#c(...args) { return privC(this, ...args) }
|
|
474
|
+
get d() { console.log('d'); }
|
|
475
|
+
get #d() { return privD(this); }
|
|
476
|
+
set e(v) { console.log('e'); }
|
|
477
|
+
set #e(v) { privE(this, v); }
|
|
515
478
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
479
|
+
initializeClass(Class);
|
|
480
|
+
*/
|
|
481
|
+
|
|
482
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs) {
|
|
483
|
+
return {
|
|
484
|
+
e: applyMemberDecs(targetClass, memberDecs),
|
|
485
|
+
// Lazily apply class decorations so that member init locals can be properly bound.
|
|
486
|
+
get c() {
|
|
487
|
+
return applyClassDecs(targetClass, classDecs);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
526
490
|
};
|
|
491
|
+
}
|
|
492
|
+
export default function applyDecs2203R(targetClass, memberDecs, classDecs) {
|
|
493
|
+
return (applyDecs2203R = applyDecs2203RFactory())(targetClass, memberDecs, classDecs);
|
|
527
494
|
}
|