@runopencode/rx-stencil 0.4.3 → 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 -0
- 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 -0
- 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
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
4
|
var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
5
5
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["rx-async.cjs",[[0,"rx-async",{"value":[16]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["rx-async.cjs",[[0,"rx-async",{"value":[16],"transform":[16],"_value":[32]}]]],["test-properties-observable.cjs",[[0,"test-properties-observable",{"foo":[1],"bar":[1],"baz":[1],"_value":[32]}]]],["test-property-observable.cjs",[[0,"test-property-observable",{"setValue":[64]}]]],["test-schedule-render.cjs",[[0,"test-schedule-render",{"increase":[64]}]]],["test-view-child-observable-shadow-dom.cjs",[[257,"test-view-child-observable-shadow-dom",{"which":[1],"getLog":[64],"clearLog":[64]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index$1 = require('./index-DWhjpI-K.js');
|
|
4
|
+
var index = require('./index-Dssn3hdS.js');
|
|
5
|
+
var stencil = require('./stencil-uD4ZIy1h.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns an RxJS operator that emits only when the element changes, based on the provided comparator function.
|
|
9
|
+
*
|
|
10
|
+
* If boolean `true` is provided, the default comparator function will be used, which compares the elements by reference.
|
|
11
|
+
*
|
|
12
|
+
* If falsy value is provided, the operator will emit every time the source observable emits.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function distinctUntilElementChanged(comparator) {
|
|
17
|
+
if (!comparator) {
|
|
18
|
+
return index.cjsExports.identity;
|
|
19
|
+
}
|
|
20
|
+
if ('function' === typeof comparator) {
|
|
21
|
+
return index.cjsExports.distinctUntilChanged(comparator);
|
|
22
|
+
}
|
|
23
|
+
return index.cjsExports.distinctUntilChanged();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns an RxJS operator that emits only when the array of elements changes, based on the provided comparator function.
|
|
27
|
+
*
|
|
28
|
+
* If boolean `true` is provided, the default comparator function will be used, which compares the elements by reference.
|
|
29
|
+
*
|
|
30
|
+
* If falsy value is provided, the operator will emit every time the source observable emits.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
function distinctUntilElementsChanged(comparator) {
|
|
35
|
+
if (!comparator) {
|
|
36
|
+
return index.cjsExports.identity;
|
|
37
|
+
}
|
|
38
|
+
// If the comparator is a function, use it to compare elements. Otherwise, use the default comparator that compares elements by reference.
|
|
39
|
+
let cmpFn = 'function' === typeof comparator ? comparator : (previous, current) => previous === current;
|
|
40
|
+
return index.cjsExports.distinctUntilChanged((previous, current) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (previous.length !== current.length) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return (_a = previous === null || previous === void 0 ? void 0 : previous.every((item, index) => cmpFn(item, current[index]))) !== null && _a !== void 0 ? _a : false;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Observe the subtree of an element for mutations.
|
|
50
|
+
*
|
|
51
|
+
* This function returns an observable that emits an array of MutationRecords whenever a mutation occurs
|
|
52
|
+
* in the subtree of the specified element.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
function observeSubtree(element) {
|
|
57
|
+
return mutationObservable(element, {
|
|
58
|
+
childList: true,
|
|
59
|
+
subtree: true,
|
|
60
|
+
}).pipe(index.cjsExports.filter((records) => {
|
|
61
|
+
for (let i = 0; i < records.length; i++) {
|
|
62
|
+
if ('childList' !== records[i].type) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (records[i].addedNodes.length || records[i].removedNodes.length) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let observables = new WeakMap();
|
|
74
|
+
/**
|
|
75
|
+
* Returns an observable that emits when the component `render()`
|
|
76
|
+
* function is called. Value will be emitted after the next
|
|
77
|
+
* microtask (next tick).
|
|
78
|
+
*
|
|
79
|
+
* If component is already rendered, the observable will emit
|
|
80
|
+
* immediately.
|
|
81
|
+
*
|
|
82
|
+
* Uses hot observable pattern.
|
|
83
|
+
*/
|
|
84
|
+
function renderObservable(cmp) {
|
|
85
|
+
if ('function' !== typeof cmp.render) {
|
|
86
|
+
throw new Error(`Component "${stencil.getComponentTagName(cmp)}" does not have a render function.`);
|
|
87
|
+
}
|
|
88
|
+
let element = index$1.getElement(cmp);
|
|
89
|
+
if (!observables.has(element)) {
|
|
90
|
+
let previousRender = cmp.render;
|
|
91
|
+
let subject = new index.cjsExports.Subject();
|
|
92
|
+
cmp.render = function () {
|
|
93
|
+
Promise.resolve().then(() => {
|
|
94
|
+
subject.next();
|
|
95
|
+
});
|
|
96
|
+
return previousRender.call(this);
|
|
97
|
+
};
|
|
98
|
+
observables.set(element, subject.asObservable());
|
|
99
|
+
}
|
|
100
|
+
return observables.get(element).pipe(stencil.isRendered(cmp) ? index.cjsExports.startWith(() => void 0) : index.cjsExports.identity);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function viewChildObservable(cmp, selector, options) {
|
|
104
|
+
let element = index$1.getElement(cmp);
|
|
105
|
+
let hostRef = stencil.getHostRef(cmp);
|
|
106
|
+
let rendered = renderObservable(cmp);
|
|
107
|
+
options = Object.assign({ distinct: true }, options);
|
|
108
|
+
if ((hostRef.$renderCount$ || 0) > 0) {
|
|
109
|
+
rendered = rendered.pipe(index.cjsExports.startWith(void 0));
|
|
110
|
+
}
|
|
111
|
+
// In shadow DOM, this is quite cheap, we can query only shadow DOM and skip the light DOM.
|
|
112
|
+
if (stencil.usesShadowDom(cmp)) {
|
|
113
|
+
return rendered.pipe(index.cjsExports.map(() => element.shadowRoot.querySelector(selector)), distinctUntilElementChanged(options.distinct));
|
|
114
|
+
}
|
|
115
|
+
// When shadow DOM is emulated, this is more expensive, we need to query light DOM and use first element
|
|
116
|
+
// which matches the selector, and it is not a child of any emulated slot node.
|
|
117
|
+
return rendered.pipe(index.cjsExports.map(() => {
|
|
118
|
+
let candidates = element.querySelectorAll(selector);
|
|
119
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
120
|
+
let candidate = candidates[i];
|
|
121
|
+
if (stencil.isEmulatedViewChild(candidate, element)) {
|
|
122
|
+
return candidate;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}), distinctUntilElementChanged(options.distinct));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Create mutation observer and return observable that emits mutation records when the target node is mutated.
|
|
131
|
+
*
|
|
132
|
+
* @param {Node} target The target node to observe for mutations.
|
|
133
|
+
* @param {MutationObserverInit} options The options for the mutation observer.
|
|
134
|
+
*/
|
|
135
|
+
function mutationObservable(target, options) {
|
|
136
|
+
return new index.cjsExports.Observable((observer) => {
|
|
137
|
+
let mutation = new MutationObserver((mutations) => {
|
|
138
|
+
observer.next(mutations);
|
|
139
|
+
});
|
|
140
|
+
mutation.observe(target, options);
|
|
141
|
+
return () => {
|
|
142
|
+
mutation.disconnect();
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
exports.distinctUntilElementChanged = distinctUntilElementChanged;
|
|
148
|
+
exports.distinctUntilElementsChanged = distinctUntilElementsChanged;
|
|
149
|
+
exports.mutationObservable = mutationObservable;
|
|
150
|
+
exports.observeSubtree = observeSubtree;
|
|
151
|
+
exports.renderObservable = renderObservable;
|
|
152
|
+
exports.viewChildObservable = viewChildObservable;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Dssn3hdS.js');
|
|
4
|
+
var propertyObservable = require('./property-observable-CPp5WEjC.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns an observable that emits an array of values from the given properties.
|
|
8
|
+
*
|
|
9
|
+
* It always emits an array of values, even if only one property is specified. The order
|
|
10
|
+
* of the values in the emitted array corresponds to the order of the properties specified.
|
|
11
|
+
*
|
|
12
|
+
* Do note that `combineLatest()` operator is used to combine the observables.
|
|
13
|
+
*/
|
|
14
|
+
function propertiesObservable(cmp, ...properties) {
|
|
15
|
+
if (0 === properties.length) {
|
|
16
|
+
throw new Error('At least one property must be specified.');
|
|
17
|
+
}
|
|
18
|
+
return index.cjsExports.combineLatest(properties.map((property) => {
|
|
19
|
+
return propertyObservable.propertyObservable(cmp, property);
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.propertiesObservable = propertiesObservable;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var index$1 = require('./index-Dssn3hdS.js');
|
|
5
|
+
var stencil = require('./stencil-uD4ZIy1h.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A WeakMap to store BehaviorSubjects for each component property.
|
|
9
|
+
*
|
|
10
|
+
* The key is the HTMLElement (component instance), and the value is a record of property names to BehaviorSubjects.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
let subjects = new WeakMap();
|
|
15
|
+
/**
|
|
16
|
+
* The name of the watcher callback function that will be registered on the component instance.
|
|
17
|
+
*/
|
|
18
|
+
const WATCHER_CALLBACK_NAME = '__runopencode_rx_stencil_watcher';
|
|
19
|
+
/**
|
|
20
|
+
* Returns an observable that emits property value when the component property value changes.
|
|
21
|
+
*/
|
|
22
|
+
function propertyObservable(cmp, property) {
|
|
23
|
+
let element = index.getElement(cmp);
|
|
24
|
+
let initialize = false;
|
|
25
|
+
if (!subjects.has(element)) {
|
|
26
|
+
subjects.set(element, {});
|
|
27
|
+
}
|
|
28
|
+
if (!subjects.get(element)[property]) {
|
|
29
|
+
subjects.get(element)[property] = new index$1.cjsExports.BehaviorSubject(cmp[property]);
|
|
30
|
+
initialize = true;
|
|
31
|
+
}
|
|
32
|
+
if (!initialize) {
|
|
33
|
+
return subjects.get(element)[property]
|
|
34
|
+
.asObservable()
|
|
35
|
+
.pipe(index$1.cjsExports.distinctUntilChanged());
|
|
36
|
+
}
|
|
37
|
+
let subject = subjects.get(element)[property];
|
|
38
|
+
let isMember = stencil.isPropOrState(cmp, property);
|
|
39
|
+
// If the property is not a member of the component (not decorated with @Prop or @State),
|
|
40
|
+
// we can watch it by modifying the property descriptor directly.
|
|
41
|
+
if (!isMember) {
|
|
42
|
+
let descriptor = Object.getOwnPropertyDescriptor(cmp, property);
|
|
43
|
+
Object.defineProperty(cmp, property, {
|
|
44
|
+
get() {
|
|
45
|
+
return subject.value;
|
|
46
|
+
},
|
|
47
|
+
set(value) {
|
|
48
|
+
subject.next(value);
|
|
49
|
+
if (descriptor && descriptor.set) {
|
|
50
|
+
descriptor.set.call(this, value);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
configurable: true,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
});
|
|
56
|
+
return subject
|
|
57
|
+
.asObservable()
|
|
58
|
+
.pipe(index$1.cjsExports.distinctUntilChanged());
|
|
59
|
+
}
|
|
60
|
+
let hostRef = stencil.getHostRef(cmp);
|
|
61
|
+
// If callback function is not registered on the component, we need to register it and ensure that some of the
|
|
62
|
+
// stencil internal flags are set to ensure that the callback will be called when the property changes.
|
|
63
|
+
if (!cmp[WATCHER_CALLBACK_NAME]) {
|
|
64
|
+
// This flag ensures that Stencil will call the prop change callback when the property changes.
|
|
65
|
+
index.BUILD.propChangeCallback = true;
|
|
66
|
+
// $flags$ needs to include 128 (0x80) to indicate that the component has watchers.
|
|
67
|
+
hostRef.$flags$ |= 128;
|
|
68
|
+
// $watchers$ object needs to exist so we can add them for property.
|
|
69
|
+
hostRef.$cmpMeta$.$watchers$ = hostRef.$cmpMeta$.$watchers$ || {};
|
|
70
|
+
// Finally, we need to register the watcher callback function on the component instance.
|
|
71
|
+
cmp[WATCHER_CALLBACK_NAME] = function (current, _previous, property) {
|
|
72
|
+
let element = index.getElement(this);
|
|
73
|
+
let subject = subjects.get(element)[property];
|
|
74
|
+
subject.next(current);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
hostRef.$cmpMeta$.$watchers$[property] = hostRef.$cmpMeta$.$watchers$[property] || [];
|
|
78
|
+
hostRef.$cmpMeta$.$watchers$[property].push({
|
|
79
|
+
[WATCHER_CALLBACK_NAME]: 0,
|
|
80
|
+
});
|
|
81
|
+
return subject
|
|
82
|
+
.asObservable()
|
|
83
|
+
.pipe(index$1.cjsExports.distinctUntilChanged());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
exports.propertyObservable = propertyObservable;
|
|
@@ -1,7 +1,11 @@
|
|
|
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 propertyObservable = require('./property-observable-CPp5WEjC.js');
|
|
6
|
+
var untilDisconnected = require('./until-disconnected-BTCr-3q2.js');
|
|
7
|
+
var setProperty = require('./set-property-C3KARzdl.js');
|
|
8
|
+
require('./stencil-uD4ZIy1h.js');
|
|
5
9
|
|
|
6
10
|
const asyncCss = () => `:host{display:inline-block}`;
|
|
7
11
|
|
|
@@ -9,27 +13,30 @@ const Async = class {
|
|
|
9
13
|
constructor(hostRef) {
|
|
10
14
|
index.registerInstance(this, hostRef);
|
|
11
15
|
this.value = null;
|
|
16
|
+
this.transform = (value) => value;
|
|
12
17
|
this._value = null;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritdoc}
|
|
21
|
+
*/
|
|
14
22
|
connectedCallback() {
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
propertyObservable.propertyObservable(this, 'value')
|
|
24
|
+
.pipe(index$1.cjsExports.switchMap((value) => {
|
|
25
|
+
if (index$1.cjsExports.isObservable(value)) {
|
|
17
26
|
return value;
|
|
18
27
|
}
|
|
19
28
|
if (value instanceof Promise) {
|
|
20
|
-
return
|
|
29
|
+
return index$1.cjsExports.from(value);
|
|
21
30
|
}
|
|
22
|
-
return
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
nextTick: false,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
// noop
|
|
31
|
+
return index$1.cjsExports.of(value);
|
|
32
|
+
}), untilDisconnected.untilDisconnected(this))
|
|
33
|
+
.subscribe(setProperty.setProperty(this, '_value'));
|
|
30
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritdoc}
|
|
37
|
+
*/
|
|
31
38
|
render() {
|
|
32
|
-
return (index.h(index.Host, { key: '
|
|
39
|
+
return (index.h(index.Host, { key: 'f59ccdf7defbbb0d9d3b87bc20e3edaae9a2513b' }, this.transform(this._value)));
|
|
33
40
|
}
|
|
34
41
|
};
|
|
35
42
|
Async.style = asyncCss();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
4
|
var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
7
|
/*
|
|
8
|
-
Stencil Client Patch Browser v4.
|
|
8
|
+
Stencil Client Patch Browser v4.45.0 | MIT Licensed | https://stenciljs.com
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
var patchBrowser = () => {
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["rx-async.cjs",[[0,"rx-async",{"value":[16]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["rx-async.cjs",[[0,"rx-async",{"value":[16],"transform":[16],"_value":[32]}]]],["test-properties-observable.cjs",[[0,"test-properties-observable",{"foo":[1],"bar":[1],"baz":[1],"_value":[32]}]]],["test-property-observable.cjs",[[0,"test-property-observable",{"setValue":[64]}]]],["test-schedule-render.cjs",[[0,"test-schedule-render",{"increase":[64]}]]],["test-view-child-observable-shadow-dom.cjs",[[257,"test-view-child-observable-shadow-dom",{"which":[1],"getLog":[64],"clearLog":[64]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var index$1 = require('./index-Dssn3hdS.js');
|
|
5
|
+
|
|
6
|
+
function fromEvent(cmp, eventName, delegateOrOptions, options) {
|
|
7
|
+
let element = index.getElement(cmp);
|
|
8
|
+
let delegate = 'string' === typeof delegateOrOptions ? delegateOrOptions : undefined;
|
|
9
|
+
let configuration = 'object' === typeof delegateOrOptions ? delegateOrOptions : options;
|
|
10
|
+
return new index$1.cjsExports.Observable((subscriber) => {
|
|
11
|
+
let handler = (event) => {
|
|
12
|
+
if (!delegate) {
|
|
13
|
+
subscriber.next(event);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!(event.target instanceof Element)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!event.target.closest(delegate)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
subscriber.next(event);
|
|
23
|
+
};
|
|
24
|
+
element.addEventListener(eventName, handler, configuration);
|
|
25
|
+
return () => {
|
|
26
|
+
element.removeEventListener(eventName, handler, configuration);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Schedule a render of the component. This is useful when you
|
|
33
|
+
* want to force a render of the component as result of changing
|
|
34
|
+
* the values of the component which are not tracked by Stencil,
|
|
35
|
+
* observables, for example.
|
|
36
|
+
*
|
|
37
|
+
* By default, the render is scheduled on the next tick, but you
|
|
38
|
+
* can disable this behavior by passing `false` as second argument.
|
|
39
|
+
*/
|
|
40
|
+
function scheduleRender(cmp, nextTick = true) {
|
|
41
|
+
return (source) => {
|
|
42
|
+
return source.pipe(index$1.cjsExports.tap(() => {
|
|
43
|
+
if (!nextTick) {
|
|
44
|
+
index.forceUpdate(cmp);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
Promise.resolve().then(() => index.forceUpdate(cmp));
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.fromEvent = fromEvent;
|
|
53
|
+
exports.scheduleRender = scheduleRender;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Set a property on a Stencil component and optionally schedule a render.
|
|
7
|
+
*
|
|
8
|
+
* This function returns a setter function that can be used to update the property value. Common use case
|
|
9
|
+
* is to set it as subscriber to an observable, so that the property is updated whenever the observable
|
|
10
|
+
* emits a new value.
|
|
11
|
+
*
|
|
12
|
+
* @param {ComponentInterface} cmp Component instance on which the property is to be set.
|
|
13
|
+
* @param {string} property Name of the property to be set on the component.
|
|
14
|
+
* @param {SetPropertyOptions} options Options to control the behavior of the property setter,
|
|
15
|
+
* such as whether to schedule a render and whether to do
|
|
16
|
+
* it on the next tick.
|
|
17
|
+
*/
|
|
18
|
+
function setProperty(cmp, property, options = {}) {
|
|
19
|
+
let resolvedOptions = Object.assign({ scheduleRender: false, nextTick: true }, options);
|
|
20
|
+
return (value) => {
|
|
21
|
+
cmp[property] = value;
|
|
22
|
+
if (!resolvedOptions.scheduleRender) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!resolvedOptions.nextTick) {
|
|
26
|
+
index.forceUpdate(cmp);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
Promise.resolve().then(() => index.forceUpdate(cmp));
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.setProperty = setProperty;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the host reference of a component.
|
|
5
|
+
*
|
|
6
|
+
* This is useful for accessing the underlying DOM element of a Stencil component.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
function getHostRef(cmp) {
|
|
11
|
+
return cmp.__stencil__getHostRef();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check if a property is defined as a member of the component with @State or @Prop decorator.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function isPropOrState(cmp, property) {
|
|
19
|
+
let hostRef = getHostRef(cmp);
|
|
20
|
+
return !!hostRef.$cmpMeta$.$members$[property];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a component uses Shadow DOM.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
function usesShadowDom(cmp) {
|
|
28
|
+
let hostRef = getHostRef(cmp);
|
|
29
|
+
let flags = hostRef.$cmpMeta$.$flags$;
|
|
30
|
+
return (flags & (1 << 0)) !== 0;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if a node is an emulated view child node.
|
|
34
|
+
*
|
|
35
|
+
* We are checking if node is a child node of the component which is not
|
|
36
|
+
* in emulated slot.
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
function isEmulatedViewChild(node, element) {
|
|
41
|
+
// If the node has the 's-ol' property, it is not an emulated content child.
|
|
42
|
+
if ('s-ol' in node) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
// If it is direct child of the component, it is not an emulated content child.
|
|
46
|
+
if (node.parentElement === element) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return isEmulatedViewChild(node.parentElement, element);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the tag name of a component.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
function getComponentTagName(cmp) {
|
|
57
|
+
let hostRef = getHostRef(cmp);
|
|
58
|
+
return hostRef.$cmpMeta$.$tagName$;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if a component has been rendered at least once.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
function isRendered(cmp) {
|
|
66
|
+
let hostRef = getHostRef(cmp);
|
|
67
|
+
return (hostRef.$renderCount$ || 0) > 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.getComponentTagName = getComponentTagName;
|
|
71
|
+
exports.getHostRef = getHostRef;
|
|
72
|
+
exports.isEmulatedViewChild = isEmulatedViewChild;
|
|
73
|
+
exports.isPropOrState = isPropOrState;
|
|
74
|
+
exports.isRendered = isRendered;
|
|
75
|
+
exports.usesShadowDom = usesShadowDom;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var index$1 = require('./index-Dssn3hdS.js');
|
|
5
|
+
var propertiesObservable = require('./properties-observable-DXbVBslA.js');
|
|
6
|
+
var untilDisconnected = require('./until-disconnected-BTCr-3q2.js');
|
|
7
|
+
require('./property-observable-CPp5WEjC.js');
|
|
8
|
+
require('./stencil-uD4ZIy1h.js');
|
|
9
|
+
|
|
10
|
+
const TestPropertiesObservable = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
this._value = undefined;
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
propertiesObservable.propertiesObservable(this, 'foo', 'bar', 'baz')
|
|
17
|
+
.pipe(index$1.cjsExports.map(([foo, bar, baz]) => {
|
|
18
|
+
this._value = `Foo: "${foo}", Bar: "${bar}", Baz: "${baz}"`;
|
|
19
|
+
}), untilDisconnected.untilDisconnected(this))
|
|
20
|
+
.subscribe();
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
return (index.h(index.Host, { key: 'b69107bec9636608215a705991bbbb0bf17ad303' }, this._value));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.test_properties_observable = TestPropertiesObservable;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var propertyObservable = require('./property-observable-CPp5WEjC.js');
|
|
5
|
+
var untilDisconnected = require('./until-disconnected-BTCr-3q2.js');
|
|
6
|
+
var setProperty = require('./set-property-C3KARzdl.js');
|
|
7
|
+
require('./index-Dssn3hdS.js');
|
|
8
|
+
require('./stencil-uD4ZIy1h.js');
|
|
9
|
+
|
|
10
|
+
const TestPropertyObservable = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
this.prop = 'foo';
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
propertyObservable.propertyObservable(this, 'prop')
|
|
18
|
+
.pipe(untilDisconnected.untilDisconnected(this))
|
|
19
|
+
.subscribe(setProperty.setProperty(this, 'value', {
|
|
20
|
+
scheduleRender: true,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
async setValue(value) {
|
|
24
|
+
this.prop = value;
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
return (index.h(index.Host, { key: '092d6fe0477d9ddfc771b152fe132c26e5dc04f0' }, this.value));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.test_property_observable = TestPropertyObservable;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var scheduleRender = require('./schedule-render-DG4hFv5E.js');
|
|
5
|
+
var untilDisconnected = require('./until-disconnected-BTCr-3q2.js');
|
|
6
|
+
require('./index-Dssn3hdS.js');
|
|
7
|
+
|
|
8
|
+
const TestScheduleRender = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
this._counter = 0;
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
scheduleRender.fromEvent(this, 'click')
|
|
15
|
+
.pipe(scheduleRender.scheduleRender(this), untilDisconnected.untilDisconnected(this))
|
|
16
|
+
.subscribe(() => {
|
|
17
|
+
this._counter++;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async increase() {
|
|
21
|
+
this._counter++;
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return (index.h(index.Host, { key: '66f26c1ef51b9e595d13926b1e46d1c7cb015566' }, this._counter));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.test_schedule_render = TestScheduleRender;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DWhjpI-K.js');
|
|
4
|
+
var mutationObservable = require('./mutation-observable-qY7nC854.js');
|
|
5
|
+
require('./index-Dssn3hdS.js');
|
|
6
|
+
require('./stencil-uD4ZIy1h.js');
|
|
7
|
+
|
|
8
|
+
const TestViewChildObservableShadowDom = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
index.registerInstance(this, hostRef);
|
|
11
|
+
this.which = 'all';
|
|
12
|
+
this._log = [];
|
|
13
|
+
}
|
|
14
|
+
async getLog() {
|
|
15
|
+
return this._log;
|
|
16
|
+
}
|
|
17
|
+
async clearLog() {
|
|
18
|
+
this._log = [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritdoc}
|
|
22
|
+
*/
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
mutationObservable.viewChildObservable(this, 'div')
|
|
25
|
+
.subscribe((el) => {
|
|
26
|
+
this._log.push(`viewChildObservable@connectedCallback: ${el === null || el === void 0 ? void 0 : el.id}`);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return (index.h(index.Host, { key: '3d253195f6c56cf48990e6daf7dde10971753a74' }, this.which !== 'even'
|
|
31
|
+
? (index.h("div", { id: "test-1", class: "odd all", key: "test-1" }, "1"))
|
|
32
|
+
: null, this.which !== 'odd'
|
|
33
|
+
? (index.h("div", { id: "test-2", class: "even all", key: "test-2" }, "2"))
|
|
34
|
+
: null, this.which !== 'even'
|
|
35
|
+
? (index.h("div", { id: "test-3", class: "odd all", key: "test-3" }, "3"))
|
|
36
|
+
: null, index.h("slot", { key: '141bd2c2626e1b89acc55ee79d7fa89e4b767e52' })));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.test_view_child_observable_shadow_dom = TestViewChildObservableShadowDom;
|