ember-source 5.12.0-beta.2 → 5.12.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/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +4200 -6302
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +4040 -8666
- package/dist/ember.prod.js +3734 -8082
- package/dist/packages/@glimmer/debug/index.js +87 -1440
- package/dist/packages/@glimmer/destroyable/index.js +59 -113
- package/dist/packages/@glimmer/encoder/index.js +4 -11
- package/dist/packages/@glimmer/global-context/index.js +40 -144
- package/dist/packages/@glimmer/manager/index.js +191 -312
- package/dist/packages/@glimmer/node/index.js +34 -76
- package/dist/packages/@glimmer/opcode-compiler/index.js +794 -1422
- package/dist/packages/@glimmer/owner/index.js +2 -1
- package/dist/packages/@glimmer/program/index.js +105 -192
- package/dist/packages/@glimmer/reference/index.js +109 -237
- package/dist/packages/@glimmer/runtime/index.js +1939 -3715
- package/dist/packages/@glimmer/util/index.js +114 -241
- package/dist/packages/@glimmer/validator/index.js +203 -409
- package/dist/packages/@glimmer/vm/index.js +163 -176
- package/dist/packages/@glimmer/wire-format/index.js +70 -71
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1 -1
- package/package.json +22 -25
|
@@ -4,8 +4,8 @@ const EMPTY_ARRAY = Object.freeze([]);
|
|
|
4
4
|
function emptyArray() {
|
|
5
5
|
return EMPTY_ARRAY;
|
|
6
6
|
}
|
|
7
|
-
const EMPTY_STRING_ARRAY = emptyArray()
|
|
8
|
-
|
|
7
|
+
const EMPTY_STRING_ARRAY = emptyArray(),
|
|
8
|
+
EMPTY_NUMBER_ARRAY = emptyArray();
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This function returns `true` if the input array is the special empty array sentinel,
|
|
@@ -15,30 +15,21 @@ function isEmptyArray(input) {
|
|
|
15
15
|
return input === EMPTY_ARRAY;
|
|
16
16
|
}
|
|
17
17
|
function* reverse(input) {
|
|
18
|
-
for (let i = input.length - 1; i >= 0; i--)
|
|
19
|
-
yield input[i];
|
|
20
|
-
}
|
|
18
|
+
for (let i = input.length - 1; i >= 0; i--) yield input[i];
|
|
21
19
|
}
|
|
22
20
|
function* enumerate(input) {
|
|
23
21
|
let i = 0;
|
|
24
|
-
for (const item of input)
|
|
25
|
-
yield [i++, item];
|
|
26
|
-
}
|
|
22
|
+
for (const item of input) yield [i++, item];
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
// import Logger from './logger';
|
|
30
|
-
|
|
31
26
|
// let alreadyWarned = false;
|
|
32
|
-
|
|
33
27
|
function debugAssert(test, msg) {
|
|
34
28
|
// if (!alreadyWarned) {
|
|
35
29
|
// alreadyWarned = true;
|
|
36
30
|
// Logger.warn("Don't leave debug assertions on in public builds");
|
|
37
31
|
// }
|
|
38
|
-
|
|
39
|
-
if (!test) {
|
|
40
|
-
throw new Error(msg || 'assertion failure');
|
|
41
|
-
}
|
|
32
|
+
if (!test) throw new Error(msg || "assertion failure");
|
|
42
33
|
}
|
|
43
34
|
function deprecate(desc) {
|
|
44
35
|
LOCAL_LOGGER.warn(`DEPRECATION: ${desc}`);
|
|
@@ -47,14 +38,14 @@ function keys(obj) {
|
|
|
47
38
|
return Object.keys(obj);
|
|
48
39
|
}
|
|
49
40
|
function unwrap(val) {
|
|
50
|
-
if (
|
|
41
|
+
if (null == val) throw new Error("Expected value to be present");
|
|
51
42
|
return val;
|
|
52
43
|
}
|
|
53
44
|
function expect(val, message) {
|
|
54
|
-
if (
|
|
45
|
+
if (null == val) throw new Error(message);
|
|
55
46
|
return val;
|
|
56
47
|
}
|
|
57
|
-
function unreachable(message =
|
|
48
|
+
function unreachable(message = "unreachable") {
|
|
58
49
|
return new Error(message);
|
|
59
50
|
}
|
|
60
51
|
function exhausted(value) {
|
|
@@ -62,63 +53,46 @@ function exhausted(value) {
|
|
|
62
53
|
}
|
|
63
54
|
const tuple = (...args) => args;
|
|
64
55
|
function isPresent(value) {
|
|
65
|
-
return
|
|
56
|
+
return null != value;
|
|
66
57
|
}
|
|
67
58
|
function assertPresent(value, message) {
|
|
68
|
-
if (!isPresent(value)) {
|
|
69
|
-
throw new Error(`Expected present, got ${typeof value === 'string' ? value : message}`);
|
|
70
|
-
}
|
|
59
|
+
if (!isPresent(value)) throw new Error(`Expected present, got ${"string" == typeof value ? value : message}`);
|
|
71
60
|
}
|
|
72
61
|
function isPresentArray(list) {
|
|
73
62
|
return list.length > 0;
|
|
74
63
|
}
|
|
75
64
|
function ifPresent(list, ifPresent, otherwise) {
|
|
76
|
-
|
|
77
|
-
return ifPresent(list);
|
|
78
|
-
} else {
|
|
79
|
-
return otherwise();
|
|
80
|
-
}
|
|
65
|
+
return isPresentArray(list) ? ifPresent(list) : otherwise();
|
|
81
66
|
}
|
|
82
67
|
function arrayToOption(list) {
|
|
83
|
-
|
|
84
|
-
return list;
|
|
85
|
-
} else {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
68
|
+
return isPresentArray(list) ? list : null;
|
|
88
69
|
}
|
|
89
|
-
function assertPresentArray(list, message =
|
|
90
|
-
if (!isPresentArray(list))
|
|
91
|
-
throw new Error(message);
|
|
92
|
-
}
|
|
70
|
+
function assertPresentArray(list, message = "unexpected empty list") {
|
|
71
|
+
if (!isPresentArray(list)) throw new Error(message);
|
|
93
72
|
}
|
|
94
|
-
function asPresentArray(list, message =
|
|
95
|
-
assertPresentArray(list, message);
|
|
96
|
-
return list;
|
|
73
|
+
function asPresentArray(list, message = "unexpected empty list") {
|
|
74
|
+
return assertPresentArray(list, message), list;
|
|
97
75
|
}
|
|
98
76
|
function getLast(list) {
|
|
99
|
-
return list.length
|
|
77
|
+
return 0 === list.length ? void 0 : list[list.length - 1];
|
|
100
78
|
}
|
|
101
79
|
function getFirst(list) {
|
|
102
|
-
return list.length
|
|
80
|
+
return 0 === list.length ? void 0 : list[0];
|
|
103
81
|
}
|
|
104
82
|
function mapPresentArray(list, mapper) {
|
|
105
|
-
if (
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
83
|
+
if (null === list) return null;
|
|
108
84
|
let out = [];
|
|
109
|
-
for (let item of list)
|
|
110
|
-
out.push(mapper(item));
|
|
111
|
-
}
|
|
85
|
+
for (let item of list) out.push(mapper(item));
|
|
112
86
|
return out;
|
|
113
87
|
}
|
|
114
88
|
function dict() {
|
|
115
89
|
return Object.create(null);
|
|
116
90
|
}
|
|
117
91
|
function isDict(u) {
|
|
118
|
-
return
|
|
92
|
+
return null != u;
|
|
119
93
|
}
|
|
120
94
|
function isObject(u) {
|
|
121
|
-
return typeof u
|
|
95
|
+
return "function" == typeof u || "object" == typeof u && null !== u;
|
|
122
96
|
}
|
|
123
97
|
class StackImpl {
|
|
124
98
|
stack;
|
|
@@ -130,20 +104,18 @@ class StackImpl {
|
|
|
130
104
|
return this.stack.length;
|
|
131
105
|
}
|
|
132
106
|
push(item) {
|
|
133
|
-
this.current = item;
|
|
134
|
-
this.stack.push(item);
|
|
107
|
+
this.current = item, this.stack.push(item);
|
|
135
108
|
}
|
|
136
109
|
pop() {
|
|
137
110
|
let item = this.stack.pop();
|
|
138
|
-
this.current = getLast(this.stack) ?? null;
|
|
139
|
-
return item === undefined ? null : item;
|
|
111
|
+
return this.current = getLast(this.stack) ?? null, void 0 === item ? null : item;
|
|
140
112
|
}
|
|
141
113
|
nth(from) {
|
|
142
114
|
let len = this.stack.length;
|
|
143
115
|
return len < from ? null : unwrap(this.stack[len - from]);
|
|
144
116
|
}
|
|
145
117
|
isEmpty() {
|
|
146
|
-
return this.stack.length
|
|
118
|
+
return 0 === this.stack.length;
|
|
147
119
|
}
|
|
148
120
|
toArray() {
|
|
149
121
|
return this.stack;
|
|
@@ -151,79 +123,52 @@ class StackImpl {
|
|
|
151
123
|
}
|
|
152
124
|
|
|
153
125
|
/// <reference types="qunit" />
|
|
154
|
-
|
|
155
|
-
let beginTestSteps;
|
|
156
|
-
let endTestSteps;
|
|
157
|
-
let verifySteps;
|
|
158
|
-
let logStep;
|
|
159
|
-
let debugToString;
|
|
126
|
+
let beginTestSteps, endTestSteps, verifySteps, logStep, debugToString;
|
|
160
127
|
if (isDevelopingApp()) {
|
|
161
128
|
let getFunctionName = fn => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
// If the class has a decent looking name, and the `toString` is one of the
|
|
180
|
-
// default Ember toStrings, replace the constructor portion of the toString
|
|
181
|
-
// with the class name. We check the length of the class name to prevent doing
|
|
182
|
-
// this when the value is minified.
|
|
183
|
-
if (name && /<.*:ember\d+>/u.test(name) && className && className[0] !== '_' && className.length > 2 && className !== 'Class') {
|
|
184
|
-
return name.replace(/<.*:/u, `<${className}:`);
|
|
185
|
-
}
|
|
186
|
-
return name || className;
|
|
187
|
-
};
|
|
188
|
-
let getPrimitiveName = value => {
|
|
189
|
-
return String(value);
|
|
190
|
-
};
|
|
191
|
-
debugToString = value => {
|
|
192
|
-
if (typeof value === 'function') {
|
|
193
|
-
return getFunctionName(value) || `(unknown function)`;
|
|
194
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
195
|
-
return getObjectName(value) || `(unknown object)`;
|
|
196
|
-
} else {
|
|
197
|
-
return getPrimitiveName(value);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
129
|
+
let functionName = fn.name;
|
|
130
|
+
if (void 0 === functionName) {
|
|
131
|
+
let match = /function (\w+)\s*\(/u.exec(String(fn));
|
|
132
|
+
functionName = match && match[1] || "";
|
|
133
|
+
}
|
|
134
|
+
return functionName.replace(/^bound /u, "");
|
|
135
|
+
},
|
|
136
|
+
getObjectName = obj => {
|
|
137
|
+
let name, className;
|
|
138
|
+
// If the class has a decent looking name, and the `toString` is one of the
|
|
139
|
+
// default Ember toStrings, replace the constructor portion of the toString
|
|
140
|
+
// with the class name. We check the length of the class name to prevent doing
|
|
141
|
+
// this when the value is minified.
|
|
142
|
+
return obj.constructor && "function" == typeof obj.constructor && (className = getFunctionName(obj.constructor)), "toString" in obj && obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString && (name = obj.toString()), name && /<.*:ember\d+>/u.test(name) && className && "_" !== className[0] && className.length > 2 && "Class" !== className ? name.replace(/<.*:/u, `<${className}:`) : name || className;
|
|
143
|
+
},
|
|
144
|
+
getPrimitiveName = value => String(value);
|
|
145
|
+
debugToString = value => "function" == typeof value ? getFunctionName(value) || "(unknown function)" : "object" == typeof value && null !== value ? getObjectName(value) || "(unknown object)" : getPrimitiveName(value);
|
|
200
146
|
}
|
|
201
147
|
var debugToString$1 = debugToString;
|
|
202
148
|
function clearElement(parent) {
|
|
203
149
|
let current = parent.firstChild;
|
|
204
|
-
|
|
150
|
+
for (; current;) {
|
|
205
151
|
let next = current.nextSibling;
|
|
206
|
-
parent.removeChild(current);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const INSERT_AFTER_END = 'afterend';
|
|
152
|
+
parent.removeChild(current), current = next;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const RAW_NODE = -1,
|
|
156
|
+
ELEMENT_NODE = 1,
|
|
157
|
+
TEXT_NODE = 3,
|
|
158
|
+
COMMENT_NODE = 8,
|
|
159
|
+
DOCUMENT_NODE = 9,
|
|
160
|
+
DOCUMENT_TYPE_NODE = 10,
|
|
161
|
+
DOCUMENT_FRAGMENT_NODE = 11,
|
|
162
|
+
NS_HTML = "http://www.w3.org/1999/xhtml",
|
|
163
|
+
NS_MATHML = "http://www.w3.org/1998/Math/MathML",
|
|
164
|
+
NS_SVG = "http://www.w3.org/2000/svg",
|
|
165
|
+
NS_XLINK = "http://www.w3.org/1999/xlink",
|
|
166
|
+
NS_XML = "http://www.w3.org/XML/1998/namespace",
|
|
167
|
+
NS_XMLNS = "http://www.w3.org/2000/xmlns/",
|
|
168
|
+
INSERT_BEFORE_BEGIN = "beforebegin",
|
|
169
|
+
INSERT_AFTER_BEGIN = "afterbegin",
|
|
170
|
+
INSERT_BEFORE_END = "beforeend",
|
|
171
|
+
INSERT_AFTER_END = "afterend";
|
|
227
172
|
|
|
228
173
|
/*
|
|
229
174
|
Encoding notes
|
|
@@ -260,22 +205,8 @@ const INSERT_AFTER_END = 'afterend';
|
|
|
260
205
|
Note: The details could change here in the future, this is just the current
|
|
261
206
|
strategy.
|
|
262
207
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
ImmediateConstants[ImmediateConstants["MAX_SMI"] = 1073741823] = "MAX_SMI";
|
|
266
|
-
ImmediateConstants[ImmediateConstants["MIN_SMI"] = -1073741824] = "MIN_SMI";
|
|
267
|
-
ImmediateConstants[ImmediateConstants["SIGN_BIT"] = -536870913] = "SIGN_BIT";
|
|
268
|
-
ImmediateConstants[ImmediateConstants["MAX_INT"] = 536870911] = "MAX_INT";
|
|
269
|
-
ImmediateConstants[ImmediateConstants["MIN_INT"] = -536870912] = "MIN_INT";
|
|
270
|
-
ImmediateConstants[ImmediateConstants["FALSE_HANDLE"] = 0] = "FALSE_HANDLE";
|
|
271
|
-
ImmediateConstants[ImmediateConstants["TRUE_HANDLE"] = 1] = "TRUE_HANDLE";
|
|
272
|
-
ImmediateConstants[ImmediateConstants["NULL_HANDLE"] = 2] = "NULL_HANDLE";
|
|
273
|
-
ImmediateConstants[ImmediateConstants["UNDEFINED_HANDLE"] = 3] = "UNDEFINED_HANDLE";
|
|
274
|
-
ImmediateConstants[ImmediateConstants["ENCODED_FALSE_HANDLE"] = 0] = "ENCODED_FALSE_HANDLE";
|
|
275
|
-
ImmediateConstants[ImmediateConstants["ENCODED_TRUE_HANDLE"] = 1] = "ENCODED_TRUE_HANDLE";
|
|
276
|
-
ImmediateConstants[ImmediateConstants["ENCODED_NULL_HANDLE"] = 2] = "ENCODED_NULL_HANDLE";
|
|
277
|
-
ImmediateConstants[ImmediateConstants["ENCODED_UNDEFINED_HANDLE"] = 3] = "ENCODED_UNDEFINED_HANDLE";
|
|
278
|
-
return ImmediateConstants;
|
|
208
|
+
let ImmediateConstants = function (ImmediateConstants) {
|
|
209
|
+
return ImmediateConstants[ImmediateConstants.MAX_SMI = 1073741823] = "MAX_SMI", ImmediateConstants[ImmediateConstants.MIN_SMI = -1073741824] = "MIN_SMI", ImmediateConstants[ImmediateConstants.SIGN_BIT = -536870913] = "SIGN_BIT", ImmediateConstants[ImmediateConstants.MAX_INT = 536870911] = "MAX_INT", ImmediateConstants[ImmediateConstants.MIN_INT = -536870912] = "MIN_INT", ImmediateConstants[ImmediateConstants.FALSE_HANDLE = 0] = "FALSE_HANDLE", ImmediateConstants[ImmediateConstants.TRUE_HANDLE = 1] = "TRUE_HANDLE", ImmediateConstants[ImmediateConstants.NULL_HANDLE = 2] = "NULL_HANDLE", ImmediateConstants[ImmediateConstants.UNDEFINED_HANDLE = 3] = "UNDEFINED_HANDLE", ImmediateConstants[ImmediateConstants.ENCODED_FALSE_HANDLE = 0] = "ENCODED_FALSE_HANDLE", ImmediateConstants[ImmediateConstants.ENCODED_TRUE_HANDLE = 1] = "ENCODED_TRUE_HANDLE", ImmediateConstants[ImmediateConstants.ENCODED_NULL_HANDLE = 2] = "ENCODED_NULL_HANDLE", ImmediateConstants[ImmediateConstants.ENCODED_UNDEFINED_HANDLE = 3] = "ENCODED_UNDEFINED_HANDLE", ImmediateConstants;
|
|
279
210
|
}({});
|
|
280
211
|
function isHandle(value) {
|
|
281
212
|
return value >= 0;
|
|
@@ -284,10 +215,10 @@ function isNonPrimitiveHandle(value) {
|
|
|
284
215
|
return value > ImmediateConstants.ENCODED_UNDEFINED_HANDLE;
|
|
285
216
|
}
|
|
286
217
|
function constants(...values) {
|
|
287
|
-
return [
|
|
218
|
+
return [!1, !0, null, void 0, ...values];
|
|
288
219
|
}
|
|
289
220
|
function isSmallInt(value) {
|
|
290
|
-
return value % 1
|
|
221
|
+
return value % 1 == 0 && value <= ImmediateConstants.MAX_INT && value >= ImmediateConstants.MIN_INT;
|
|
291
222
|
}
|
|
292
223
|
function encodeNegative(num) {
|
|
293
224
|
return num & ImmediateConstants.SIGN_BIT;
|
|
@@ -308,14 +239,11 @@ function decodeHandle(num) {
|
|
|
308
239
|
return num;
|
|
309
240
|
}
|
|
310
241
|
function encodeImmediate(num) {
|
|
311
|
-
num |= 0;
|
|
312
|
-
return num < 0 ? encodeNegative(num) : encodePositive(num);
|
|
242
|
+
return (num |= 0) < 0 ? encodeNegative(num) : encodePositive(num);
|
|
313
243
|
}
|
|
314
244
|
function decodeImmediate(num) {
|
|
315
|
-
num |= 0;
|
|
316
|
-
return num > ImmediateConstants.SIGN_BIT ? decodePositive(num) : decodeNegative(num);
|
|
245
|
+
return (num |= 0) > ImmediateConstants.SIGN_BIT ? decodePositive(num) : decodeNegative(num);
|
|
317
246
|
}
|
|
318
|
-
[1, -1].forEach(x => decodeImmediate(encodeImmediate(x)));
|
|
319
247
|
|
|
320
248
|
/**
|
|
321
249
|
Strongly hint runtimes to intern the provided string.
|
|
@@ -359,16 +287,13 @@ function decodeImmediate(num) {
|
|
|
359
287
|
function intern(str) {
|
|
360
288
|
let obj = {};
|
|
361
289
|
obj[str] = 1;
|
|
362
|
-
for (let key in obj)
|
|
363
|
-
if (key === str) {
|
|
364
|
-
return key;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
290
|
+
for (let key in obj) if (key === str) return key;
|
|
367
291
|
return str;
|
|
368
292
|
}
|
|
369
|
-
|
|
293
|
+
[1, -1].forEach(x => decodeImmediate(encodeImmediate(x)));
|
|
294
|
+
const SERIALIZATION_FIRST_NODE_STRING = "%+b:0%";
|
|
370
295
|
function isSerializationFirstNode(node) {
|
|
371
|
-
return node.nodeValue
|
|
296
|
+
return "%+b:0%" === node.nodeValue;
|
|
372
297
|
}
|
|
373
298
|
let assign = Object.assign;
|
|
374
299
|
function values(obj) {
|
|
@@ -378,41 +303,21 @@ function entries(dict) {
|
|
|
378
303
|
return Object.entries(dict);
|
|
379
304
|
}
|
|
380
305
|
function castToSimple(node) {
|
|
381
|
-
|
|
382
|
-
return node;
|
|
383
|
-
} else if (isSimpleElement(node)) {
|
|
384
|
-
return node;
|
|
385
|
-
} else {
|
|
386
|
-
return node;
|
|
387
|
-
}
|
|
306
|
+
return isDocument(node) || isSimpleElement(node), node;
|
|
388
307
|
}
|
|
389
308
|
|
|
390
309
|
// If passed a document, verify we're in the browser and return it as a Document
|
|
391
|
-
|
|
392
310
|
// If we don't know what this is, but the check requires it to be an element,
|
|
393
311
|
// the cast will mandate that it's a browser element
|
|
394
|
-
|
|
395
312
|
// Finally, if it's a more generic check, the cast will mandate that it's a
|
|
396
313
|
// browser node and return a BrowserNodeUtils corresponding to the check
|
|
397
|
-
|
|
398
314
|
function castToBrowser(node, sugaryCheck) {
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (
|
|
403
|
-
throw new Error('Attempted to cast to a browser node in a non-browser context');
|
|
404
|
-
}
|
|
405
|
-
if (isDocument(node)) {
|
|
406
|
-
return node;
|
|
407
|
-
}
|
|
408
|
-
if (node.ownerDocument !== document) {
|
|
409
|
-
throw new Error('Attempted to cast to a browser node with a node that was not created from this document');
|
|
410
|
-
}
|
|
315
|
+
if (null == node) return null;
|
|
316
|
+
if (void 0 === typeof document) throw new Error("Attempted to cast to a browser node in a non-browser context");
|
|
317
|
+
if (isDocument(node)) return node;
|
|
318
|
+
if (node.ownerDocument !== document) throw new Error("Attempted to cast to a browser node with a node that was not created from this document");
|
|
411
319
|
return checkBrowserNode(node, sugaryCheck);
|
|
412
320
|
}
|
|
413
|
-
function checkError(from, check) {
|
|
414
|
-
return new Error(`cannot cast a ${from} into ${String(check)}`);
|
|
415
|
-
}
|
|
416
321
|
function isDocument(node) {
|
|
417
322
|
return node.nodeType === DOCUMENT_NODE;
|
|
418
323
|
}
|
|
@@ -423,109 +328,79 @@ function isElement(node) {
|
|
|
423
328
|
return node?.nodeType === ELEMENT_NODE && node instanceof Element;
|
|
424
329
|
}
|
|
425
330
|
function checkBrowserNode(node, check) {
|
|
426
|
-
let isMatch =
|
|
427
|
-
if (
|
|
428
|
-
if (
|
|
429
|
-
|
|
430
|
-
} else if (Array.isArray(check)) {
|
|
431
|
-
isMatch = check.some(c => stringCheckNode(node, c));
|
|
432
|
-
} else {
|
|
433
|
-
throw unreachable();
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (isMatch && node instanceof Node) {
|
|
437
|
-
return node;
|
|
438
|
-
} else {
|
|
439
|
-
throw checkError(`SimpleElement(${node?.constructor?.name ?? 'null'})`, check);
|
|
331
|
+
let isMatch = !1;
|
|
332
|
+
if (null !== node) if ("string" == typeof check) isMatch = stringCheckNode(node, check);else {
|
|
333
|
+
if (!Array.isArray(check)) throw unreachable();
|
|
334
|
+
isMatch = check.some(c => stringCheckNode(node, c));
|
|
440
335
|
}
|
|
336
|
+
if (isMatch && node instanceof Node) return node;
|
|
337
|
+
throw function (from, check) {
|
|
338
|
+
return new Error(`cannot cast a ${from} into ${String(check)}`);
|
|
339
|
+
}(`SimpleElement(${node?.constructor?.name ?? "null"})`, check);
|
|
441
340
|
}
|
|
442
341
|
function stringCheckNode(node, check) {
|
|
443
342
|
switch (check) {
|
|
444
|
-
case
|
|
445
|
-
return
|
|
446
|
-
case
|
|
343
|
+
case "NODE":
|
|
344
|
+
return !0;
|
|
345
|
+
case "HTML":
|
|
447
346
|
return node instanceof HTMLElement;
|
|
448
|
-
case
|
|
347
|
+
case "SVG":
|
|
449
348
|
return node instanceof SVGElement;
|
|
450
|
-
case
|
|
349
|
+
case "ELEMENT":
|
|
451
350
|
return node instanceof Element;
|
|
452
351
|
default:
|
|
453
|
-
if (check.toUpperCase() === check)
|
|
454
|
-
throw new Error(`BUG: this code is missing handling for a generic node type`);
|
|
455
|
-
}
|
|
352
|
+
if (check.toUpperCase() === check) throw new Error("BUG: this code is missing handling for a generic node type");
|
|
456
353
|
return node instanceof Element && node.tagName.toLowerCase() === check;
|
|
457
354
|
}
|
|
458
355
|
}
|
|
459
356
|
function strip(strings, ...args) {
|
|
460
|
-
let out =
|
|
461
|
-
for (const [i, string] of enumerate(strings)) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
let
|
|
466
|
-
while (isPresentArray(lines) && /^\s*$/u.test(getFirst(lines))) {
|
|
467
|
-
lines.shift();
|
|
468
|
-
}
|
|
469
|
-
while (isPresentArray(lines) && /^\s*$/u.test(getLast(lines))) {
|
|
470
|
-
lines.pop();
|
|
471
|
-
}
|
|
472
|
-
let min = Infinity;
|
|
357
|
+
let out = "";
|
|
358
|
+
for (const [i, string] of enumerate(strings)) out += `${string}${void 0 !== args[i] ? String(args[i]) : ""}`;
|
|
359
|
+
let lines = out.split("\n");
|
|
360
|
+
for (; isPresentArray(lines) && /^\s*$/u.test(getFirst(lines));) lines.shift();
|
|
361
|
+
for (; isPresentArray(lines) && /^\s*$/u.test(getLast(lines));) lines.pop();
|
|
362
|
+
let min = 1 / 0;
|
|
473
363
|
for (let line of lines) {
|
|
474
364
|
let leading = /^\s*/u.exec(line)[0].length;
|
|
475
365
|
min = Math.min(min, leading);
|
|
476
366
|
}
|
|
477
367
|
let stripped = [];
|
|
478
|
-
for (let line of lines)
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
return stripped.join('\n');
|
|
368
|
+
for (let line of lines) stripped.push(line.slice(min));
|
|
369
|
+
return stripped.join("\n");
|
|
482
370
|
}
|
|
483
371
|
function unwrapHandle(handle) {
|
|
484
|
-
if (typeof handle
|
|
485
|
-
|
|
486
|
-
} else {
|
|
372
|
+
if ("number" == typeof handle) return handle;
|
|
373
|
+
{
|
|
487
374
|
let error = handle.errors[0];
|
|
488
375
|
throw new Error(`Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}`);
|
|
489
376
|
}
|
|
490
377
|
}
|
|
491
378
|
function unwrapTemplate(template) {
|
|
492
|
-
if (template.result
|
|
493
|
-
throw new Error(`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`);
|
|
494
|
-
}
|
|
379
|
+
if ("error" === template.result) throw new Error(`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`);
|
|
495
380
|
return template;
|
|
496
381
|
}
|
|
497
382
|
function extractHandle(handle) {
|
|
498
|
-
|
|
499
|
-
return handle;
|
|
500
|
-
} else {
|
|
501
|
-
return handle.handle;
|
|
502
|
-
}
|
|
383
|
+
return "number" == typeof handle ? handle : handle.handle;
|
|
503
384
|
}
|
|
504
385
|
function isOkHandle(handle) {
|
|
505
|
-
return typeof handle
|
|
386
|
+
return "number" == typeof handle;
|
|
506
387
|
}
|
|
507
388
|
function isErrHandle(handle) {
|
|
508
|
-
return typeof handle
|
|
389
|
+
return "number" == typeof handle;
|
|
509
390
|
}
|
|
510
391
|
function buildUntouchableThis(source) {
|
|
511
392
|
let context = null;
|
|
512
393
|
if (isDevelopingApp()) {
|
|
513
394
|
let assertOnProperty = property => {
|
|
514
|
-
let access = typeof property
|
|
395
|
+
let access = "symbol" == typeof property || "number" == typeof property ? `[${String(property)}]` : `.${property}`;
|
|
515
396
|
throw new Error(`You accessed \`this${access}\` from a function passed to the ${source}, but the function itself was not bound to a valid \`this\` context. Consider updating to use a bound function (for instance, use an arrow function, \`() => {}\`).`);
|
|
516
397
|
};
|
|
517
398
|
context = new Proxy({}, {
|
|
518
399
|
get(_target, property) {
|
|
519
400
|
assertOnProperty(property);
|
|
520
401
|
},
|
|
521
|
-
set(_target, property)
|
|
522
|
-
|
|
523
|
-
return false;
|
|
524
|
-
},
|
|
525
|
-
has(_target, property) {
|
|
526
|
-
assertOnProperty(property);
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
402
|
+
set: (_target, property) => (assertOnProperty(property), !1),
|
|
403
|
+
has: (_target, property) => (assertOnProperty(property), !1)
|
|
529
404
|
});
|
|
530
405
|
}
|
|
531
406
|
return context;
|
|
@@ -539,7 +414,8 @@ function buildUntouchableThis(source) {
|
|
|
539
414
|
* It does not alleviate the need to check LOCAL_SHOULD_LOG, which is used
|
|
540
415
|
* for stripping.
|
|
541
416
|
*/
|
|
542
|
-
const LOCAL_LOGGER = console
|
|
417
|
+
const LOCAL_LOGGER = console,
|
|
418
|
+
LOGGER = console;
|
|
543
419
|
|
|
544
420
|
/**
|
|
545
421
|
* This constant exists to make it easier to differentiate normal logs from
|
|
@@ -547,11 +423,8 @@ const LOCAL_LOGGER = console;
|
|
|
547
423
|
* and is meant to be used in the rare situation where a console.* call is
|
|
548
424
|
* actually appropriate.
|
|
549
425
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
LOGGER.log('unreachable', value);
|
|
553
|
-
LOGGER.log(`${desc} :: ${JSON.stringify(value)} (${value})`);
|
|
554
|
-
throw new Error(`code reached unreachable`);
|
|
426
|
+
function assertNever(value, desc = "unexpected unreachable branch") {
|
|
427
|
+
throw LOGGER.log("unreachable", value), LOGGER.log(`${desc} :: ${JSON.stringify(value)} (${value})`), new Error("code reached unreachable");
|
|
555
428
|
}
|
|
556
429
|
|
|
557
430
|
export { COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, EMPTY_ARRAY, EMPTY_NUMBER_ARRAY, EMPTY_STRING_ARRAY, INSERT_AFTER_BEGIN, INSERT_AFTER_END, INSERT_BEFORE_BEGIN, INSERT_BEFORE_END, ImmediateConstants, LOCAL_LOGGER, LOGGER, NS_HTML, NS_MATHML, NS_SVG, NS_XLINK, NS_XML, NS_XMLNS, RAW_NODE, SERIALIZATION_FIRST_NODE_STRING, StackImpl as Stack, TEXT_NODE, arrayToOption, asPresentArray, debugAssert as assert, assertNever, assertPresent, assertPresentArray, assign, beginTestSteps, buildUntouchableThis, castToBrowser, castToSimple, checkBrowserNode as checkNode, clearElement, constants, debugToString$1 as debugToString, decodeHandle, decodeImmediate, decodeNegative, decodePositive, deprecate, dict, emptyArray, encodeHandle, encodeImmediate, encodeNegative, encodePositive, endTestSteps, entries, enumerate, exhausted, expect, extractHandle, getFirst, getLast, ifPresent, intern, isDict, isElement, isEmptyArray, isErrHandle, isHandle, isNonPrimitiveHandle, isObject, isOkHandle, isPresent, isPresentArray, isSerializationFirstNode, isSimpleElement, isSmallInt, keys, logStep, mapPresentArray, reverse, strip, tuple, unreachable, unwrap, unwrapHandle, unwrapTemplate, values, verifySteps };
|