@runopencode/rx-stencil 0.4.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.
Files changed (116) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +39 -0
  3. package/dist/cjs/index-5f6f12ab.js +1265 -0
  4. package/dist/cjs/index-5f6f12ab.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +572 -0
  6. package/dist/cjs/index.cjs.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +15 -0
  8. package/dist/cjs/loader.cjs.js.map +1 -0
  9. package/dist/cjs/rx-async.cjs.entry.js +71 -0
  10. package/dist/cjs/rx-async.cjs.entry.js.map +1 -0
  11. package/dist/cjs/rx-stencil.cjs.js +25 -0
  12. package/dist/cjs/rx-stencil.cjs.js.map +1 -0
  13. package/dist/cjs/set-property-88176225.js +1167 -0
  14. package/dist/cjs/set-property-88176225.js.map +1 -0
  15. package/dist/collection/collection-manifest.json +12 -0
  16. package/dist/collection/components/async/async.js +67 -0
  17. package/dist/collection/components/async/async.js.map +1 -0
  18. package/dist/collection/components/async/async.scss +3 -0
  19. package/dist/collection/index.js +3 -0
  20. package/dist/collection/index.js.map +1 -0
  21. package/dist/collection/rx/decorator/index.js +3 -0
  22. package/dist/collection/rx/decorator/index.js.map +1 -0
  23. package/dist/collection/rx/decorator/query-selector-all.js +41 -0
  24. package/dist/collection/rx/decorator/query-selector-all.js.map +1 -0
  25. package/dist/collection/rx/decorator/query-selector.js +54 -0
  26. package/dist/collection/rx/decorator/query-selector.js.map +1 -0
  27. package/dist/collection/rx/index.js +5 -0
  28. package/dist/collection/rx/index.js.map +1 -0
  29. package/dist/collection/rx/observable/index.js +4 -0
  30. package/dist/collection/rx/observable/index.js.map +1 -0
  31. package/dist/collection/rx/observable/mutation-observable.js +13 -0
  32. package/dist/collection/rx/observable/mutation-observable.js.map +1 -0
  33. package/dist/collection/rx/observable/property-observable.js +28 -0
  34. package/dist/collection/rx/observable/property-observable.js.map +1 -0
  35. package/dist/collection/rx/observable/render-observable.js +24 -0
  36. package/dist/collection/rx/observable/render-observable.js.map +1 -0
  37. package/dist/collection/rx/operator/index.js +4 -0
  38. package/dist/collection/rx/operator/index.js.map +1 -0
  39. package/dist/collection/rx/operator/schedule-render.js +23 -0
  40. package/dist/collection/rx/operator/schedule-render.js.map +1 -0
  41. package/dist/collection/rx/operator/to-property.js +19 -0
  42. package/dist/collection/rx/operator/to-property.js.map +1 -0
  43. package/dist/collection/rx/operator/until-disconnected.js +105 -0
  44. package/dist/collection/rx/operator/until-disconnected.js.map +1 -0
  45. package/dist/collection/rx/subscriber/index.js +2 -0
  46. package/dist/collection/rx/subscriber/index.js.map +1 -0
  47. package/dist/collection/rx/subscriber/set-property.js +16 -0
  48. package/dist/collection/rx/subscriber/set-property.js.map +1 -0
  49. package/dist/collection/utils/get-property-descriptor.js +18 -0
  50. package/dist/collection/utils/get-property-descriptor.js.map +1 -0
  51. package/dist/collection/utils/index.js +2 -0
  52. package/dist/collection/utils/index.js.map +1 -0
  53. package/dist/components/index.d.ts +33 -0
  54. package/dist/components/index.js +562 -0
  55. package/dist/components/index.js.map +1 -0
  56. package/dist/components/rx-async.d.ts +11 -0
  57. package/dist/components/rx-async.js +86 -0
  58. package/dist/components/rx-async.js.map +1 -0
  59. package/dist/components/set-property.js +1150 -0
  60. package/dist/components/set-property.js.map +1 -0
  61. package/dist/esm/index-9102de09.js +1236 -0
  62. package/dist/esm/index-9102de09.js.map +1 -0
  63. package/dist/esm/index.js +561 -0
  64. package/dist/esm/index.js.map +1 -0
  65. package/dist/esm/loader.js +11 -0
  66. package/dist/esm/loader.js.map +1 -0
  67. package/dist/esm/polyfills/core-js.js +11 -0
  68. package/dist/esm/polyfills/dom.js +79 -0
  69. package/dist/esm/polyfills/es5-html-element.js +1 -0
  70. package/dist/esm/polyfills/index.js +34 -0
  71. package/dist/esm/polyfills/system.js +6 -0
  72. package/dist/esm/rx-async.entry.js +67 -0
  73. package/dist/esm/rx-async.entry.js.map +1 -0
  74. package/dist/esm/rx-stencil.js +20 -0
  75. package/dist/esm/rx-stencil.js.map +1 -0
  76. package/dist/esm/set-property-7fa82bef.js +1150 -0
  77. package/dist/esm/set-property-7fa82bef.js.map +1 -0
  78. package/dist/index.cjs.js +1 -0
  79. package/dist/index.js +1 -0
  80. package/dist/rx-stencil/index.esm.js +2 -0
  81. package/dist/rx-stencil/index.esm.js.map +1 -0
  82. package/dist/rx-stencil/p-01af4414.entry.js +2 -0
  83. package/dist/rx-stencil/p-01af4414.entry.js.map +1 -0
  84. package/dist/rx-stencil/p-0cd0b2da.js +2 -0
  85. package/dist/rx-stencil/p-0cd0b2da.js.map +1 -0
  86. package/dist/rx-stencil/p-8411601b.js +3 -0
  87. package/dist/rx-stencil/p-8411601b.js.map +1 -0
  88. package/dist/rx-stencil/rx-stencil.esm.js +2 -0
  89. package/dist/rx-stencil/rx-stencil.esm.js.map +1 -0
  90. package/dist/types/components/async/async.d.ts +10 -0
  91. package/dist/types/components.d.ts +41 -0
  92. package/dist/types/index.d.ts +2 -0
  93. package/dist/types/rx/decorator/index.d.ts +2 -0
  94. package/dist/types/rx/decorator/query-selector-all.d.ts +22 -0
  95. package/dist/types/rx/decorator/query-selector.d.ts +30 -0
  96. package/dist/types/rx/index.d.ts +4 -0
  97. package/dist/types/rx/observable/index.d.ts +3 -0
  98. package/dist/types/rx/observable/mutation-observable.d.ts +2 -0
  99. package/dist/types/rx/observable/property-observable.d.ts +6 -0
  100. package/dist/types/rx/observable/render-observable.d.ts +8 -0
  101. package/dist/types/rx/operator/index.d.ts +3 -0
  102. package/dist/types/rx/operator/schedule-render.d.ts +12 -0
  103. package/dist/types/rx/operator/to-property.d.ts +9 -0
  104. package/dist/types/rx/operator/until-disconnected.d.ts +7 -0
  105. package/dist/types/rx/subscriber/index.d.ts +1 -0
  106. package/dist/types/rx/subscriber/set-property.d.ts +16 -0
  107. package/dist/types/stencil-public-runtime.d.ts +1652 -0
  108. package/dist/types/utils/get-property-descriptor.d.ts +7 -0
  109. package/dist/types/utils/index.d.ts +1 -0
  110. package/loader/cdn.js +3 -0
  111. package/loader/index.cjs.js +3 -0
  112. package/loader/index.d.ts +21 -0
  113. package/loader/index.es2017.js +3 -0
  114. package/loader/index.js +4 -0
  115. package/loader/package.json +11 -0
  116. package/package.json +42 -0
@@ -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,2 @@
1
+ export { setProperty, } from './set-property';
2
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export { getPropertyDescriptor } from './get-property-descriptor';
2
+ //# sourceMappingURL=index.js.map
@@ -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,33 @@
1
+ /**
2
+ * Get the base path to where the assets can be found. Use "setAssetPath(path)"
3
+ * if the path needs to be customized.
4
+ */
5
+ export declare const getAssetPath: (path: string) => string;
6
+
7
+ /**
8
+ * Used to manually set the base path where assets can be found.
9
+ * If the script is used as "module", it's recommended to use "import.meta.url",
10
+ * such as "setAssetPath(import.meta.url)". Other options include
11
+ * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
12
+ * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
13
+ * But do note that this configuration depends on how your script is bundled, or lack of
14
+ * bundling, and where your assets can be loaded from. Additionally custom bundling
15
+ * will have to ensure the static assets are copied to its build directory.
16
+ */
17
+ export declare const setAssetPath: (path: string) => void;
18
+
19
+ /**
20
+ * Used to specify a nonce value that corresponds with an application's CSP.
21
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
22
+ * Alternatively, the nonce value can be set on a meta tag in the DOM head
23
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) which
24
+ * will result in the same behavior.
25
+ */
26
+ export declare const setNonce: (nonce: string) => void
27
+
28
+ export interface SetPlatformOptions {
29
+ raf?: (c: FrameRequestCallback) => number;
30
+ ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
31
+ rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
32
+ }
33
+ export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;