@motionscript/core 0.1.0-alpha.9 → 0.1.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/CHANGELOG.md +19 -0
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +20 -5
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/browser/chunks/chunk-CCGVIR4F.js +3 -0
- package/dist/browser/chunks/chunk-CCGVIR4F.js.map +7 -0
- package/dist/browser/chunks/chunk-N4WSN5WY.js +13 -0
- package/dist/browser/chunks/chunk-N4WSN5WY.js.map +7 -0
- package/dist/browser/chunks/chunk-WZSI3GSK.js +6 -0
- package/dist/browser/chunks/{chunk-7DB6BI27.js.map → chunk-WZSI3GSK.js.map} +4 -4
- package/dist/browser/component.js +1 -1
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/components/factory/views.d.ts.map +1 -1
- package/dist/components/factory/views.js +41 -1
- package/dist/components/factory/views.js.map +1 -1
- package/dist/components/trees/node/node-reactive.d.ts +3 -4
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -1
- package/dist/components/trees/node/node-reactive.js +13 -10
- package/dist/components/trees/node/node-reactive.js.map +1 -1
- package/dist/document/command-traits.d.ts +8 -0
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +17 -0
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/settled-index.d.ts +6 -0
- package/dist/document/settled-index.d.ts.map +1 -1
- package/dist/document/settled-index.js +18 -1
- package/dist/document/settled-index.js.map +1 -1
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +26 -6
- package/dist/document/timeline.js.map +1 -1
- package/dist/props/host.d.ts +5 -0
- package/dist/props/host.d.ts.map +1 -1
- package/dist/props/host.js +3 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/layout.d.ts +29 -0
- package/dist/props/layout.d.ts.map +1 -0
- package/dist/props/layout.js +84 -0
- package/dist/props/layout.js.map +1 -0
- package/package.json +1 -1
- package/dist/browser/chunks/chunk-7DB6BI27.js +0 -6
- package/dist/browser/chunks/chunk-IX53IFBD.js +0 -13
- package/dist/browser/chunks/chunk-IX53IFBD.js.map +0 -7
- package/dist/browser/chunks/chunk-Q55UPA3E.js +0 -3
- package/dist/browser/chunks/chunk-Q55UPA3E.js.map +0 -7
package/dist/props/host.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PropLayout } from "./layout.js";
|
|
1
2
|
import { PropSlot } from "./slot.js";
|
|
2
3
|
/** @internal */
|
|
3
4
|
export type TweenFn<T> = (from: T, to: T, t: number) => T;
|
|
@@ -15,6 +16,10 @@ export type TweenFn<T> = (from: T, to: T, t: number) => T;
|
|
|
15
16
|
export interface PropCells {
|
|
16
17
|
/** Field → its live slot. Present for every registered prop. */
|
|
17
18
|
slots: Map<string, PropSlot<any>>;
|
|
19
|
+
/** The host class's prop indices; {@link list} holds its slots by them. */
|
|
20
|
+
layout: PropLayout;
|
|
21
|
+
/** Field → its slot, by {@link layout} index: what the prop accessors read. */
|
|
22
|
+
list: (PropSlot<any> | undefined)[];
|
|
18
23
|
/** Field → how it interpolates, for props a numeric lerp cannot cover. */
|
|
19
24
|
tweens?: Map<string, TweenFn<any>>;
|
|
20
25
|
/** Field → external prop value to internal slot value, for fields that need it. */
|
package/dist/props/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/props/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,gBAAgB;AAChB,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KA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,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IACpC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,mFAAmF;IACnF,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;CACxD;AAED,gBAAgB;AAChB,MAAM,WAAW,QAAQ;IACrB;kCAC8B;IAC9B,OAAO,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,gBAAgB;AAChB,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAElF;AAED,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,CAGpD"}
|
package/dist/props/host.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { PropLayout } from "./layout.js";
|
|
1
2
|
/** @internal */
|
|
2
3
|
export function getPropSlot(obj, name) {
|
|
3
4
|
return obj.__cells?.slots.get(name);
|
|
4
5
|
}
|
|
5
6
|
/** The host's slots, created on first use. @internal */
|
|
6
7
|
export function ensureCells(obj) {
|
|
7
|
-
|
|
8
|
+
// Every field from the start, so all cells share one shape and the prop accessors' reads of them stay monomorphic.
|
|
9
|
+
return obj.__cells ??= { slots: new Map(), layout: PropLayout.of(Object.getPrototypeOf(obj)), list: [], tweens: undefined, mappers: undefined };
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=host.js.map
|
package/dist/props/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/props/host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/props/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAqCtC,gBAAgB;AAChB,MAAM,UAAU,WAAW,CAAC,GAAa,EAAE,IAAY;IACnD,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,WAAW,CAAC,GAAa;IACrC,mHAAmH;IACnH,OAAO,GAAG,CAAC,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAW,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC9J,CAAC","sourcesContent":["import { PropLayout } from \"./layout\";\nimport { PropSlot } from \"./slot\";\n\n/** @internal */\nexport type TweenFn<T> = (from: T, to: T, t: number) => T;\n\n/**\n * The slots behind an object's `property`-declared fields, plus the per-field\n * metadata `set()` and `to()` route through.\n *\n * One object rather than three loose maps on the host, because the host is a\n * `Node` and every public field it carries is published API. Grouping them\n * means a node exposes one internal name instead of three, and gives the thing\n * a name a reader can look up.\n *\n * @internal\n */\nexport interface PropCells {\n /** Field → its live slot. Present for every registered prop. */\n slots: Map<string, PropSlot<any>>;\n /** The host class's prop indices; {@link list} holds its slots by them. */\n layout: PropLayout;\n /** Field → its slot, by {@link layout} index: what the prop accessors read. */\n list: (PropSlot<any> | undefined)[];\n /** Field → how it interpolates, for props a numeric lerp cannot cover. */\n tweens?: Map<string, TweenFn<any>>;\n /** Field → external prop value to internal slot value, for fields that need it. */\n mappers?: Map<string, (ext: any, prev?: any) => any>;\n}\n\n/** @internal */\nexport interface PropHost {\n /** See {@link PropCells}. Absent until the first prop is registered, and\n * cleared by `dispose()`. */\n __cells?: PropCells;\n}\n\n/** @internal */\nexport function getPropSlot(obj: PropHost, name: string): PropSlot<any> | undefined {\n return obj.__cells?.slots.get(name);\n}\n\n/** The host's slots, created on first use. @internal */\nexport function ensureCells(obj: PropHost): PropCells {\n // Every field from the start, so all cells share one shape and the prop accessors' reads of them stay monomorphic.\n return obj.__cells ??= { slots: new Map(), layout: PropLayout.of(Object.getPrototypeOf(obj) as object), list: [], tweens: undefined, mappers: undefined };\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where each prop of one node class sits in its instances' slot lists, and the
|
|
3
|
+
* accessors that read it, defined once on the class's prototype.
|
|
4
|
+
*
|
|
5
|
+
* On the prototype rather than on each instance, so every node of a type shares
|
|
6
|
+
* one hidden class and a prop read in layout or render stays monomorphic. The
|
|
7
|
+
* accessors reach their slot by index: closures made at one site share their
|
|
8
|
+
* feedback, so a lookup by name inside one would see every prop of every class.
|
|
9
|
+
*
|
|
10
|
+
* An instance that has not registered a field, or a prototype that already
|
|
11
|
+
* defines one itself, reads and writes as if the accessor were not there.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PropLayout {
|
|
14
|
+
private readonly _proto;
|
|
15
|
+
static of(proto: object): PropLayout;
|
|
16
|
+
/** `field`'s index, or -1 when no instance has registered it. */
|
|
17
|
+
indexOf(field: string): number;
|
|
18
|
+
/** `field`'s index, given its accessor the first time any instance registers it. */
|
|
19
|
+
place(field: string): number;
|
|
20
|
+
/** Whether reading `field` on `host` reaches this layout's accessor. */
|
|
21
|
+
serves(host: object, field: string): boolean;
|
|
22
|
+
private constructor();
|
|
23
|
+
private readonly _parent;
|
|
24
|
+
private readonly _index;
|
|
25
|
+
private readonly _foreign;
|
|
26
|
+
private _getter;
|
|
27
|
+
private _setter;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/props/layout.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;IAmCC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAlC3C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAMpC,iEAAiE;IACjE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI9B,oFAAoF;IACpF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAiB5B,wEAAwE;IACxE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAI5C,OAAO;IAIP,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAE9C,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,OAAO;CAclB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const LAYOUTS = new WeakMap();
|
|
2
|
+
/**
|
|
3
|
+
* Where each prop of one node class sits in its instances' slot lists, and the
|
|
4
|
+
* accessors that read it, defined once on the class's prototype.
|
|
5
|
+
*
|
|
6
|
+
* On the prototype rather than on each instance, so every node of a type shares
|
|
7
|
+
* one hidden class and a prop read in layout or render stays monomorphic. The
|
|
8
|
+
* accessors reach their slot by index: closures made at one site share their
|
|
9
|
+
* feedback, so a lookup by name inside one would see every prop of every class.
|
|
10
|
+
*
|
|
11
|
+
* An instance that has not registered a field, or a prototype that already
|
|
12
|
+
* defines one itself, reads and writes as if the accessor were not there.
|
|
13
|
+
*/
|
|
14
|
+
export class PropLayout {
|
|
15
|
+
_proto;
|
|
16
|
+
static of(proto) {
|
|
17
|
+
let layout = LAYOUTS.get(proto);
|
|
18
|
+
if (!layout)
|
|
19
|
+
LAYOUTS.set(proto, (layout = new PropLayout(proto)));
|
|
20
|
+
return layout;
|
|
21
|
+
}
|
|
22
|
+
/** `field`'s index, or -1 when no instance has registered it. */
|
|
23
|
+
indexOf(field) {
|
|
24
|
+
return this._index.get(field) ?? -1;
|
|
25
|
+
}
|
|
26
|
+
/** `field`'s index, given its accessor the first time any instance registers it. */
|
|
27
|
+
place(field) {
|
|
28
|
+
let i = this._index.get(field);
|
|
29
|
+
if (i !== undefined)
|
|
30
|
+
return i;
|
|
31
|
+
this._index.set(field, (i = this._index.size));
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(this._proto, field)) {
|
|
33
|
+
this._foreign.add(field);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
Object.defineProperty(this._proto, field, {
|
|
37
|
+
get: this._getter(i, field),
|
|
38
|
+
set: this._setter(i, field),
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return i;
|
|
44
|
+
}
|
|
45
|
+
/** Whether reading `field` on `host` reaches this layout's accessor. */
|
|
46
|
+
serves(host, field) {
|
|
47
|
+
return !this._foreign.has(field) && !Object.prototype.hasOwnProperty.call(host, field);
|
|
48
|
+
}
|
|
49
|
+
constructor(_proto) {
|
|
50
|
+
this._proto = _proto;
|
|
51
|
+
this._parent = Object.getPrototypeOf(_proto);
|
|
52
|
+
}
|
|
53
|
+
_parent;
|
|
54
|
+
_index = new Map();
|
|
55
|
+
_foreign = new Set();
|
|
56
|
+
_getter(i, field) {
|
|
57
|
+
const layout = this;
|
|
58
|
+
const parent = this._parent;
|
|
59
|
+
return function () {
|
|
60
|
+
const cells = this.__cells;
|
|
61
|
+
const slot = cells !== undefined && cells.layout === layout ? cells.list[i] : undefined;
|
|
62
|
+
if (slot !== undefined)
|
|
63
|
+
return slot.get();
|
|
64
|
+
return parent === null ? undefined : Reflect.get(parent, field, this);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
_setter(i, field) {
|
|
68
|
+
const layout = this;
|
|
69
|
+
const parent = this._parent;
|
|
70
|
+
return function (value) {
|
|
71
|
+
const cells = this.__cells;
|
|
72
|
+
if (cells !== undefined && cells.layout === layout && cells.list[i] !== undefined) {
|
|
73
|
+
this._writeProp(field, value);
|
|
74
|
+
}
|
|
75
|
+
else if (parent !== null) {
|
|
76
|
+
Reflect.set(parent, field, value, this);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
Object.defineProperty(this, field, { value, writable: true, enumerable: true, configurable: true });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/props/layout.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAsB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,UAAU;IAmCkB;IAlCrC,MAAM,CAAC,EAAE,CAAC,KAAa;QACnB,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,iEAAiE;IACjE,OAAO,CAAC,KAAa;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,oFAAoF;IACpF,KAAK,CAAC,KAAa;QACf,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC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M,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACxF,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;YAC1C,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC,CAAC;IACN,CAAC;IAEO,OAAO,CAAC,CAAS,EAAE,KAAa;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,OAAO,UAAU,KAAK;YAClB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;YAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBAChF,IAAI,CAAC,UAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;iBAAM,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YACxG,CAAC;QACL,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { PropSlot } from \"./slot\";\n\n/** What a prop accessor reads its slots from and writes through. */\ninterface LaidOutHost {\n __cells?: { layout: PropLayout; list: readonly (PropSlot<unknown> | undefined)[] };\n _writeProp?(field: string, value: unknown): void;\n}\n\nconst LAYOUTS = new WeakMap<object, PropLayout>();\n\n/**\n * Where each prop of one node class sits in its instances' slot lists, and the\n * accessors that read it, defined once on the class's prototype.\n *\n * On the prototype rather than on each instance, so every node of a type shares\n * one hidden class and a prop read in layout or render stays monomorphic. The\n * accessors reach their slot by index: closures made at one site share their\n * feedback, so a lookup by name inside one would see every prop of every class.\n *\n * An instance that has not registered a field, or a prototype that already\n * defines one itself, reads and writes as if the accessor were not there.\n */\nexport class PropLayout {\n static of(proto: object): PropLayout {\n let layout = LAYOUTS.get(proto);\n if (!layout) LAYOUTS.set(proto, (layout = new PropLayout(proto)));\n return layout;\n }\n\n /** `field`'s index, or -1 when no instance has registered it. */\n indexOf(field: string): number {\n return this._index.get(field) ?? -1;\n }\n\n /** `field`'s index, given its accessor the first time any instance registers it. */\n place(field: string): number {\n let i = this._index.get(field);\n if (i !== undefined) return i;\n this._index.set(field, (i = this._index.size));\n if (Object.prototype.hasOwnProperty.call(this._proto, field)) {\n this._foreign.add(field);\n } else {\n Object.defineProperty(this._proto, field, {\n get: this._getter(i, field),\n set: this._setter(i, field),\n enumerable: true,\n configurable: true,\n });\n }\n return i;\n }\n\n /** Whether reading `field` on `host` reaches this layout's accessor. */\n serves(host: object, field: string): boolean {\n return !this._foreign.has(field) && !Object.prototype.hasOwnProperty.call(host, field);\n }\n\n private constructor(private readonly _proto: object) {\n this._parent = Object.getPrototypeOf(_proto) as object | null;\n }\n\n private readonly _parent: object | null;\n private readonly _index = new Map<string, number>();\n private readonly _foreign = new Set<string>();\n\n private _getter(i: number, field: string): (this: LaidOutHost) => unknown {\n const layout = this;\n const parent = this._parent;\n return function () {\n const cells = this.__cells;\n const slot = cells !== undefined && cells.layout === layout ? cells.list[i] : undefined;\n if (slot !== undefined) return slot.get();\n return parent === null ? undefined : Reflect.get(parent, field, this);\n };\n }\n\n private _setter(i: number, field: string): (this: LaidOutHost, value: unknown) => void {\n const layout = this;\n const parent = this._parent;\n return function (value) {\n const cells = this.__cells;\n if (cells !== undefined && cells.layout === layout && cells.list[i] !== undefined) {\n this._writeProp!(field, value);\n } else if (parent !== null) {\n Reflect.set(parent, field, value, this);\n } else {\n Object.defineProperty(this, field, { value, writable: true, enumerable: true, configurable: true });\n }\n };\n }\n}\n"]}
|