ember-source 6.4.0-alpha.2 → 6.4.0-alpha.3
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 +907 -1527
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +3574 -4029
- package/dist/ember.prod.js +3408 -3984
- package/dist/packages/@ember/-internals/glimmer/index.js +2 -2
- package/dist/packages/@ember/-internals/owner/index.js +1 -0
- package/dist/packages/@ember/application/index.js +2 -2
- package/dist/packages/@ember/application/instance.js +1 -1
- package/dist/packages/@ember/component/helper.js +1 -1
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/debug/lib/capture-render-tree.js +5 -3
- package/dist/packages/@ember/engine/index.js +2 -2
- package/dist/packages/@ember/helper/index.js +1 -1
- package/dist/packages/@ember/modifier/index.js +1 -1
- package/dist/packages/@ember/renderer/index.js +1 -1
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/template/index.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/plugins/index.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/template.js +73 -89
- package/dist/packages/@glimmer/destroyable/index.js +45 -16
- package/dist/packages/@glimmer/encoder/index.js +1 -2
- package/dist/packages/@glimmer/global-context/index.js +15 -27
- package/dist/packages/@glimmer/manager/index.js +137 -84
- package/dist/packages/@glimmer/node/index.js +7 -4
- package/dist/packages/@glimmer/opcode-compiler/index.js +564 -534
- package/dist/packages/@glimmer/owner/index.js +1 -0
- package/dist/packages/@glimmer/program/index.js +42 -109
- package/dist/packages/@glimmer/reference/index.js +18 -29
- package/dist/packages/@glimmer/runtime/index.js +3435 -3263
- package/dist/packages/@glimmer/util/index.js +32 -273
- package/dist/packages/@glimmer/validator/index.js +36 -43
- package/dist/packages/@glimmer/vm/index.js +2 -140
- package/dist/packages/@glimmer/wire-format/index.js +1 -2
- package/dist/packages/ember/barrel.js +1 -1
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/lib/initializers.js +1 -1
- package/dist/packages/shared-chunks/{index-CQygUgr9.js → index-y5ClupI2.js} +50 -45
- package/dist/packages/shared-chunks/{setup-registry-DXuvS1Rj.js → setup-registry-8yPevDL_.js} +1 -1
- package/dist/packages/shared-chunks/{transform-resolutions-O6uYv8DS.js → transform-resolutions-Dpc2ClA0.js} +298 -441
- package/docs/data.json +40 -22
- package/package.json +21 -22
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/outlet.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/unwrap-template.d.ts +7 -0
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +7 -9
- package/types/stable/@ember/-internals/glimmer/lib/resolver.d.ts +2 -5
- package/types/stable/index.d.ts +1 -0
- package/dist/packages/@glimmer/debug/index.js +0 -168
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { getInternalHelperManager, getInternalModifierManager, getInternalComponentManager, capabilityFlagsFrom, getComponentTemplate, managerHasCapability } from '../manager/index.js';
|
|
2
2
|
import { templateFactory } from '../opcode-compiler/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { enumerate } from '../util/index.js';
|
|
4
4
|
import { InternalComponentCapabilities, OPERAND_LEN_MASK, ARG_SHIFT, MACHINE_MASK, TYPE_MASK } from '../vm/index.js';
|
|
5
5
|
import { SexpOpcodes as opcodes } from '../wire-format/index.js';
|
|
6
6
|
|
|
7
|
+
function unwrapTemplate(template) {
|
|
8
|
+
if ("error" === template.result) throw new Error(`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`);
|
|
9
|
+
return template;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* Default component template, which is a plain yield
|
|
9
14
|
*/
|
|
10
|
-
const DEFAULT_TEMPLATE_BLOCK = [[[opcodes.Yield, 1, null]], ["&default"],
|
|
15
|
+
const DEFAULT_TEMPLATE_BLOCK = [[[opcodes.Yield, 1, null]], ["&default"], []],
|
|
11
16
|
DEFAULT_TEMPLATE = {
|
|
12
17
|
// random uuid
|
|
13
18
|
id: "1b32f5c2-7623-43d6-a0ad-9672898920a1",
|
|
@@ -17,12 +22,9 @@ const DEFAULT_TEMPLATE_BLOCK = [[[opcodes.Yield, 1, null]], ["&default"], !1, []
|
|
|
17
22
|
isStrictMode: !0
|
|
18
23
|
},
|
|
19
24
|
WELL_KNOWN_EMPTY_ARRAY = Object.freeze([]),
|
|
20
|
-
STARTER_CONSTANTS =
|
|
25
|
+
STARTER_CONSTANTS = [!1, !0, null, void 0, WELL_KNOWN_EMPTY_ARRAY],
|
|
21
26
|
WELL_KNOWN_EMPTY_ARRAY_POSITION = STARTER_CONSTANTS.indexOf(WELL_KNOWN_EMPTY_ARRAY);
|
|
22
|
-
class
|
|
23
|
-
// `0` means NULL
|
|
24
|
-
values = STARTER_CONSTANTS.slice();
|
|
25
|
-
indexMap = new Map(this.values.map((value, index) => [value, index]));
|
|
27
|
+
class ConstantsImpl {
|
|
26
28
|
value(value) {
|
|
27
29
|
let indexMap = this.indexMap,
|
|
28
30
|
index = indexMap.get(value);
|
|
@@ -37,35 +39,9 @@ class CompileTimeConstantImpl {
|
|
|
37
39
|
toPool() {
|
|
38
40
|
return this.values;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
values;
|
|
43
|
-
constructor(pool) {
|
|
44
|
-
this.values = pool;
|
|
45
|
-
}
|
|
46
|
-
getValue(handle) {
|
|
47
|
-
return this.values[handle];
|
|
48
|
-
}
|
|
49
|
-
getArray(value) {
|
|
50
|
-
let handles = this.getValue(value),
|
|
51
|
-
reified = new Array(handles.length);
|
|
52
|
-
for (const [i, n] of enumerate(handles)) reified[i] = this.getValue(n);
|
|
53
|
-
return reified;
|
|
42
|
+
hasHandle(handle) {
|
|
43
|
+
return this.values.length > handle;
|
|
54
44
|
}
|
|
55
|
-
}
|
|
56
|
-
class ConstantsImpl extends CompileTimeConstantImpl {
|
|
57
|
-
reifiedArrs = {
|
|
58
|
-
[WELL_KNOWN_EMPTY_ARRAY_POSITION]: WELL_KNOWN_EMPTY_ARRAY
|
|
59
|
-
};
|
|
60
|
-
defaultTemplate = templateFactory(DEFAULT_TEMPLATE)();
|
|
61
|
-
// Used for tests and debugging purposes, and to be able to analyze large apps
|
|
62
|
-
// This is why it's enabled even in production
|
|
63
|
-
helperDefinitionCount = 0;
|
|
64
|
-
modifierDefinitionCount = 0;
|
|
65
|
-
componentDefinitionCount = 0;
|
|
66
|
-
helperDefinitionCache = new WeakMap();
|
|
67
|
-
modifierDefinitionCache = new WeakMap();
|
|
68
|
-
componentDefinitionCache = new WeakMap();
|
|
69
45
|
helper(definitionState,
|
|
70
46
|
// TODO: Add a way to expose resolved name for debugging
|
|
71
47
|
_resolvedName = null, isOptional) {
|
|
@@ -73,7 +49,6 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
73
49
|
if (void 0 === handle) {
|
|
74
50
|
let managerOrHelper = getInternalHelperManager(definitionState, isOptional);
|
|
75
51
|
if (null === managerOrHelper) return this.helperDefinitionCache.set(definitionState, null), null;
|
|
76
|
-
debugAssert(managerOrHelper, "BUG: expected manager or helper");
|
|
77
52
|
let helper = "function" == typeof managerOrHelper ? managerOrHelper : managerOrHelper.getHelper(definitionState);
|
|
78
53
|
handle = this.value(helper), this.helperDefinitionCache.set(definitionState, handle), this.helperDefinitionCount++;
|
|
79
54
|
}
|
|
@@ -93,12 +68,11 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
93
68
|
}
|
|
94
69
|
return handle;
|
|
95
70
|
}
|
|
96
|
-
component(definitionState, owner, isOptional) {
|
|
71
|
+
component(definitionState, owner, isOptional, debugName) {
|
|
97
72
|
let definition = this.componentDefinitionCache.get(definitionState);
|
|
98
73
|
if (void 0 === definition) {
|
|
99
74
|
let manager = getInternalComponentManager(definitionState, isOptional);
|
|
100
75
|
if (null === manager) return this.componentDefinitionCache.set(definitionState, null), null;
|
|
101
|
-
debugAssert(manager, "BUG: expected manager");
|
|
102
76
|
let template,
|
|
103
77
|
capabilities = capabilityFlagsFrom(manager.getCapabilities(definitionState)),
|
|
104
78
|
templateFactory = getComponentTemplate(definitionState),
|
|
@@ -106,12 +80,11 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
106
80
|
template = managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout) ? templateFactory?.(owner) : templateFactory?.(owner) ?? this.defaultTemplate, void 0 !== template && (template = unwrapTemplate(template), compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout()), definition = {
|
|
107
81
|
resolvedName: null,
|
|
108
82
|
handle: -1,
|
|
109
|
-
// replaced momentarily
|
|
110
83
|
manager: manager,
|
|
111
84
|
capabilities: capabilities,
|
|
112
85
|
state: definitionState,
|
|
113
86
|
compilable: compilable
|
|
114
|
-
}, definition.handle = this.value(definition), this.componentDefinitionCache.set(definitionState, definition), this.componentDefinitionCount++;
|
|
87
|
+
}, definition.handle = this.value(definition), debugName && (definition.debugName = debugName), this.componentDefinitionCache.set(definitionState, definition), this.componentDefinitionCount++;
|
|
115
88
|
}
|
|
116
89
|
return definition;
|
|
117
90
|
}
|
|
@@ -128,17 +101,16 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
128
101
|
managerHasCapability(manager, capabilities, InternalComponentCapabilities.dynamicLayout) || (template = template ?? this.defaultTemplate), null !== template && (template = unwrapTemplate(template), compilable = managerHasCapability(manager, capabilities, InternalComponentCapabilities.wrapped) ? template.asWrappedLayout() : template.asLayout()), definition = {
|
|
129
102
|
resolvedName: resolvedName,
|
|
130
103
|
handle: -1,
|
|
131
|
-
// replaced momentarily
|
|
132
104
|
manager: manager,
|
|
133
105
|
capabilities: capabilities,
|
|
134
106
|
state: state,
|
|
135
107
|
compilable: compilable
|
|
136
108
|
}, definition.handle = this.value(definition), this.componentDefinitionCache.set(resolvedDefinition, definition), this.componentDefinitionCount++;
|
|
137
109
|
}
|
|
138
|
-
return
|
|
110
|
+
return definition;
|
|
139
111
|
}
|
|
140
112
|
getValue(index) {
|
|
141
|
-
return
|
|
113
|
+
return this.values[index];
|
|
142
114
|
}
|
|
143
115
|
getArray(index) {
|
|
144
116
|
let reifiedArrs = this.reifiedArrs,
|
|
@@ -151,11 +123,18 @@ class ConstantsImpl extends CompileTimeConstantImpl {
|
|
|
151
123
|
}
|
|
152
124
|
return reified;
|
|
153
125
|
}
|
|
126
|
+
constructor() {
|
|
127
|
+
this.reifiedArrs = {
|
|
128
|
+
[WELL_KNOWN_EMPTY_ARRAY_POSITION]: WELL_KNOWN_EMPTY_ARRAY
|
|
129
|
+
}, this.defaultTemplate = templateFactory(DEFAULT_TEMPLATE)(),
|
|
130
|
+
// Used for tests and debugging purposes, and to be able to analyze large apps
|
|
131
|
+
// This is why it's enabled even in production
|
|
132
|
+
this.helperDefinitionCount = 0, this.modifierDefinitionCount = 0, this.componentDefinitionCount = 0, this.values = STARTER_CONSTANTS.slice(), this.indexMap = new Map(this.values.map((value, index) => [value, index])), this.helperDefinitionCache = new WeakMap(), this.modifierDefinitionCache = new WeakMap(), this.componentDefinitionCache = new WeakMap();
|
|
133
|
+
}
|
|
154
134
|
}
|
|
155
135
|
class RuntimeOpImpl {
|
|
156
|
-
offset = 0;
|
|
157
136
|
constructor(heap) {
|
|
158
|
-
this.heap = heap;
|
|
137
|
+
this.heap = heap, this.offset = 0;
|
|
159
138
|
}
|
|
160
139
|
get size() {
|
|
161
140
|
return 1 + ((this.heap.getbyaddr(this.offset) & OPERAND_LEN_MASK) >> ARG_SHIFT);
|
|
@@ -176,38 +155,9 @@ class RuntimeOpImpl {
|
|
|
176
155
|
return this.heap.getbyaddr(this.offset + 3);
|
|
177
156
|
}
|
|
178
157
|
}
|
|
179
|
-
var TableSlotState = function (TableSlotState) {
|
|
180
|
-
return TableSlotState[TableSlotState.Allocated = 0] = "Allocated", TableSlotState[TableSlotState.Freed = 1] = "Freed", TableSlotState[TableSlotState.Purged = 2] = "Purged", TableSlotState[TableSlotState.Pointer = 3] = "Pointer", TableSlotState;
|
|
181
|
-
}(TableSlotState || {});
|
|
182
|
-
class RuntimeHeapImpl {
|
|
183
|
-
heap;
|
|
184
|
-
table;
|
|
185
|
-
constructor(serializedHeap) {
|
|
186
|
-
let {
|
|
187
|
-
buffer: buffer,
|
|
188
|
-
table: table
|
|
189
|
-
} = serializedHeap;
|
|
190
|
-
this.heap = new Int32Array(buffer), this.table = table;
|
|
191
|
-
}
|
|
192
|
-
// It is illegal to close over this address, as compaction
|
|
193
|
-
// may move it. However, it is legal to use this address
|
|
194
|
-
// multiple times between compactions.
|
|
195
|
-
getaddr(handle) {
|
|
196
|
-
return unwrap(this.table[handle]);
|
|
197
|
-
}
|
|
198
|
-
getbyaddr(address) {
|
|
199
|
-
return expect(this.heap[address], "Access memory out of bounds of the heap");
|
|
200
|
-
}
|
|
201
|
-
sizeof(handle) {
|
|
202
|
-
return this.table, -1;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function hydrateHeap(serializedHeap) {
|
|
206
|
-
return new RuntimeHeapImpl(serializedHeap);
|
|
207
|
-
}
|
|
208
158
|
|
|
209
159
|
/**
|
|
210
|
-
* The Heap is responsible for dynamically allocating
|
|
160
|
+
* The Program Heap is responsible for dynamically allocating
|
|
211
161
|
* memory in which we read/write the VM's instructions
|
|
212
162
|
* from/to. When we malloc we pass out a VMHandle, which
|
|
213
163
|
* is used as an indirect way of accessing the memory during
|
|
@@ -226,14 +176,12 @@ function hydrateHeap(serializedHeap) {
|
|
|
226
176
|
* valid during the execution. This means you cannot close
|
|
227
177
|
* over them as you will have a bad memory access exception.
|
|
228
178
|
*/
|
|
229
|
-
class
|
|
230
|
-
offset = 0;
|
|
231
|
-
heap;
|
|
232
|
-
handleTable;
|
|
233
|
-
handleState;
|
|
234
|
-
handle = 0;
|
|
179
|
+
class ProgramHeapImpl {
|
|
235
180
|
constructor() {
|
|
236
|
-
this.heap = new Int32Array(1048576), this.handleTable = [], this.handleState = [];
|
|
181
|
+
this.offset = 0, this.handle = 0, this.heap = new Int32Array(1048576), this.handleTable = [], this.handleState = [];
|
|
182
|
+
}
|
|
183
|
+
entries() {
|
|
184
|
+
return this.offset;
|
|
237
185
|
}
|
|
238
186
|
pushRaw(value) {
|
|
239
187
|
this.sizeCheck(), this.heap[this.offset++] = value;
|
|
@@ -254,7 +202,7 @@ class HeapImpl {
|
|
|
254
202
|
}
|
|
255
203
|
}
|
|
256
204
|
getbyaddr(address) {
|
|
257
|
-
return
|
|
205
|
+
return this.heap[address];
|
|
258
206
|
}
|
|
259
207
|
setbyaddr(address, value) {
|
|
260
208
|
this.heap[address] = value;
|
|
@@ -271,13 +219,13 @@ class HeapImpl {
|
|
|
271
219
|
// may move it. However, it is legal to use this address
|
|
272
220
|
// multiple times between compactions.
|
|
273
221
|
getaddr(handle) {
|
|
274
|
-
return
|
|
222
|
+
return this.handleTable[handle];
|
|
275
223
|
}
|
|
276
224
|
sizeof(handle) {
|
|
277
225
|
return this.handleTable, -1;
|
|
278
226
|
}
|
|
279
227
|
free(handle) {
|
|
280
|
-
this.handleState[handle] =
|
|
228
|
+
this.handleState[handle] = 1;
|
|
281
229
|
}
|
|
282
230
|
/**
|
|
283
231
|
* The heap uses the [Mark-Compact Algorithm](https://en.wikipedia.org/wiki/Mark-compact_algorithm) to shift
|
|
@@ -294,37 +242,22 @@ class HeapImpl {
|
|
|
294
242
|
heap: heap
|
|
295
243
|
} = this;
|
|
296
244
|
for (let i = 0; i < length; i++) {
|
|
297
|
-
let offset =
|
|
298
|
-
size =
|
|
245
|
+
let offset = handleTable[i],
|
|
246
|
+
size = handleTable[i + 1] - offset,
|
|
299
247
|
state = handleState[i];
|
|
300
|
-
if (
|
|
248
|
+
if (2 !== state) if (1 === state)
|
|
301
249
|
// transition to "already freed" aka "purged"
|
|
302
250
|
// a good improvement would be to reuse
|
|
303
251
|
// these slots
|
|
304
|
-
handleState[i] =
|
|
305
|
-
for (let j = offset; j <= i + size; j++) heap[j - compactedSize] =
|
|
252
|
+
handleState[i] = 2, compactedSize += size;else if (0 === state) {
|
|
253
|
+
for (let j = offset; j <= i + size; j++) heap[j - compactedSize] = heap[j];
|
|
306
254
|
handleTable[i] = offset - compactedSize;
|
|
307
|
-
} else
|
|
255
|
+
} else 3 === state && (handleTable[i] = offset - compactedSize);
|
|
308
256
|
}
|
|
309
257
|
this.offset = this.offset - compactedSize;
|
|
310
258
|
}
|
|
311
|
-
capture(offset = this.offset) {
|
|
312
|
-
// Only called in eager mode
|
|
313
|
-
let buffer = function (arr, start, end) {
|
|
314
|
-
if (void 0 !== arr.slice) return arr.slice(start, end);
|
|
315
|
-
let ret = new Int32Array(end);
|
|
316
|
-
for (; start < end; start++) ret[start] = unwrap(arr[start]);
|
|
317
|
-
return ret;
|
|
318
|
-
}(this.heap, 0, offset).buffer;
|
|
319
|
-
return {
|
|
320
|
-
handle: this.handle,
|
|
321
|
-
table: this.handleTable,
|
|
322
|
-
buffer: buffer
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
259
|
}
|
|
326
|
-
class
|
|
327
|
-
_opcode;
|
|
260
|
+
class ProgramImpl {
|
|
328
261
|
constructor(constants, heap) {
|
|
329
262
|
this.constants = constants, this.heap = heap, this._opcode = new RuntimeOpImpl(this.heap);
|
|
330
263
|
}
|
|
@@ -335,8 +268,8 @@ class RuntimeProgramImpl {
|
|
|
335
268
|
function artifacts() {
|
|
336
269
|
return {
|
|
337
270
|
constants: new ConstantsImpl(),
|
|
338
|
-
heap: new
|
|
271
|
+
heap: new ProgramHeapImpl()
|
|
339
272
|
};
|
|
340
273
|
}
|
|
341
274
|
|
|
342
|
-
export {
|
|
275
|
+
export { ConstantsImpl, ProgramHeapImpl, ProgramImpl, RuntimeOpImpl, artifacts };
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import { setProp, getProp, toIterator, getPath } from '../global-context/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import { CONSTANT_TAG, validateTag, track, valueForTag, consumeTag, dirtyTag as DIRTY_TAG,
|
|
2
|
+
import { isDict, EMPTY_ARRAY, isIndexable } from '../util/index.js';
|
|
3
|
+
import { CONSTANT_TAG, validateTag, track, valueForTag, consumeTag, createTag, dirtyTag as DIRTY_TAG, INITIAL } from '../validator/index.js';
|
|
4
4
|
import { isDevelopingApp } from '@embroider/macros';
|
|
5
5
|
|
|
6
|
-
const REFERENCE = Symbol("REFERENCE")
|
|
7
|
-
COMPUTE = 1,
|
|
8
|
-
UNBOUND = 2;
|
|
9
|
-
|
|
10
|
-
//////////
|
|
6
|
+
const REFERENCE = Symbol("REFERENCE");
|
|
11
7
|
class ReferenceImpl {
|
|
12
|
-
[REFERENCE];
|
|
13
|
-
tag = null;
|
|
14
|
-
lastRevision = INITIAL;
|
|
15
|
-
lastValue;
|
|
16
|
-
children = null;
|
|
17
|
-
compute = null;
|
|
18
|
-
update = null;
|
|
19
|
-
debugLabel;
|
|
20
8
|
constructor(type) {
|
|
21
|
-
this[REFERENCE] = type;
|
|
9
|
+
this.tag = null, this.lastRevision = INITIAL, this.children = null, this.compute = null, this.update = null, this[REFERENCE] = type;
|
|
22
10
|
}
|
|
23
11
|
}
|
|
24
12
|
function createPrimitiveRef(value) {
|
|
25
|
-
const ref = new ReferenceImpl(
|
|
13
|
+
const ref = new ReferenceImpl(2);
|
|
26
14
|
return ref.tag = CONSTANT_TAG, ref.lastValue = value, isDevelopingApp() && (ref.debugLabel = String(value)), ref;
|
|
27
15
|
}
|
|
28
16
|
const UNDEFINED_REFERENCE = createPrimitiveRef(void 0),
|
|
@@ -34,11 +22,11 @@ function createConstRef(value, debugLabel) {
|
|
|
34
22
|
return ref.lastValue = value, ref.tag = CONSTANT_TAG, isDevelopingApp() && (ref.debugLabel = debugLabel), ref;
|
|
35
23
|
}
|
|
36
24
|
function createUnboundRef(value, debugLabel) {
|
|
37
|
-
const ref = new ReferenceImpl(
|
|
25
|
+
const ref = new ReferenceImpl(2);
|
|
38
26
|
return ref.lastValue = value, ref.tag = CONSTANT_TAG, isDevelopingApp() && (ref.debugLabel = debugLabel), ref;
|
|
39
27
|
}
|
|
40
28
|
function createComputeRef(compute, update = null, debugLabel = "unknown") {
|
|
41
|
-
const ref = new ReferenceImpl(
|
|
29
|
+
const ref = new ReferenceImpl(1);
|
|
42
30
|
return ref.compute = compute, ref.update = update, isDevelopingApp() && (ref.debugLabel = `(result of a \`${debugLabel}\` helper)`), ref;
|
|
43
31
|
}
|
|
44
32
|
function createReadOnlyRef(ref) {
|
|
@@ -72,6 +60,7 @@ function valueForRef(_ref) {
|
|
|
72
60
|
compute: compute
|
|
73
61
|
} = ref,
|
|
74
62
|
newTag = track(() => {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
75
64
|
lastValue = ref.lastValue = compute();
|
|
76
65
|
}, isDevelopingApp() && ref.debugLabel);
|
|
77
66
|
tag = ref.tag = newTag, ref.lastRevision = valueForTag(newTag);
|
|
@@ -79,15 +68,18 @@ function valueForRef(_ref) {
|
|
|
79
68
|
return consumeTag(tag), lastValue;
|
|
80
69
|
}
|
|
81
70
|
function updateRef(_ref, value) {
|
|
82
|
-
|
|
71
|
+
(0, _ref.update)(value);
|
|
83
72
|
}
|
|
84
73
|
function childRefFor(_parentRef, path) {
|
|
85
74
|
const parentRef = _parentRef,
|
|
86
75
|
type = parentRef[REFERENCE];
|
|
87
76
|
let child,
|
|
88
77
|
children = parentRef.children;
|
|
89
|
-
if (null === children) children = parentRef.children = new Map();else
|
|
90
|
-
|
|
78
|
+
if (null === children) children = parentRef.children = new Map();else {
|
|
79
|
+
const next = children.get(path);
|
|
80
|
+
if (next) return next;
|
|
81
|
+
}
|
|
82
|
+
if (2 === type) {
|
|
91
83
|
const parent = valueForRef(parentRef);
|
|
92
84
|
child = isDict(parent) ? createUnboundRef(parent[path], isDevelopingApp() && `${parentRef.debugLabel}.${path}`) : UNDEFINED_REFERENCE;
|
|
93
85
|
} else child = createComputeRef(() => {
|
|
@@ -114,8 +106,6 @@ const NULL_IDENTITY = {},
|
|
|
114
106
|
INDEX = (_, index) => String(index),
|
|
115
107
|
IDENTITY = item => null === item ? NULL_IDENTITY : item;
|
|
116
108
|
class WeakMapWithPrimitives {
|
|
117
|
-
_weakMap;
|
|
118
|
-
_primitiveMap;
|
|
119
109
|
get weakMap() {
|
|
120
110
|
return void 0 === this._weakMap && (this._weakMap = new WeakMap()), this._weakMap;
|
|
121
111
|
}
|
|
@@ -123,10 +113,10 @@ class WeakMapWithPrimitives {
|
|
|
123
113
|
return void 0 === this._primitiveMap && (this._primitiveMap = new Map()), this._primitiveMap;
|
|
124
114
|
}
|
|
125
115
|
set(key, value) {
|
|
126
|
-
|
|
116
|
+
isIndexable(key) ? this.weakMap.set(key, value) : this.primitiveMap.set(key, value);
|
|
127
117
|
}
|
|
128
118
|
get(key) {
|
|
129
|
-
return
|
|
119
|
+
return isIndexable(key) ? this.weakMap.get(key) : this.primitiveMap.get(key);
|
|
130
120
|
}
|
|
131
121
|
}
|
|
132
122
|
const IDENTITIES = new WeakMapWithPrimitives();
|
|
@@ -164,6 +154,7 @@ function uniqueKeyFor(keyFor) {
|
|
|
164
154
|
}
|
|
165
155
|
function createIteratorRef(listRef, key) {
|
|
166
156
|
return createComputeRef(() => {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
167
158
|
let iterable = valueForRef(listRef),
|
|
168
159
|
keyFor = function (key) {
|
|
169
160
|
switch (key) {
|
|
@@ -205,10 +196,8 @@ class IteratorWrapper {
|
|
|
205
196
|
}
|
|
206
197
|
}
|
|
207
198
|
class ArrayIterator {
|
|
208
|
-
current;
|
|
209
|
-
pos = 0;
|
|
210
199
|
constructor(iterator, keyFor) {
|
|
211
|
-
this.iterator = iterator, this.keyFor = keyFor, 0 === iterator.length ? this.current = {
|
|
200
|
+
this.iterator = iterator, this.keyFor = keyFor, this.pos = 0, 0 === iterator.length ? this.current = {
|
|
212
201
|
kind: "empty"
|
|
213
202
|
} : this.current = {
|
|
214
203
|
kind: "first",
|