@runopencode/rx-stencil 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-CbERigo8.js → index-DWhjpI-K.js} +396 -41
- package/dist/{esm/set-property-CpZKE-Xu.js → cjs/index-Dssn3hdS.js} +2 -61
- package/dist/cjs/index.cjs.js +280 -244
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mutation-observable-qY7nC854.js +152 -0
- package/dist/cjs/properties-observable-DXbVBslA.js +23 -0
- package/dist/cjs/property-observable-CPp5WEjC.js +86 -0
- package/dist/cjs/rx-async.cjs.entry.js +21 -14
- package/dist/cjs/rx-stencil.cjs.js +3 -3
- package/dist/cjs/schedule-render-DG4hFv5E.js +53 -0
- package/dist/cjs/set-property-C3KARzdl.js +33 -0
- package/dist/cjs/stencil-uD4ZIy1h.js +75 -0
- package/dist/cjs/test-properties-observable.cjs.entry.js +27 -0
- package/dist/cjs/test-property-observable.cjs.entry.js +31 -0
- package/dist/cjs/test-schedule-render.cjs.entry.js +28 -0
- package/dist/cjs/test-view-child-observable-shadow-dom.cjs.entry.js +40 -0
- package/dist/cjs/until-disconnected-BTCr-3q2.js +27 -0
- package/dist/collection/collection-manifest.json +9 -2
- package/dist/collection/components/async/async.js +42 -10
- package/dist/collection/components/index.js +1 -1
- package/dist/collection/rx/decorator/content-child.js +34 -0
- package/dist/collection/rx/decorator/content-children.js +34 -0
- package/dist/collection/rx/decorator/index.js +6 -2
- package/dist/collection/rx/decorator/query-selector-all.js +6 -38
- package/dist/collection/rx/decorator/query-selector.js +6 -51
- package/dist/collection/rx/decorator/view-child.js +34 -0
- package/dist/collection/rx/decorator/view-children.js +34 -0
- package/dist/collection/rx/index.js +1 -0
- package/dist/collection/rx/observable/connected-observable.js +27 -0
- package/dist/collection/rx/observable/content-child-observable.js +24 -0
- package/dist/collection/rx/observable/content-children-observable.js +15 -0
- package/dist/collection/rx/observable/from-event.js +26 -0
- package/dist/collection/rx/observable/index.js +9 -4
- package/dist/collection/rx/observable/mutation-observable.js +6 -0
- package/dist/collection/rx/observable/properties-observable.js +5 -0
- package/dist/collection/rx/observable/property-observable.js +72 -17
- package/dist/collection/rx/observable/render-observable.js +18 -9
- package/dist/collection/rx/observable/view-child-observable.js +30 -0
- package/dist/collection/rx/observable/view-children-observable.js +21 -0
- package/dist/collection/rx/operator/index.js +4 -3
- package/dist/collection/rx/operator/to-property.js +7 -7
- package/dist/collection/rx/operator/until-disconnected.js +12 -94
- package/dist/collection/rx/operator/while-connected.js +39 -0
- package/dist/collection/rx/subscriber/index.js +1 -1
- package/dist/collection/rx/subscriber/set-property.js +13 -0
- package/dist/collection/rx/types.js +1 -0
- package/dist/collection/tests/rx/observable/from-event/test-from-event.component.js +30 -0
- package/dist/collection/tests/rx/observable/properties-observable/test-properties-observable.component.js +85 -0
- package/dist/collection/tests/rx/observable/property-observable/test-property-observable.component.js +47 -0
- package/dist/collection/tests/rx/observable/render-observable.unit.js +38 -0
- package/dist/collection/tests/rx/observable/view-child-observable/test-view-child-observable-shadow-dom.component.js +96 -0
- package/dist/collection/tests/rx/operator/schedule-render/test-schedule-render.component.js +42 -0
- package/dist/collection/tests/rx/operator/to-property.unit.js +28 -0
- package/dist/collection/tests/rx/operator/until-disconnected.unit.js +25 -0
- package/dist/collection/tests/rx/operator/while-connected/test-while-connected.component.js +32 -0
- package/dist/collection/tests/rx/subscriber/set-property.unit.js +53 -0
- package/dist/collection/utils/decorator.js +33 -0
- package/dist/collection/utils/index.js +1 -1
- package/dist/collection/utils/rxjs.js +67 -0
- package/dist/collection/utils/stencil.js +66 -0
- package/dist/collection/utils/values-registry.js +40 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +1 -0
- package/dist/components/mutation-observable.js +1 -0
- package/dist/components/properties-observable.js +1 -0
- package/dist/components/property-observable.js +1 -0
- package/dist/components/rx-async.js +1 -1
- package/dist/components/schedule-render.js +1 -0
- package/dist/components/set-property.js +1 -1
- package/dist/components/stencil.js +1 -0
- package/dist/components/test-properties-observable.d.ts +11 -0
- package/dist/components/test-properties-observable.js +1 -0
- package/dist/components/test-property-observable.d.ts +11 -0
- package/dist/components/test-property-observable.js +1 -0
- package/dist/components/test-schedule-render.d.ts +11 -0
- package/dist/components/test-schedule-render.js +1 -0
- package/dist/components/test-view-child-observable-shadow-dom.d.ts +11 -0
- package/dist/components/test-view-child-observable-shadow-dom.js +1 -0
- package/dist/components/until-disconnected.js +1 -0
- package/dist/esm/{index-BIBww8qU.js → index-BCGlW-2C.js} +396 -42
- package/dist/{cjs/set-property-BZHuI0P5.js → esm/index-Bn8mRT4P.js} +1 -67
- package/dist/esm/index.js +266 -240
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mutation-observable-xA7xgk29.js +145 -0
- package/dist/esm/properties-observable-Bzq-rZ4c.js +21 -0
- package/dist/esm/property-observable-BKyQe0OR.js +84 -0
- package/dist/esm/rx-async.entry.js +18 -11
- package/dist/esm/rx-stencil.js +4 -4
- package/dist/esm/schedule-render-BGCI5FMG.js +50 -0
- package/dist/esm/set-property-CgrvJ28c.js +31 -0
- package/dist/esm/stencil-BQCAKjCT.js +68 -0
- package/dist/esm/test-properties-observable.entry.js +25 -0
- package/dist/esm/test-property-observable.entry.js +29 -0
- package/dist/esm/test-schedule-render.entry.js +26 -0
- package/dist/esm/test-view-child-observable-shadow-dom.entry.js +38 -0
- package/dist/esm/until-disconnected-D2pF81SM.js +25 -0
- package/dist/rx-stencil/index.esm.js +1 -1
- package/dist/rx-stencil/p-7c570c65.entry.js +1 -0
- package/dist/rx-stencil/p-BCGlW-2C.js +3 -0
- package/dist/rx-stencil/p-BLLg2g3n.js +1 -0
- package/dist/rx-stencil/p-BQCAKjCT.js +1 -0
- package/dist/rx-stencil/p-Bn8mRT4P.js +1 -0
- package/dist/rx-stencil/p-D1zETqVV.js +1 -0
- package/dist/rx-stencil/p-DHIVm3-O.js +1 -0
- package/dist/rx-stencil/p-J0xLdrjW.js +1 -0
- package/dist/rx-stencil/p-Sf5sf4Pq.js +1 -0
- package/dist/rx-stencil/p-a4c71f45.entry.js +1 -0
- package/dist/rx-stencil/p-b2c6ba01.entry.js +1 -0
- package/dist/rx-stencil/p-dc654207.entry.js +1 -0
- package/dist/rx-stencil/p-e661490a.entry.js +1 -0
- package/dist/rx-stencil/p-wVeMJABH.js +1 -0
- package/dist/rx-stencil/rx-stencil.esm.js +1 -1
- package/dist/types/components/async/async.d.ts +9 -2
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components.d.ts +92 -2
- package/dist/types/rx/decorator/content-child.d.ts +3 -0
- package/dist/types/rx/decorator/content-children.d.ts +3 -0
- package/dist/types/rx/decorator/index.d.ts +6 -2
- package/dist/types/rx/decorator/query-selector-all.d.ts +7 -21
- package/dist/types/rx/decorator/query-selector.d.ts +7 -29
- package/dist/types/rx/decorator/view-child.d.ts +27 -0
- package/dist/types/rx/decorator/view-children.d.ts +11 -0
- package/dist/types/rx/index.d.ts +1 -0
- package/dist/types/rx/observable/connected-observable.d.ts +9 -0
- package/dist/types/rx/observable/content-child-observable.d.ts +5 -0
- package/dist/types/rx/observable/content-children-observable.d.ts +5 -0
- package/dist/types/rx/observable/from-event.d.ts +26 -0
- package/dist/types/rx/observable/index.d.ts +9 -4
- package/dist/types/rx/observable/mutation-observable.d.ts +6 -0
- package/dist/types/rx/observable/properties-observable.d.ts +5 -0
- package/dist/types/rx/observable/property-observable.d.ts +1 -1
- package/dist/types/rx/observable/render-observable.d.ts +6 -1
- package/dist/types/rx/observable/view-child-observable.d.ts +17 -0
- package/dist/types/rx/observable/view-children-observable.d.ts +5 -0
- package/dist/types/rx/operator/index.d.ts +4 -3
- package/dist/types/rx/operator/to-property.d.ts +1 -3
- package/dist/types/rx/operator/while-connected.d.ts +22 -0
- package/dist/types/rx/subscriber/index.d.ts +1 -1
- package/dist/types/rx/subscriber/set-property.d.ts +13 -0
- package/dist/types/rx/types.d.ts +12 -0
- package/dist/types/stencil-public-runtime.d.ts +74 -55
- package/dist/types/tests/rx/observable/properties-observable/test-properties-observable.component.d.ts +9 -0
- package/dist/types/tests/rx/observable/property-observable/test-property-observable.component.d.ts +8 -0
- package/dist/types/tests/rx/observable/render-observable.unit.d.ts +1 -0
- package/dist/types/tests/rx/observable/view-child-observable/test-view-child-observable-shadow-dom.component.d.ts +12 -0
- package/dist/types/tests/rx/operator/schedule-render/test-schedule-render.component.d.ts +7 -0
- package/dist/types/tests/rx/operator/to-property.unit.d.ts +1 -0
- package/dist/types/tests/rx/operator/until-disconnected.unit.d.ts +1 -0
- package/dist/types/tests/rx/subscriber/set-property.unit.d.ts +1 -0
- package/dist/types/utils/decorator.d.ts +11 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/rxjs.d.ts +31 -0
- package/dist/types/utils/stencil.d.ts +54 -0
- package/dist/types/utils/values-registry.d.ts +10 -0
- package/loader/index.d.ts +1 -1
- package/package.json +19 -10
- package/dist/collection/utils/get-property-descriptor.js +0 -17
- package/dist/rx-stencil/p-77100dee.entry.js +0 -1
- package/dist/rx-stencil/p-BIBww8qU.js +0 -2
- package/dist/rx-stencil/p-IbpJ_cRo.js +0 -1
- package/dist/types/utils/get-property-descriptor.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var cjs = {};
|
|
4
4
|
|
|
@@ -9458,63 +9458,4 @@ function requireCjs () {
|
|
|
9458
9458
|
|
|
9459
9459
|
var cjsExports = /*@__PURE__*/ requireCjs();
|
|
9460
9460
|
|
|
9461
|
-
|
|
9462
|
-
* Returns property descriptor for the given property of the component.
|
|
9463
|
-
*
|
|
9464
|
-
* {@internal}
|
|
9465
|
-
*/
|
|
9466
|
-
function getPropertyDescriptor(cmp, property, configurableRequired = true) {
|
|
9467
|
-
// descriptors are defined on prototype, so we have to go one level up.
|
|
9468
|
-
let prototype = Object.getPrototypeOf(cmp);
|
|
9469
|
-
let descriptor = Object.getOwnPropertyDescriptor(prototype, property);
|
|
9470
|
-
if (!descriptor) {
|
|
9471
|
-
throw new Error(`Property "${property}" is not defined on component "${cmp.constructor.name}".`);
|
|
9472
|
-
}
|
|
9473
|
-
if (configurableRequired && !descriptor.configurable) {
|
|
9474
|
-
throw new Error(`Property "${property}" is not configurable on component "${cmp.constructor.name}".`);
|
|
9475
|
-
}
|
|
9476
|
-
return descriptor;
|
|
9477
|
-
}
|
|
9478
|
-
|
|
9479
|
-
/**
|
|
9480
|
-
* Returns an observable that emits property value when the component property value changes.
|
|
9481
|
-
*/
|
|
9482
|
-
function propertyObservable(cmp, property) {
|
|
9483
|
-
let subjectProperty = `__rx__subject_for_property__${property}__`;
|
|
9484
|
-
if (!cmp[subjectProperty]) {
|
|
9485
|
-
let descriptor = getPropertyDescriptor(cmp, property);
|
|
9486
|
-
let previousSetter = descriptor.set;
|
|
9487
|
-
let previousGetter = descriptor.get;
|
|
9488
|
-
// we have to invoke previous getter on component instance to get the current value
|
|
9489
|
-
let currentValue = undefined !== previousGetter ? previousGetter.call(cmp) : descriptor.value;
|
|
9490
|
-
let subject = new cjsExports.BehaviorSubject(currentValue);
|
|
9491
|
-
descriptor.set = function (value) {
|
|
9492
|
-
if (previousSetter) {
|
|
9493
|
-
previousSetter.call(this, value);
|
|
9494
|
-
}
|
|
9495
|
-
subject.next(value);
|
|
9496
|
-
};
|
|
9497
|
-
Object.defineProperty(cmp, property, descriptor);
|
|
9498
|
-
cmp[subjectProperty] = subject;
|
|
9499
|
-
}
|
|
9500
|
-
return cmp[subjectProperty]
|
|
9501
|
-
.asObservable()
|
|
9502
|
-
.pipe(cjsExports.distinctUntilChanged());
|
|
9503
|
-
}
|
|
9504
|
-
|
|
9505
|
-
function setProperty(cmp, property, options = {}) {
|
|
9506
|
-
let resolvedOptions = Object.assign({ scheduleRender: false, nextTick: true }, options);
|
|
9507
|
-
return (value) => {
|
|
9508
|
-
cmp[property] = value;
|
|
9509
|
-
if (!resolvedOptions.scheduleRender) {
|
|
9510
|
-
return;
|
|
9511
|
-
}
|
|
9512
|
-
if (!resolvedOptions.nextTick) {
|
|
9513
|
-
forceUpdate(cmp);
|
|
9514
|
-
return;
|
|
9515
|
-
}
|
|
9516
|
-
Promise.resolve().then(() => forceUpdate(cmp));
|
|
9517
|
-
};
|
|
9518
|
-
}
|
|
9519
|
-
|
|
9520
|
-
export { cjsExports as c, getPropertyDescriptor as g, propertyObservable as p, setProperty as s };
|
|
9461
|
+
exports.cjsExports = cjsExports;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,291 +1,327 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var index$1 = require('./index-Dssn3hdS.js');
|
|
5
|
+
var stencil = require('./stencil-uD4ZIy1h.js');
|
|
6
|
+
var mutationObservable = require('./mutation-observable-qY7nC854.js');
|
|
7
|
+
var scheduleRender = require('./schedule-render-DG4hFv5E.js');
|
|
8
|
+
var propertiesObservable = require('./properties-observable-DXbVBslA.js');
|
|
9
|
+
var propertyObservable = require('./property-observable-CPp5WEjC.js');
|
|
10
|
+
var untilDisconnected = require('./until-disconnected-BTCr-3q2.js');
|
|
11
|
+
var setProperty = require('./set-property-C3KARzdl.js');
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Operator that emits values from the source observable only
|
|
15
|
+
* while the component is connected to DOM.
|
|
16
|
+
*
|
|
17
|
+
* This can be useful for cases where you want to move components in and out of the DOM,
|
|
18
|
+
* but still want to receive values from an observable while the component is connected
|
|
19
|
+
* and react to them.
|
|
20
|
+
*/
|
|
21
|
+
function whileConnected(cmp, options) {
|
|
22
|
+
return (source) => {
|
|
23
|
+
let element = index.getElement(cmp);
|
|
24
|
+
let reemit = (options === null || options === void 0 ? void 0 : options.reemit) || false;
|
|
25
|
+
if (!reemit) {
|
|
26
|
+
return source.pipe(index$1.cjsExports.filter(() => element.isConnected));
|
|
27
|
+
}
|
|
28
|
+
let captured = false;
|
|
29
|
+
let last = undefined;
|
|
30
|
+
let reemiter = new index$1.cjsExports.Subject();
|
|
31
|
+
let previousConnectedCallback = cmp.connectedCallback;
|
|
32
|
+
cmp.connectedCallback = function () {
|
|
33
|
+
previousConnectedCallback === null || previousConnectedCallback === void 0 ? void 0 : previousConnectedCallback.call(this);
|
|
34
|
+
if (!captured) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
reemiter.next(last);
|
|
38
|
+
captured = false;
|
|
39
|
+
last = undefined;
|
|
14
40
|
};
|
|
15
|
-
|
|
41
|
+
return index$1.cjsExports.merge(reemiter, source.pipe(index$1.cjsExports.tap((value) => {
|
|
42
|
+
if (element.isConnected) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
captured = true;
|
|
46
|
+
last = value;
|
|
47
|
+
}), index$1.cjsExports.filter(() => element.isConnected)));
|
|
48
|
+
};
|
|
16
49
|
}
|
|
17
50
|
|
|
51
|
+
function applyOperators(...args) {
|
|
52
|
+
let [observable, cmp, options] = args;
|
|
53
|
+
return applyOperatorsInternal(observable, cmp, options);
|
|
54
|
+
}
|
|
18
55
|
/**
|
|
19
|
-
*
|
|
56
|
+
* A TypeScript types hack to make the applyOperators function work
|
|
57
|
+
* with both ViewChild and ViewChildren options.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
20
60
|
*/
|
|
21
|
-
function
|
|
22
|
-
if (
|
|
23
|
-
|
|
61
|
+
function applyOperatorsInternal(observable, cmp, options) {
|
|
62
|
+
if (options === null || options === void 0 ? void 0 : options.whileConnected) {
|
|
63
|
+
observable = observable.pipe(whileConnected(cmp, {
|
|
64
|
+
reemit: true,
|
|
65
|
+
}));
|
|
24
66
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
67
|
+
if (options === null || options === void 0 ? void 0 : options.filter) {
|
|
68
|
+
observable = observable.pipe(true === options.filter
|
|
69
|
+
? index$1.cjsExports.filter((value) => {
|
|
70
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return !!value;
|
|
74
|
+
})
|
|
75
|
+
: index$1.cjsExports.filter(options.filter));
|
|
76
|
+
}
|
|
77
|
+
if (options === null || options === void 0 ? void 0 : options.cached) {
|
|
78
|
+
observable = observable.pipe(index$1.cjsExports.take(1));
|
|
79
|
+
}
|
|
80
|
+
return observable;
|
|
28
81
|
}
|
|
29
82
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
83
|
+
let registries = new Map();
|
|
84
|
+
class ValuesRegistry {
|
|
85
|
+
constructor() {
|
|
86
|
+
this._observables = new WeakMap();
|
|
87
|
+
}
|
|
88
|
+
has(element, property) {
|
|
89
|
+
return this._observables.has(element) && this._observables.get(element).has(property);
|
|
90
|
+
}
|
|
91
|
+
get(element, property) {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
return (_b = (_a = this._observables.get(element)) === null || _a === void 0 ? void 0 : _a.get(property)) === null || _b === void 0 ? void 0 : _b[0];
|
|
94
|
+
}
|
|
95
|
+
set(element, property, observable, initial) {
|
|
96
|
+
this.delete(element, property);
|
|
97
|
+
if (!this._observables.has(element)) {
|
|
98
|
+
this._observables.set(element, new Map());
|
|
99
|
+
}
|
|
100
|
+
this._observables.get(element).set(property, [observable, initial, undefined]);
|
|
101
|
+
this._observables.get(element).get(property)[2] = observable.subscribe((value) => {
|
|
102
|
+
this._observables.get(element).get(property)[1] = value;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
delete(element, property) {
|
|
106
|
+
if (this._observables.has(element) && this._observables.get(element).has(property)) {
|
|
107
|
+
let previous = this._observables.get(element).get(property)[2];
|
|
108
|
+
previous === null || previous === void 0 ? void 0 : previous.unsubscribe();
|
|
109
|
+
this._observables.get(element).delete(property);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
value(element, property) {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
return (_b = (_a = this._observables.get(element)) === null || _a === void 0 ? void 0 : _a.get(property)) === null || _b === void 0 ? void 0 : _b[1];
|
|
38
115
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return previousRender.call(this);
|
|
46
|
-
};
|
|
47
|
-
return () => {
|
|
48
|
-
cmp.render = previousRender;
|
|
49
|
-
};
|
|
50
|
-
});
|
|
116
|
+
}
|
|
117
|
+
function getRegistry(key) {
|
|
118
|
+
if (!registries.has(key)) {
|
|
119
|
+
registries.set(key, new ValuesRegistry());
|
|
120
|
+
}
|
|
121
|
+
return registries.get(key);
|
|
51
122
|
}
|
|
52
123
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (let i = 0; i <
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (records[i].addedNodes.length || records[i].removedNodes.length) {
|
|
69
|
-
return true;
|
|
124
|
+
function contentChildObservable(cmp, selector, options) {
|
|
125
|
+
let element = index.getElement(cmp);
|
|
126
|
+
let mutations = mutationObservable.observeSubtree(element).pipe(index$1.cjsExports.map(() => void 0), index$1.cjsExports.startWith(void 0));
|
|
127
|
+
options = Object.assign({ distinct: true }, options);
|
|
128
|
+
// In shadow DOM, we can just listen for the mutations and query the element directly.
|
|
129
|
+
if (stencil.usesShadowDom(cmp)) {
|
|
130
|
+
return mutations.pipe(index$1.cjsExports.map(() => element.querySelector(selector)), mutationObservable.distinctUntilElementChanged(options.distinct));
|
|
131
|
+
}
|
|
132
|
+
// When shadow DOM is emulated, we need to filter out elements that are part of the emulated view child.
|
|
133
|
+
return mutations.pipe(index$1.cjsExports.map(() => {
|
|
134
|
+
let candidates = Array.from(element.querySelectorAll(selector));
|
|
135
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
136
|
+
let candidate = candidates[i];
|
|
137
|
+
if (!stencil.isEmulatedViewChild(candidate, element)) {
|
|
138
|
+
return candidate;
|
|
70
139
|
}
|
|
71
140
|
}
|
|
72
|
-
return
|
|
73
|
-
}),
|
|
74
|
-
/* noop */
|
|
75
|
-
}));
|
|
141
|
+
return null;
|
|
142
|
+
}), mutationObservable.distinctUntilElementChanged(options.distinct));
|
|
76
143
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
144
|
+
|
|
145
|
+
function ContentChild(selector, options) {
|
|
146
|
+
return function (cmp, property) {
|
|
147
|
+
let connectedCallback = cmp.connectedCallback;
|
|
148
|
+
cmp.connectedCallback = function () {
|
|
149
|
+
connectedCallback === null || connectedCallback === void 0 ? void 0 : connectedCallback.call(this);
|
|
150
|
+
};
|
|
151
|
+
let descriptor = Object.getOwnPropertyDescriptor(cmp.prototype, property) || {
|
|
152
|
+
configurable: true,
|
|
153
|
+
enumerable: true,
|
|
154
|
+
};
|
|
155
|
+
delete descriptor['value'];
|
|
156
|
+
delete descriptor['writable'];
|
|
157
|
+
Object.defineProperty(cmp, property, Object.assign(Object.assign({}, descriptor), { set(_value) {
|
|
89
158
|
},
|
|
90
|
-
get
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let observable = (
|
|
95
|
-
|
|
159
|
+
get() {
|
|
160
|
+
let element = index.getElement(this);
|
|
161
|
+
let registry = getRegistry('@ContentChild');
|
|
162
|
+
if (!registry.has(element, property)) {
|
|
163
|
+
let observable = contentChildObservable(this, selector, options);
|
|
164
|
+
observable = applyOperators(observable, this, options);
|
|
165
|
+
registry.set(element, property, observable);
|
|
96
166
|
}
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
Object.defineProperty(target, property, descriptor);
|
|
167
|
+
return registry.value(element, property);
|
|
168
|
+
} }));
|
|
101
169
|
};
|
|
102
170
|
}
|
|
103
171
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
172
|
+
function contentChildrenObservable(cmp, selector, options) {
|
|
173
|
+
let element = index.getElement(cmp);
|
|
174
|
+
let mutations = mutationObservable.observeSubtree(element).pipe(index$1.cjsExports.map(() => void 0), index$1.cjsExports.startWith(void 0));
|
|
175
|
+
options = Object.assign({ distinct: true }, options);
|
|
176
|
+
// In shadow DOM, we can just listen for the mutations and query the element directly.
|
|
177
|
+
if (stencil.usesShadowDom(cmp)) {
|
|
178
|
+
return mutations.pipe(index$1.cjsExports.map(() => Array.from(element.querySelectorAll(selector))), mutationObservable.distinctUntilElementsChanged(options.distinct));
|
|
179
|
+
}
|
|
180
|
+
// When shadow DOM is emulated, we need to filter out elements that are part of the emulated view child.
|
|
181
|
+
return mutations.pipe(index$1.cjsExports.map(() => Array.from(element.querySelectorAll(selector)).filter((candidate) => !stencil.isEmulatedViewChild(candidate, element))), mutationObservable.distinctUntilElementsChanged(options.distinct));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function ContentChildren(selector, options) {
|
|
185
|
+
return function (cmp, property) {
|
|
186
|
+
let connectedCallback = cmp.connectedCallback;
|
|
187
|
+
cmp.connectedCallback = function () {
|
|
188
|
+
connectedCallback === null || connectedCallback === void 0 ? void 0 : connectedCallback.call(this);
|
|
189
|
+
};
|
|
190
|
+
let descriptor = Object.getOwnPropertyDescriptor(cmp.prototype, property) || {
|
|
191
|
+
configurable: true,
|
|
192
|
+
enumerable: true,
|
|
193
|
+
};
|
|
194
|
+
delete descriptor['value'];
|
|
195
|
+
delete descriptor['writable'];
|
|
196
|
+
Object.defineProperty(cmp, property, Object.assign(Object.assign({}, descriptor), { set(_value) {
|
|
116
197
|
},
|
|
117
|
-
get
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let observable = (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
for (let i = 0; i < previous.length; i++) {
|
|
127
|
-
if (previous[i] !== current[i]) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
}), setProperty.cjsExports.shareReplay(1));
|
|
198
|
+
get() {
|
|
199
|
+
let element = index.getElement(cmp);
|
|
200
|
+
let registry = getRegistry('@ContentChildren');
|
|
201
|
+
if (!registry.has(element, property)) {
|
|
202
|
+
let observable = contentChildrenObservable(this, selector, options);
|
|
203
|
+
observable = applyOperators(observable, this, options);
|
|
204
|
+
registry.set(element, property, observable);
|
|
133
205
|
}
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
Object.defineProperty(target, property, descriptor);
|
|
206
|
+
return registry.value(element, property);
|
|
207
|
+
} }));
|
|
138
208
|
};
|
|
139
209
|
}
|
|
140
210
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
211
|
+
function ViewChild(selector, options) {
|
|
212
|
+
return function (cmp, property) {
|
|
213
|
+
let connectedCallback = cmp.connectedCallback;
|
|
214
|
+
cmp.connectedCallback = function () {
|
|
215
|
+
connectedCallback === null || connectedCallback === void 0 ? void 0 : connectedCallback.call(this);
|
|
216
|
+
};
|
|
217
|
+
let descriptor = Object.getOwnPropertyDescriptor(cmp.prototype, property) || {
|
|
218
|
+
configurable: true,
|
|
219
|
+
enumerable: true,
|
|
220
|
+
};
|
|
221
|
+
delete descriptor['value'];
|
|
222
|
+
delete descriptor['writable'];
|
|
223
|
+
Object.defineProperty(cmp, property, Object.assign(Object.assign({}, descriptor), { set(_value) {
|
|
224
|
+
},
|
|
225
|
+
get() {
|
|
226
|
+
let element = index.getElement(this);
|
|
227
|
+
let registry = getRegistry('@ViewChild');
|
|
228
|
+
if (!registry.has(element, property)) {
|
|
229
|
+
let observable = mutationObservable.viewChildObservable(this, selector, options);
|
|
230
|
+
observable = applyOperators(observable, this, options);
|
|
231
|
+
registry.set(element, property, observable);
|
|
232
|
+
}
|
|
233
|
+
return registry.value(element, property);
|
|
234
|
+
} }));
|
|
159
235
|
};
|
|
160
236
|
}
|
|
161
237
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
function toProperty(cmp, property) {
|
|
169
|
-
// ensure that the property is defined on the component.
|
|
170
|
-
setProperty.getPropertyDescriptor(cmp, property);
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
return (source) => {
|
|
173
|
-
return source.pipe(setProperty.cjsExports.tap((value) => {
|
|
174
|
-
cmp[property] = value;
|
|
175
|
-
}));
|
|
176
|
-
};
|
|
238
|
+
function QuerySelector(selector, options) {
|
|
239
|
+
if ('content' === (options === null || options === void 0 ? void 0 : options.target)) {
|
|
240
|
+
return ContentChild(selector, options);
|
|
241
|
+
}
|
|
242
|
+
return ViewChild(selector, options);
|
|
177
243
|
}
|
|
178
244
|
|
|
179
|
-
|
|
180
|
-
* A map of component observables that are being watched for
|
|
181
|
-
* disconnect callback invocation. A weak map is being used
|
|
182
|
-
* so that the component instance can be garbage collected.
|
|
183
|
-
*
|
|
184
|
-
* {@internal}
|
|
185
|
-
*/
|
|
186
|
-
let disconnectObservables = new WeakMap();
|
|
187
|
-
/**
|
|
188
|
-
* Creates an observable that emits a value when the component
|
|
189
|
-
* is disconnected from DOM and method `disconnectedCallback()`
|
|
190
|
-
* is invoked. StencilJS will supress the invocation of this
|
|
191
|
-
* method if it is not defined on the component.
|
|
192
|
-
*
|
|
193
|
-
* {@internal}
|
|
194
|
-
*/
|
|
195
|
-
let createUsingDisconnectedCallback = function (cmp) {
|
|
196
|
-
let previousDisconnected = cmp.disconnectedCallback;
|
|
197
|
-
if (!previousDisconnected) {
|
|
198
|
-
throw new Error(`Component "${cmp.constructor.name}" does not have a "disconnectedCallback()" method defined.`);
|
|
199
|
-
}
|
|
200
|
-
let disconnectedSubject$ = new setProperty.cjsExports.Subject();
|
|
201
|
-
cmp.disconnectedCallback = function () {
|
|
202
|
-
if (previousDisconnected) {
|
|
203
|
-
previousDisconnected.call(cmp);
|
|
204
|
-
}
|
|
205
|
-
disconnectedSubject$.next();
|
|
206
|
-
};
|
|
207
|
-
return disconnectedSubject$.asObservable();
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Mutation observer is our next heuristic. We will monitor parent
|
|
211
|
-
* node of the component and emit a value when the component is
|
|
212
|
-
* disconnected from DOM. This will only work, of course, if the
|
|
213
|
-
* component is not the root node of the application and component
|
|
214
|
-
* is already within DOM.
|
|
215
|
-
*
|
|
216
|
-
* {@internal}
|
|
217
|
-
*/
|
|
218
|
-
let createUsingMutationObserver = function (cmp) {
|
|
245
|
+
function viewChildrenObservable(cmp, selector, options) {
|
|
219
246
|
let element = index.getElement(cmp);
|
|
220
|
-
|
|
221
|
-
|
|
247
|
+
let hostRef = stencil.getHostRef(cmp);
|
|
248
|
+
let rendered = mutationObservable.renderObservable(cmp);
|
|
249
|
+
options = Object.assign({ distinct: true }, options);
|
|
250
|
+
if ((hostRef.$renderCount$ || 0) > 0) {
|
|
251
|
+
rendered = rendered.pipe(index$1.cjsExports.startWith(void 0));
|
|
222
252
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
subtree: true,
|
|
238
|
-
});
|
|
239
|
-
return () => {
|
|
240
|
-
mutationObserver.disconnect();
|
|
241
|
-
// we can not re-use this observable, so we have to delete it
|
|
242
|
-
disconnectObservables.delete(cmp);
|
|
253
|
+
// In shadow DOM, this is quite cheap, we can query only shadow DOM and skip the light DOM.
|
|
254
|
+
if (stencil.usesShadowDom(cmp)) {
|
|
255
|
+
return rendered.pipe(index$1.cjsExports.map(() => Array.from(element.shadowRoot.querySelectorAll(selector))), mutationObservable.distinctUntilElementsChanged(options.distinct));
|
|
256
|
+
}
|
|
257
|
+
// When shadow DOM is emulated, this is more expensive, we need to query light DOM and use elements
|
|
258
|
+
// which matches the selector, and it is not a child of any emulated slot node.
|
|
259
|
+
return rendered.pipe(index$1.cjsExports.map(() => Array.from(element.querySelectorAll(selector))), index$1.cjsExports.map((candidates) => candidates.filter((candidate) => stencil.isEmulatedViewChild(candidate, element))), mutationObservable.distinctUntilElementsChanged(options.distinct));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function ViewChildren(selector, options) {
|
|
263
|
+
return function (cmp, property) {
|
|
264
|
+
let connectedCallback = cmp.connectedCallback;
|
|
265
|
+
cmp.connectedCallback = function () {
|
|
266
|
+
connectedCallback === null || connectedCallback === void 0 ? void 0 : connectedCallback.call(this);
|
|
243
267
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
268
|
+
let descriptor = Object.getOwnPropertyDescriptor(cmp.prototype, property) || {
|
|
269
|
+
configurable: true,
|
|
270
|
+
enumerable: true,
|
|
271
|
+
};
|
|
272
|
+
delete descriptor['value'];
|
|
273
|
+
delete descriptor['writable'];
|
|
274
|
+
Object.defineProperty(cmp, property, Object.assign(Object.assign({}, descriptor), { set(_value) {
|
|
275
|
+
},
|
|
276
|
+
get() {
|
|
277
|
+
let element = index.getElement(cmp);
|
|
278
|
+
let registry = getRegistry('@ViewChildren');
|
|
279
|
+
if (!registry.has(element, property)) {
|
|
280
|
+
let observable = viewChildrenObservable(this, selector, options);
|
|
281
|
+
observable = applyOperators(observable, this, options);
|
|
282
|
+
registry.set(element, property, observable);
|
|
283
|
+
}
|
|
284
|
+
return registry.value(element, property);
|
|
285
|
+
} }));
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function QuerySelectorAll(selector, options) {
|
|
290
|
+
if ('content' === (options === null || options === void 0 ? void 0 : options.target)) {
|
|
291
|
+
return ContentChildren(selector, options);
|
|
265
292
|
}
|
|
266
|
-
|
|
293
|
+
return ViewChildren(selector, options);
|
|
267
294
|
}
|
|
295
|
+
|
|
268
296
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
297
|
+
* Use this function to tap into a value stream and flush value to
|
|
298
|
+
* component property.
|
|
271
299
|
*/
|
|
272
|
-
function
|
|
300
|
+
function toProperty(cmp, property) {
|
|
273
301
|
return (source) => {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
let disconnectObservable$ = disconnectObservables.get(cmp);
|
|
278
|
-
return source.pipe(setProperty.cjsExports.takeUntil(disconnectObservable$));
|
|
302
|
+
return source.pipe(index$1.cjsExports.tap((value) => {
|
|
303
|
+
cmp[property] = value;
|
|
304
|
+
}));
|
|
279
305
|
};
|
|
280
306
|
}
|
|
281
307
|
|
|
282
|
-
exports.
|
|
308
|
+
exports.mutationObservable = mutationObservable.mutationObservable;
|
|
309
|
+
exports.renderObservable = mutationObservable.renderObservable;
|
|
310
|
+
exports.viewChildObservable = mutationObservable.viewChildObservable;
|
|
311
|
+
exports.fromEvent = scheduleRender.fromEvent;
|
|
312
|
+
exports.scheduleRender = scheduleRender.scheduleRender;
|
|
313
|
+
exports.propertiesObservable = propertiesObservable.propertiesObservable;
|
|
314
|
+
exports.propertyObservable = propertyObservable.propertyObservable;
|
|
315
|
+
exports.untilDisconnected = untilDisconnected.untilDisconnected;
|
|
283
316
|
exports.setProperty = setProperty.setProperty;
|
|
317
|
+
exports.ContentChild = ContentChild;
|
|
318
|
+
exports.ContentChildren = ContentChildren;
|
|
284
319
|
exports.QuerySelector = QuerySelector;
|
|
285
320
|
exports.QuerySelectorAll = QuerySelectorAll;
|
|
286
|
-
exports.
|
|
287
|
-
exports.
|
|
288
|
-
exports.
|
|
289
|
-
exports.
|
|
321
|
+
exports.ViewChild = ViewChild;
|
|
322
|
+
exports.ViewChildren = ViewChildren;
|
|
323
|
+
exports.contentChildObservable = contentChildObservable;
|
|
324
|
+
exports.contentChildrenObservable = contentChildrenObservable;
|
|
290
325
|
exports.toProperty = toProperty;
|
|
291
|
-
exports.
|
|
326
|
+
exports.viewChildrenObservable = viewChildrenObservable;
|
|
327
|
+
exports.whileConnected = whileConnected;
|