@runopencode/rx-stencil 0.3.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/LICENSE +18 -0
- package/README.md +42 -0
- package/dist/cjs/index-825eaf13.js +1207 -0
- package/dist/cjs/index-825eaf13.js.map +1 -0
- package/dist/cjs/index.cjs.js +672 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +24 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/rx-async.cjs.entry.js +71 -0
- package/dist/cjs/rx-async.cjs.entry.js.map +1 -0
- package/dist/cjs/rx-stencil.cjs.js +28 -0
- package/dist/cjs/rx-stencil.cjs.js.map +1 -0
- package/dist/cjs/set-property-e9b49bec.js +1171 -0
- package/dist/cjs/set-property-e9b49bec.js.map +1 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/async/async.js +66 -0
- package/dist/collection/components/async/async.js.map +1 -0
- package/dist/collection/components/async/async.scss +3 -0
- package/dist/collection/index.js +3 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/rx/decorator/index.js +3 -0
- package/dist/collection/rx/decorator/index.js.map +1 -0
- package/dist/collection/rx/decorator/query-selector-all.js +41 -0
- package/dist/collection/rx/decorator/query-selector-all.js.map +1 -0
- package/dist/collection/rx/decorator/query-selector.js +54 -0
- package/dist/collection/rx/decorator/query-selector.js.map +1 -0
- package/dist/collection/rx/index.js +5 -0
- package/dist/collection/rx/index.js.map +1 -0
- package/dist/collection/rx/observable/index.js +5 -0
- package/dist/collection/rx/observable/index.js.map +1 -0
- package/dist/collection/rx/observable/mutation-observable.js +13 -0
- package/dist/collection/rx/observable/mutation-observable.js.map +1 -0
- package/dist/collection/rx/observable/properties-observable.js +14 -0
- package/dist/collection/rx/observable/properties-observable.js.map +1 -0
- package/dist/collection/rx/observable/property-observable.js +28 -0
- package/dist/collection/rx/observable/property-observable.js.map +1 -0
- package/dist/collection/rx/observable/render-observable.js +24 -0
- package/dist/collection/rx/observable/render-observable.js.map +1 -0
- package/dist/collection/rx/operator/index.js +4 -0
- package/dist/collection/rx/operator/index.js.map +1 -0
- package/dist/collection/rx/operator/schedule-render.js +23 -0
- package/dist/collection/rx/operator/schedule-render.js.map +1 -0
- package/dist/collection/rx/operator/to-property.js +19 -0
- package/dist/collection/rx/operator/to-property.js.map +1 -0
- package/dist/collection/rx/operator/until-disconnected.js +105 -0
- package/dist/collection/rx/operator/until-disconnected.js.map +1 -0
- package/dist/collection/rx/subscriber/index.js +2 -0
- package/dist/collection/rx/subscriber/index.js.map +1 -0
- package/dist/collection/rx/subscriber/set-property.js +16 -0
- package/dist/collection/rx/subscriber/set-property.js.map +1 -0
- package/dist/collection/utils/get-property-descriptor.js +18 -0
- package/dist/collection/utils/get-property-descriptor.js.map +1 -0
- package/dist/collection/utils/index.js +2 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.js +661 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/rx-async.d.ts +11 -0
- package/dist/components/rx-async.js +86 -0
- package/dist/components/rx-async.js.map +1 -0
- package/dist/components/set-property.js +1153 -0
- package/dist/components/set-property.js.map +1 -0
- package/dist/esm/index-9f5c1c1c.js +1178 -0
- package/dist/esm/index-9f5c1c1c.js.map +1 -0
- package/dist/esm/index.js +660 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +20 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/rx-async.entry.js +67 -0
- package/dist/esm/rx-async.entry.js.map +1 -0
- package/dist/esm/rx-stencil.js +23 -0
- package/dist/esm/rx-stencil.js.map +1 -0
- package/dist/esm/set-property-adc341f7.js +1153 -0
- package/dist/esm/set-property-adc341f7.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/rx-stencil/index.esm.js +2 -0
- package/dist/rx-stencil/index.esm.js.map +1 -0
- package/dist/rx-stencil/p-3ccfcb54.js +3 -0
- package/dist/rx-stencil/p-3ccfcb54.js.map +1 -0
- package/dist/rx-stencil/p-55056215.js +2 -0
- package/dist/rx-stencil/p-55056215.js.map +1 -0
- package/dist/rx-stencil/p-b1ed83f6.entry.js +2 -0
- package/dist/rx-stencil/p-b1ed83f6.entry.js.map +1 -0
- package/dist/rx-stencil/rx-stencil.esm.js +2 -0
- package/dist/rx-stencil/rx-stencil.esm.js.map +1 -0
- package/dist/types/components/async/async.d.ts +10 -0
- package/dist/types/components.d.ts +41 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/rx/decorator/index.d.ts +2 -0
- package/dist/types/rx/decorator/query-selector-all.d.ts +22 -0
- package/dist/types/rx/decorator/query-selector.d.ts +30 -0
- package/dist/types/rx/index.d.ts +4 -0
- package/dist/types/rx/observable/index.d.ts +4 -0
- package/dist/types/rx/observable/mutation-observable.d.ts +2 -0
- package/dist/types/rx/observable/properties-observable.d.ts +6 -0
- package/dist/types/rx/observable/property-observable.d.ts +6 -0
- package/dist/types/rx/observable/render-observable.d.ts +8 -0
- package/dist/types/rx/operator/index.d.ts +3 -0
- package/dist/types/rx/operator/schedule-render.d.ts +12 -0
- package/dist/types/rx/operator/to-property.d.ts +9 -0
- package/dist/types/rx/operator/until-disconnected.d.ts +7 -0
- package/dist/types/rx/subscriber/index.d.ts +1 -0
- package/dist/types/rx/subscriber/set-property.d.ts +16 -0
- package/dist/types/stencil-public-runtime.d.ts +1640 -0
- package/dist/types/utils/get-property-descriptor.d.ts +7 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/docs/components.md +69 -0
- package/docs/creation-operators.md +138 -0
- package/docs/pipeable-operators.md +36 -0
- package/docs/query-selector-all-decorator.md +154 -0
- package/docs/query-selector-decorator.md +116 -0
- package/docs/subscribers.md +49 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +21 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +11 -0
- package/package.json +48 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Observable, } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an observable that emits when the component render()
|
|
4
|
+
* function is called. Value will be emitted after the next
|
|
5
|
+
* microtask (next tick).
|
|
6
|
+
*/
|
|
7
|
+
export function renderObservable(cmp) {
|
|
8
|
+
if ('function' !== typeof cmp.render) {
|
|
9
|
+
throw new Error('Component does not have a render function.');
|
|
10
|
+
}
|
|
11
|
+
return new Observable((subscriber) => {
|
|
12
|
+
let previousRender = cmp.render;
|
|
13
|
+
cmp.render = function () {
|
|
14
|
+
Promise.resolve().then(() => {
|
|
15
|
+
subscriber.next();
|
|
16
|
+
});
|
|
17
|
+
return previousRender.call(this);
|
|
18
|
+
};
|
|
19
|
+
return () => {
|
|
20
|
+
cmp.render = previousRender;
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=render-observable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-observable.js","sourceRoot":"","sources":["../../../src/rx/observable/render-observable.ts"],"names":[],"mappings":"AACA,OAAO,EACH,UAAU,GAGb,MAAkC,MAAM,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAuB;EACpD,IAAI,UAAU,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE;IAClC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;GACjE;EAED,OAAO,IAAI,UAAU,CAAO,CAAC,UAA4B,EAAiB,EAAE;IACxE,IAAI,cAAc,GAAc,GAAG,CAAC,MAAM,CAAC;IAE3C,GAAG,CAAC,MAAM,GAAG;MACT,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAS,EAAE;QAC9B,UAAU,CAAC,IAAI,EAAE,CAAC;MACtB,CAAC,CAAC,CAAC;MAEH,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAA;IAED,OAAO,GAAS,EAAE;MACd,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC;IAChC,CAAC,CAAA;EACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { ComponentInterface } from '@stencil/core';\nimport {\n Observable,\n Subscriber,\n TeardownLogic,\n} from 'rxjs';\n\n/**\n * Returns an observable that emits when the component render()\n * function is called. Value will be emitted after the next\n * microtask (next tick).\n */\nexport function renderObservable(cmp: ComponentInterface): Observable<void> {\n if ('function' !== typeof cmp.render) {\n throw new Error('Component does not have a render function.');\n }\n\n return new Observable<void>((subscriber: Subscriber<void>): TeardownLogic => {\n let previousRender: () => any = cmp.render;\n\n cmp.render = function (): any {\n Promise.resolve().then((): void => {\n subscriber.next();\n });\n\n return previousRender.call(this);\n }\n\n return (): void => {\n cmp.render = previousRender;\n }\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rx/operator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAS,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAa,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { scheduleRender } from './schedule-render';\nexport { toProperty } from './to-property';\nexport { untilDisconnected } from './until-disconnected';\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { forceUpdate, } from '@stencil/core';
|
|
2
|
+
import { tap, } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Schedule a render of the component. This is useful when you
|
|
5
|
+
* want to force a render of the component as result of changing
|
|
6
|
+
* the values of the component which are not tracked by Stencil,
|
|
7
|
+
* observables, for example.
|
|
8
|
+
*
|
|
9
|
+
* By default, the render is scheduled on the next tick, but you
|
|
10
|
+
* can disable this behavior by passing `false` as second argument.
|
|
11
|
+
*/
|
|
12
|
+
export function scheduleRender(cmp, nextTick = true) {
|
|
13
|
+
return (source) => {
|
|
14
|
+
return source.pipe(tap(() => {
|
|
15
|
+
if (!nextTick) {
|
|
16
|
+
forceUpdate(cmp);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
Promise.resolve().then(() => forceUpdate(cmp));
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=schedule-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-render.js","sourceRoot":"","sources":["../../../src/rx/operator/schedule-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAGH,GAAG,GACN,MAAM,MAAM,CAAC;AAEd;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAc,GAAuB,EAAE,WAAoB,IAAI;EACzF,OAAO,CAAC,MAAqB,EAAiB,EAAE;IAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAS,EAAE;MAC9B,IAAI,CAAC,QAAQ,EAAE;QACX,WAAW,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO;OACV;MAED,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAS,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC,CAAC;EACR,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {\n ComponentInterface,\n forceUpdate,\n} from '@stencil/core';\nimport {\n MonoTypeOperatorFunction,\n Observable,\n tap,\n} from 'rxjs';\n\n/**\n * Schedule a render of the component. This is useful when you\n * want to force a render of the component as result of changing\n * the values of the component which are not tracked by Stencil,\n * observables, for example.\n *\n * By default, the render is scheduled on the next tick, but you\n * can disable this behavior by passing `false` as second argument.\n */\nexport function scheduleRender<T = unknown>(cmp: ComponentInterface, nextTick: boolean = true): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>): Observable<T> => {\n return source.pipe(tap((): void => {\n if (!nextTick) {\n forceUpdate(cmp);\n return;\n }\n\n Promise.resolve().then((): void => forceUpdate(cmp));\n }));\n };\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { tap, } from 'rxjs';
|
|
2
|
+
import { getPropertyDescriptor } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Use this function to tap into a value stream and flush value to
|
|
5
|
+
* component property. You may also use this function as subscription
|
|
6
|
+
* function (function will detect that value is passed instead of
|
|
7
|
+
* observable).
|
|
8
|
+
*/
|
|
9
|
+
export function toProperty(cmp, property) {
|
|
10
|
+
// ensure that the property is defined on the component.
|
|
11
|
+
getPropertyDescriptor(cmp, property);
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
return (source) => {
|
|
14
|
+
return source.pipe(tap((value) => {
|
|
15
|
+
cmp[property] = value;
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=to-property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-property.js","sourceRoot":"","sources":["../../../src/rx/operator/to-property.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,GAAG,GACN,MAAqC,MAAM,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAU,GAAuB,EAAE,QAAgB;EACzE,wDAAwD;EACxD,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;EAErC,aAAa;EACb,OAAO,CAAC,MAAqB,EAAwB,EAAE;IACnD,OAAO,MAAM,CAAC,IAAI,CACd,GAAG,CAAC,CAAC,KAAQ,EAAQ,EAAE;MACnB,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAC1B,CAAC,CAAC,CACL,CAAC;EACN,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { ComponentInterface } from '@stencil/core';\nimport {\n MonoTypeOperatorFunction,\n tap,\n} from 'rxjs';\nimport { getPropertyDescriptor } from '../../utils';\n\n/**\n * Use this function to tap into a value stream and flush value to\n * component property. You may also use this function as subscription\n * function (function will detect that value is passed instead of\n * observable).\n */\nexport function toProperty<T = any>(cmp: ComponentInterface, property: string): MonoTypeOperatorFunction<T> {\n // ensure that the property is defined on the component.\n getPropertyDescriptor(cmp, property);\n\n // @ts-ignore\n return (source: Observable<T>): Observable<T> | void => {\n return source.pipe(\n tap((value: T): void => {\n cmp[property] = value;\n }),\n );\n };\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { getElement, } from '@stencil/core';
|
|
2
|
+
import { Observable, Subject, takeUntil, } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* A map of component observables that are being watched for
|
|
5
|
+
* disconnect callback invocation. A weak map is being used
|
|
6
|
+
* so that the component instance can be garbage collected.
|
|
7
|
+
*
|
|
8
|
+
* {@internal}
|
|
9
|
+
*/
|
|
10
|
+
let disconnectObservables = new WeakMap();
|
|
11
|
+
/**
|
|
12
|
+
* Creates an observable that emits a value when the component
|
|
13
|
+
* is disconnected from DOM and method `disconnectedCallback()`
|
|
14
|
+
* is invoked. StencilJS will supress the invocation of this
|
|
15
|
+
* method if it is not defined on the component.
|
|
16
|
+
*
|
|
17
|
+
* {@internal}
|
|
18
|
+
*/
|
|
19
|
+
let createUsingDisconnectedCallback = function (cmp) {
|
|
20
|
+
let previousDisconnected = cmp.disconnectedCallback;
|
|
21
|
+
if (!previousDisconnected) {
|
|
22
|
+
throw new Error(`Component "${cmp.constructor.name}" does not have a "disconnectedCallback()" method defined.`);
|
|
23
|
+
}
|
|
24
|
+
let disconnectedSubject$ = new Subject();
|
|
25
|
+
cmp.disconnectedCallback = function () {
|
|
26
|
+
if (previousDisconnected) {
|
|
27
|
+
previousDisconnected.call(cmp);
|
|
28
|
+
}
|
|
29
|
+
disconnectedSubject$.next();
|
|
30
|
+
};
|
|
31
|
+
return disconnectedSubject$.asObservable();
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Mutation observer is our next heuristic. We will monitor parent
|
|
35
|
+
* node of the component and emit a value when the component is
|
|
36
|
+
* disconnected from DOM. This will only work, of course, if the
|
|
37
|
+
* component is not the root node of the application and component
|
|
38
|
+
* is already within DOM.
|
|
39
|
+
*
|
|
40
|
+
* {@internal}
|
|
41
|
+
*/
|
|
42
|
+
let createUsingMutationObserver = function (cmp) {
|
|
43
|
+
let element = getElement(cmp);
|
|
44
|
+
if (null === element.parentNode) {
|
|
45
|
+
throw new Error(`Component "${cmp.constructor.name}" is not within DOM.`);
|
|
46
|
+
}
|
|
47
|
+
return new Observable((observer) => {
|
|
48
|
+
let mutationObserver = new MutationObserver((mutations) => {
|
|
49
|
+
mutations.forEach((record) => {
|
|
50
|
+
for (let node of Array.from(record.removedNodes)) {
|
|
51
|
+
if (node !== element) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
observer.next();
|
|
55
|
+
observer.complete();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
mutationObserver.observe(element.parentNode, {
|
|
60
|
+
childList: true,
|
|
61
|
+
subtree: true,
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
mutationObserver.disconnect();
|
|
65
|
+
// we can not re-use this observable, so we have to delete it
|
|
66
|
+
disconnectObservables.delete(cmp);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Creates an observable that emits a value when the component
|
|
72
|
+
* is disconnected from DOM.
|
|
73
|
+
*
|
|
74
|
+
* {@internal}
|
|
75
|
+
*/
|
|
76
|
+
function createDisconnectObservable(cmp) {
|
|
77
|
+
let functions = [
|
|
78
|
+
createUsingDisconnectedCallback,
|
|
79
|
+
createUsingMutationObserver,
|
|
80
|
+
];
|
|
81
|
+
for (let fn of functions) {
|
|
82
|
+
try {
|
|
83
|
+
disconnectObservables.set(cmp, fn(cmp));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
// noop
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`Could not create disconnect observable for component "${cmp.constructor.name}".`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Operator that unsubscribes from the source observable when
|
|
94
|
+
* the component is disconnected from DOM.
|
|
95
|
+
*/
|
|
96
|
+
export function untilDisconnected(cmp) {
|
|
97
|
+
return (source) => {
|
|
98
|
+
if (!disconnectObservables.has(cmp)) {
|
|
99
|
+
createDisconnectObservable(cmp);
|
|
100
|
+
}
|
|
101
|
+
let disconnectObservable$ = disconnectObservables.get(cmp);
|
|
102
|
+
return source.pipe(takeUntil(disconnectObservable$));
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=until-disconnected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"until-disconnected.js","sourceRoot":"","sources":["../../../src/rx/operator/until-disconnected.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n ComponentInterface,\n getElement,\n} from '@stencil/core';\nimport {\n MonoTypeOperatorFunction,\n Observable,\n Subject,\n Subscriber,\n takeUntil,\n TeardownLogic,\n} from 'rxjs';\n\n/**\n * A map of component observables that are being watched for\n * disconnect callback invocation. A weak map is being used\n * so that the component instance can be garbage collected.\n *\n * {@internal}\n */\nlet disconnectObservables: WeakMap<ComponentInterface, Observable<void>> = new WeakMap();\n\n/**\n * A function that creates an observable which emits an event\n * when the component is disconnected from DOM.\n *\n * {@internal}\n */\ntype CreateDisconnectObservableFn = (cmp: ComponentInterface) => Observable<void>;\n\n/**\n * Creates an observable that emits a value when the component\n * is disconnected from DOM and method `disconnectedCallback()`\n * is invoked. StencilJS will supress the invocation of this\n * method if it is not defined on the component.\n *\n * {@internal}\n */\nlet createUsingDisconnectedCallback: CreateDisconnectObservableFn = function (cmp: ComponentInterface): Observable<void> {\n let previousDisconnected: Function | undefined = cmp.disconnectedCallback;\n\n if (!previousDisconnected) {\n throw new Error(`Component \"${cmp.constructor.name}\" does not have a \"disconnectedCallback()\" method defined.`);\n }\n\n let disconnectedSubject$: Subject<void> = new Subject<void>();\n\n cmp.disconnectedCallback = function (): void {\n if (previousDisconnected) {\n previousDisconnected.call(cmp);\n }\n\n disconnectedSubject$.next();\n };\n\n return disconnectedSubject$.asObservable();\n}\n\n/**\n * Mutation observer is our next heuristic. We will monitor parent\n * node of the component and emit a value when the component is\n * disconnected from DOM. This will only work, of course, if the\n * component is not the root node of the application and component\n * is already within DOM.\n *\n * {@internal}\n */\nlet createUsingMutationObserver: CreateDisconnectObservableFn = function (cmp: ComponentInterface): Observable<void> {\n let element: HTMLElement = getElement(cmp);\n\n if (null === element.parentNode) {\n throw new Error(`Component \"${cmp.constructor.name}\" is not within DOM.`);\n }\n\n return new Observable<void>((observer: Subscriber<void>): TeardownLogic => {\n\n let mutationObserver: MutationObserver = new MutationObserver((mutations: MutationRecord[]): void => {\n mutations.forEach((record: MutationRecord): void => {\n for (let node of Array.from(record.removedNodes)) {\n if (node !== element) {\n continue;\n }\n\n observer.next();\n observer.complete();\n }\n });\n });\n\n mutationObserver.observe(element.parentNode, {\n childList: true,\n subtree: true,\n });\n\n return (): void => {\n mutationObserver.disconnect();\n // we can not re-use this observable, so we have to delete it\n disconnectObservables.delete(cmp);\n };\n });\n\n\n}\n\n/**\n * Creates an observable that emits a value when the component\n * is disconnected from DOM.\n *\n * {@internal}\n */\nfunction createDisconnectObservable(cmp: ComponentInterface): void {\n let functions: CreateDisconnectObservableFn[] = [\n createUsingDisconnectedCallback,\n createUsingMutationObserver,\n ];\n\n for (let fn of functions) {\n try {\n disconnectObservables.set(cmp, fn(cmp));\n return;\n } catch (e) {\n // noop\n }\n }\n\n throw new Error(`Could not create disconnect observable for component \"${cmp.constructor.name}\".`);\n}\n\n/**\n * Operator that unsubscribes from the source observable when\n * the component is disconnected from DOM.\n */\nexport function untilDisconnected<T = unknown>(cmp: ComponentInterface): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>): Observable<T> => {\n if (!disconnectObservables.has(cmp)) {\n createDisconnectObservable(cmp);\n }\n\n let disconnectObservable$: Observable<void> = disconnectObservables.get(cmp);\n\n return source.pipe(\n takeUntil<T>(disconnectObservable$),\n );\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rx/subscriber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,GACd,MAAM,gBAAgB,CAAC","sourcesContent":["export {\n SetPropertyOptions,\n setProperty,\n} from './set-property';\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { forceUpdate, } from '@stencil/core';
|
|
2
|
+
export function setProperty(cmp, property, options = {}) {
|
|
3
|
+
let resolvedOptions = Object.assign({ scheduleRender: false, nextTick: true }, options);
|
|
4
|
+
return (value) => {
|
|
5
|
+
cmp[property] = value;
|
|
6
|
+
if (!resolvedOptions.scheduleRender) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!resolvedOptions.nextTick) {
|
|
10
|
+
forceUpdate(cmp);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
Promise.resolve().then(() => forceUpdate(cmp));
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=set-property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-property.js","sourceRoot":"","sources":["../../../src/rx/subscriber/set-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,GACd,MAAM,eAAe,CAAC;AAiBvB,MAAM,UAAU,WAAW,CAAU,GAAuB,EAAE,QAAgB,EAAE,UAA8B,EAAE;EAC5G,IAAI,eAAe,mBACf,cAAc,EAAE,KAAK,EACrB,QAAQ,EAAQ,IAAI,IACjB,OAAO,CACb,CAAC;EAEF,OAAO,CAAC,KAAQ,EAAQ,EAAE;IACtB,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAEtB,IAAI,CAAC,eAAe,CAAC,cAAc,EAAE;MACjC,OAAO;KACV;IAED,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;MAC3B,WAAW,CAAC,GAAG,CAAC,CAAC;MACjB,OAAO;KACV;IAED,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAS,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;EACzD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {\n ComponentInterface,\n forceUpdate,\n} from '@stencil/core';\n\nexport type SetPropertyOptions = {\n /**\n * Whether to schedule a render of the component after the\n * property is updated. By default, this value is set to\n * `false`, assuming that the property is annotated with\n * either @State or @Prop decorator.\n */\n scheduleRender?: boolean;\n /**\n * Whether to schedule a render of the component on the next\n * tick. By default, this value is set to `true`.\n */\n nextTick?: boolean;\n}\n\nexport function setProperty<T = any>(cmp: ComponentInterface, property: string, options: SetPropertyOptions = {}): (value: T) => void {\n let resolvedOptions: SetPropertyOptions = {\n scheduleRender: false,\n nextTick: true,\n ...options,\n };\n\n return (value: T): void => {\n cmp[property] = value;\n\n if (!resolvedOptions.scheduleRender) {\n return;\n }\n\n if (!resolvedOptions.nextTick) {\n forceUpdate(cmp);\n return;\n }\n\n Promise.resolve().then((): void => forceUpdate(cmp));\n };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns property descriptor for the given property of the component.
|
|
3
|
+
*
|
|
4
|
+
* {@internal}
|
|
5
|
+
*/
|
|
6
|
+
export function getPropertyDescriptor(cmp, property, configurableRequired = true) {
|
|
7
|
+
// descriptors are defined on prototype, so we have to go one level up.
|
|
8
|
+
let prototype = Object.getPrototypeOf(cmp);
|
|
9
|
+
let descriptor = Object.getOwnPropertyDescriptor(prototype, property);
|
|
10
|
+
if (!descriptor) {
|
|
11
|
+
throw new Error(`Property "${property}" is not defined on component "${cmp.constructor.name}".`);
|
|
12
|
+
}
|
|
13
|
+
if (configurableRequired && !descriptor.configurable) {
|
|
14
|
+
throw new Error(`Property "${property}" is not configurable on component "${cmp.constructor.name}".`);
|
|
15
|
+
}
|
|
16
|
+
return descriptor;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=get-property-descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-property-descriptor.js","sourceRoot":"","sources":["../../src/utils/get-property-descriptor.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAuB,EAAE,QAAgB,EAAE,uBAAgC,IAAI;EACjH,uEAAuE;EACvE,IAAI,SAAS,GAAwB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;EAChE,IAAI,UAAU,GAAuB,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;EAE1F,IAAI,CAAC,UAAU,EAAE;IACb,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,kCAAkC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,CAAC;GACpG;EAED,IAAI,oBAAoB,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE;IAClD,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,uCAAuC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,CAAC;GACzG;EAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { ComponentInterface } from '@stencil/core';\n\n/**\n * Returns property descriptor for the given property of the component.\n *\n * {@internal}\n */\nexport function getPropertyDescriptor(cmp: ComponentInterface, property: string, configurableRequired: boolean = true): PropertyDescriptor {\n // descriptors are defined on prototype, so we have to go one level up.\n let prototype: object = Object.getPrototypeOf(cmp);\n let descriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor(prototype, property);\n\n if (!descriptor) {\n throw new Error(`Property \"${property}\" is not defined on component \"${cmp.constructor.name}\".`);\n }\n\n if (configurableRequired && !descriptor.configurable) {\n throw new Error(`Property \"${property}\" is not configurable on component \"${cmp.constructor.name}\".`);\n }\n\n return descriptor;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { getPropertyDescriptor } from './get-property-descriptor';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used to manually set the base path where assets can be found.
|
|
3
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
4
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
5
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
6
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
7
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
8
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
9
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
10
|
+
*/
|
|
11
|
+
export declare const setAssetPath: (path: string) => void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
15
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
16
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
17
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
18
|
+
* will result in the same behavior.
|
|
19
|
+
*/
|
|
20
|
+
export declare const setNonce: (nonce: string) => void
|
|
21
|
+
|
|
22
|
+
export interface SetPlatformOptions {
|
|
23
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
24
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
25
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|