@factoringplus/pl-components-pack-v3 1.2.30 → 1.2.31-pre-01

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 (177) hide show
  1. package/dist/components/{button → basic/pl-button}/index.d.ts +56 -55
  2. package/dist/components/{button → basic/pl-button}/pl-button.vue.d.ts +12 -11
  3. package/dist/components/{button → basic/pl-button}/types/index.d.ts +2 -1
  4. package/dist/components/{pl-dialog → basic/pl-dialog}/index.d.ts +2 -1
  5. package/dist/components/{pl-dialog → basic/pl-dialog}/pl-dialog-plus.vue.d.ts +15 -17
  6. package/dist/components/{pl-link → basic/pl-link}/index.d.ts +2 -1
  7. package/dist/components/{pl-link → basic/pl-link}/pl-link.vue.d.ts +7 -7
  8. package/dist/components/{pl-scrollbar → basic/pl-scrollbar}/index.d.ts +2 -1
  9. package/dist/components/{pl-scrollbar → basic/pl-scrollbar}/pl-scrollbar.vue.d.ts +8 -8
  10. package/dist/components/{pl-skeleton → basic/pl-skeleton}/index.d.ts +2 -1
  11. package/dist/components/{pl-skeleton → basic/pl-skeleton}/pl-skeleton.vue.d.ts +7 -7
  12. package/dist/components/{pl-tooltip-plus → basic/pl-tooltip-plus}/index.d.ts +2 -1
  13. package/dist/components/{pl-tooltip-plus → basic/pl-tooltip-plus}/pl-tooltip-plus.vue.d.ts +8 -8
  14. package/dist/components/components.d.ts +39 -37
  15. package/dist/components/{pl-card → data/pl-card}/index.d.ts +2 -1
  16. package/dist/components/{pl-multitab → data/pl-multitab}/components/pl-tab-card.vue.d.ts +10 -9
  17. package/dist/components/{pl-multitab → data/pl-multitab}/index.d.ts +2 -1
  18. package/dist/components/{pl-multitab → data/pl-multitab}/pl-multitab.vue.d.ts +9 -8
  19. package/dist/components/{pl-multitab → data/pl-multitab}/types/index.d.ts +2 -1
  20. package/dist/components/{pl-snackbar → data/pl-snackbar}/index.d.ts +2 -1
  21. package/dist/components/{pl-snackbar → data/pl-snackbar}/pl-snackbar.vue.d.ts +9 -14
  22. package/dist/components/data/pl-snackbar/renderSnackbar.d.ts +4 -0
  23. package/dist/components/data/pl-snackbar/types.d.ts +26 -0
  24. package/dist/components/{pl-stepper → data/pl-stepper}/index.d.ts +2 -1
  25. package/dist/components/data/pl-stepper/pl-stepper.vue.d.ts +57 -0
  26. package/dist/components/{pl-table-plus → data/pl-table-plus}/components/row-mask.vue.d.ts +6 -6
  27. package/dist/components/{pl-table-plus → data/pl-table-plus}/index.d.ts +2 -1
  28. package/dist/components/{pl-table-plus → data/pl-table-plus}/pl-table-plus.vue.d.ts +9 -9
  29. package/dist/components/data/pl-tabs/components/pl-tab-counter.vue.d.ts +21 -0
  30. package/dist/components/{pl-tabs → data/pl-tabs}/components/pl-tab.vue.d.ts +8 -7
  31. package/dist/components/{pl-tabs → data/pl-tabs}/index.d.ts +2 -1
  32. package/dist/components/{pl-tabs → data/pl-tabs}/pl-tabs.vue.d.ts +7 -7
  33. package/dist/components/{currency-input → deprecated/currency-input}/index.d.ts +2 -1
  34. package/dist/components/{pl-checkbox → deprecated/pl-checkbox}/index.d.ts +2 -1
  35. package/dist/components/{pl-date-picker → deprecated/pl-date-picker}/index.d.ts +2 -1
  36. package/dist/components/deprecated/pl-date-picker/pl-date-picker-range.vue.d.ts +77 -0
  37. package/dist/components/deprecated/pl-date-picker/pl-date-picker.vue.d.ts +72 -0
  38. package/dist/components/{pl-date-picker-legacy → deprecated/pl-date-picker-legacy}/index.d.ts +2 -1
  39. package/dist/components/deprecated/pl-dialog/index.d.ts +6 -0
  40. package/dist/components/{pl-dialog → deprecated/pl-dialog}/pl-dialog.vue.d.ts +11 -11
  41. package/dist/components/{pl-form-item → deprecated/pl-form-item}/index.d.ts +2 -1
  42. package/dist/components/{pl-input → deprecated/pl-input}/index.d.ts +2 -1
  43. package/dist/components/{pl-input-native → deprecated/pl-input-native}/index.d.ts +2 -1
  44. package/dist/components/{pl-select → deprecated/pl-select}/index.d.ts +2 -1
  45. package/dist/components/deprecated/pl-select/pl-select.vue.d.ts +147 -0
  46. package/dist/components/{pl-suggestions → deprecated/pl-suggestions}/index.d.ts +2 -1
  47. package/dist/components/deprecated/pl-suggestions/pl-suggestions.vue.d.ts +112 -0
  48. package/dist/components/{pl-table → deprecated/pl-table}/index.d.ts +2 -1
  49. package/dist/components/deprecated/pl-table/pl-table.vue.d.ts +133 -0
  50. package/dist/components/{pl-tooltip → deprecated/pl-tooltip}/index.d.ts +2 -1
  51. package/dist/components/{pl-tooltip → deprecated/pl-tooltip}/pl-tooltip.vue.d.ts +7 -7
  52. package/dist/components/{pl-upload → deprecated/pl-upload}/index.d.ts +2 -1
  53. package/dist/components/deprecated/pl-upload/pl-upload.vue.d.ts +124 -0
  54. package/dist/components/{pl-upload-legacy → deprecated/pl-upload-legacy}/index.d.ts +2 -1
  55. package/dist/components/deprecated/pl-upload-legacy/pl-upload-legacy.vue.d.ts +112 -0
  56. package/dist/components/{pl-autocomplete → form/pl-autocomplete}/components/pl-autocomplete-dropdown.vue.d.ts +14 -13
  57. package/dist/components/{pl-autocomplete → form/pl-autocomplete}/components/pl-default.vue.d.ts +13 -12
  58. package/dist/components/{pl-autocomplete → form/pl-autocomplete}/index.d.ts +2 -1
  59. package/dist/components/{pl-autocomplete → form/pl-autocomplete}/pl-autocompete.vue.d.ts +21 -20
  60. package/dist/components/{pl-autocomplete → form/pl-autocomplete}/types/index.d.ts +3 -2
  61. package/dist/components/{pl-checkbox-plus → form/pl-checkbox-plus}/index.d.ts +2 -1
  62. package/dist/components/{pl-checkbox-plus → form/pl-checkbox-plus}/pl-checkbox-plus.vue.d.ts +4 -4
  63. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/common/components/PlDatePickerRangeWrapper.vue.d.ts +12 -15
  64. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/common/components/PlDatePickerWrapper.vue.d.ts +10 -13
  65. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/common/types/index.d.ts +2 -2
  66. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/common/utils/wrapperFunctions.d.ts +5 -4
  67. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/index.d.ts +2 -1
  68. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/pl-date-picker-plus/pl-date-picker-plus.vue.d.ts +16 -15
  69. package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/pl-date-picker-range-plus/pl-date-picker-range-plus.vue.d.ts +16 -15
  70. package/dist/components/{pl-form → form/pl-form}/index.d.ts +2 -1
  71. package/dist/components/{pl-form → form/pl-form}/pl-form.vue.d.ts +10 -9
  72. package/dist/components/{pl-input-plus → form/pl-input-plus}/components/pl-currency.vue.d.ts +11 -10
  73. package/dist/components/{pl-input-plus → form/pl-input-plus}/components/pl-default.vue.d.ts +18 -17
  74. package/dist/components/{pl-input-plus → form/pl-input-plus}/components/pl-password.vue.d.ts +11 -10
  75. package/dist/components/{pl-input-plus → form/pl-input-plus}/components/pl-textarea.vue.d.ts +11 -10
  76. package/dist/components/{pl-input-plus → form/pl-input-plus}/index.d.ts +2 -1
  77. package/dist/components/{pl-input-plus → form/pl-input-plus}/pl-input-plus.vue.d.ts +21 -20
  78. package/dist/components/{pl-input-plus → form/pl-input-plus}/types/index.d.ts +5 -4
  79. package/dist/components/{pl-multi-select → form/pl-multi-select}/components/pl-default.vue.d.ts +13 -12
  80. package/dist/components/{pl-multi-select → form/pl-multi-select}/components/pl-multi-select-dropdown.vue.d.ts +11 -10
  81. package/dist/components/{pl-multi-select → form/pl-multi-select}/index.d.ts +2 -1
  82. package/dist/components/{pl-multi-select → form/pl-multi-select}/pl-multi-select.vue.d.ts +14 -13
  83. package/dist/components/{pl-multi-select → form/pl-multi-select}/types/index.d.ts +3 -2
  84. package/dist/components/{pl-radio → form/pl-radio}/index.d.ts +2 -1
  85. package/dist/components/{pl-radio → form/pl-radio}/pl-radio.vue.d.ts +3 -3
  86. package/dist/components/form/pl-select-plus/components/pl-account.vue.d.ts +68 -0
  87. package/dist/components/{pl-select-plus → form/pl-select-plus}/components/pl-default.vue.d.ts +14 -13
  88. package/dist/components/{pl-select-plus → form/pl-select-plus}/components/pl-select-dropdown.vue.d.ts +11 -10
  89. package/dist/components/{pl-select-plus → form/pl-select-plus}/index.d.ts +2 -1
  90. package/dist/components/{pl-select-plus → form/pl-select-plus}/pl-select-plus.vue.d.ts +15 -14
  91. package/dist/components/{pl-select-plus → form/pl-select-plus}/types/index.d.ts +3 -2
  92. package/dist/components/{pl-switch → form/pl-switch}/index.d.ts +2 -1
  93. package/dist/components/{pl-switch → form/pl-switch}/pl-switch.vue.d.ts +3 -3
  94. package/dist/components/{pl-upload-plus → form/pl-upload-plus}/index.d.ts +2 -1
  95. package/dist/components/{pl-upload-plus → form/pl-upload-plus}/pl-upload-plus.vue.d.ts +14 -14
  96. package/dist/components/form/pl-upload-plus/types/FileExtension.d.ts +1 -0
  97. package/dist/components/{pl-icon → shared/pl-icon}/index.d.ts +3 -2
  98. package/dist/components/shared/pl-icon/pl-icon.vue.d.ts +13 -0
  99. package/dist/components/shared/pl-icon/types/index.d.ts +3 -0
  100. package/dist/components/{pl-label → shared/pl-label}/pl-label.vue.d.ts +3 -3
  101. package/dist/components/shared/pl-mark-text/index.d.ts +16 -0
  102. package/dist/components/shared/pl-mark-text/pl-mark-text.vue.d.ts +16 -0
  103. package/dist/components/{pl-option → shared/pl-option}/index.d.ts +2 -1
  104. package/dist/components/{pl-option → shared/pl-option}/pl-option.vue.d.ts +7 -7
  105. package/dist/components/{pl-tab-pane → shared/pl-tab-pane}/index.d.ts +2 -1
  106. package/dist/components/{pl-tab-pane → shared/pl-tab-pane}/pl-tab-pane.vue.d.ts +10 -9
  107. package/dist/components/{pl-tab-pane → shared/pl-tab-pane}/types/index.d.ts +2 -1
  108. package/dist/components/{pl-tags/pl-tags.vue.d.ts → shared/pl-tags-chips/pl-tags-chips.vue.d.ts} +8 -8
  109. package/dist/components/shared/pl-text/components/pl-body1.vue.d.ts +21 -0
  110. package/dist/components/shared/pl-text/components/pl-body2.vue.d.ts +21 -0
  111. package/dist/components/shared/pl-text/components/pl-body3.vue.d.ts +21 -0
  112. package/dist/components/shared/pl-text/components/pl-bodyu.vue.d.ts +21 -0
  113. package/dist/components/shared/pl-text/components/pl-btn1.vue.d.ts +21 -0
  114. package/dist/components/shared/pl-text/components/pl-btn2.vue.d.ts +21 -0
  115. package/dist/components/shared/pl-text/components/pl-btn3.vue.d.ts +21 -0
  116. package/dist/components/shared/pl-text/components/pl-cap.vue.d.ts +21 -0
  117. package/dist/components/shared/pl-text/components/pl-h1.vue.d.ts +21 -0
  118. package/dist/components/shared/pl-text/components/pl-h2.vue.d.ts +21 -0
  119. package/dist/components/shared/pl-text/components/pl-h3.vue.d.ts +21 -0
  120. package/dist/components/shared/pl-text/components/pl-h4.vue.d.ts +21 -0
  121. package/dist/components/shared/pl-text/components/pl-sub1.vue.d.ts +17 -0
  122. package/dist/components/shared/pl-text/components/pl-sub2.vue.d.ts +17 -0
  123. package/dist/components/shared/pl-text/components/pl-system.vue.d.ts +17 -0
  124. package/dist/components/shared/pl-text/components/pl-tag.vue.d.ts +17 -0
  125. package/dist/components/shared/pl-text/components/pl-title1.vue.d.ts +17 -0
  126. package/dist/components/shared/pl-text/components/pl-title2.vue.d.ts +17 -0
  127. package/dist/components/shared/pl-text/components/pl-title3.vue.d.ts +17 -0
  128. package/dist/components/{pl-text → shared/pl-text}/index.d.ts +2 -1
  129. package/dist/directives/index.d.ts +3 -1
  130. package/dist/directives/vInfiniteScroll/vInfiniteScroll.d.ts +2 -1
  131. package/dist/directives/vLoading.d.ts +2 -1
  132. package/dist/directives/vTap.d.ts +2 -1
  133. package/dist/directives/vTouchOutside.d.ts +2 -1
  134. package/dist/install-function/index.d.ts +4 -3
  135. package/dist/pl-components-pack-v3.d.ts +0 -2
  136. package/dist/pl-components-pack-v3.es.js +16896 -17035
  137. package/dist/pl-components-pack-v3.umd.js +41 -42
  138. package/dist/plugins/filters.d.ts +5 -3
  139. package/dist/plugins/loading/loading.d.ts +3 -1
  140. package/dist/services/plLoading.d.ts +1 -1
  141. package/dist/style.css +1 -1
  142. package/dist/utils/dadataParser.d.ts +2 -1
  143. package/dist/utils/deepSet.d.ts +3 -2
  144. package/dist/utils/formatAccount.d.ts +1 -1
  145. package/dist/utils/getSourceCode.d.ts +4 -1
  146. package/package.json +67 -79
  147. package/dist/components/entry.d.ts +0 -88
  148. package/dist/components/pl-icon/pl-icon.vue.d.ts +0 -12
  149. package/dist/components/pl-icon/types/index.d.ts +0 -2
  150. package/dist/components/pl-mark-text/index.d.ts +0 -2
  151. package/dist/components/pl-snackbar/renderSnackbar.d.ts +0 -4
  152. package/dist/components/pl-snackbar/types.d.ts +0 -21
  153. package/dist/components/pl-tabs/components/pl-tab-counter.vue.d.ts +0 -21
  154. package/dist/components/pl-text/components/pl-body1.vue.d.ts +0 -21
  155. package/dist/components/pl-text/components/pl-body2.vue.d.ts +0 -21
  156. package/dist/components/pl-text/components/pl-body3.vue.d.ts +0 -21
  157. package/dist/components/pl-text/components/pl-bodyu.vue.d.ts +0 -21
  158. package/dist/components/pl-text/components/pl-btn1.vue.d.ts +0 -21
  159. package/dist/components/pl-text/components/pl-btn2.vue.d.ts +0 -21
  160. package/dist/components/pl-text/components/pl-btn3.vue.d.ts +0 -21
  161. package/dist/components/pl-text/components/pl-cap.vue.d.ts +0 -21
  162. package/dist/components/pl-text/components/pl-h1.vue.d.ts +0 -21
  163. package/dist/components/pl-text/components/pl-h2.vue.d.ts +0 -21
  164. package/dist/components/pl-text/components/pl-h3.vue.d.ts +0 -21
  165. package/dist/components/pl-text/components/pl-h4.vue.d.ts +0 -21
  166. package/dist/components/pl-text/components/pl-sub1.vue.d.ts +0 -17
  167. package/dist/components/pl-text/components/pl-sub2.vue.d.ts +0 -17
  168. package/dist/components/pl-text/components/pl-system.vue.d.ts +0 -17
  169. package/dist/components/pl-text/components/pl-tag.vue.d.ts +0 -17
  170. package/dist/components/pl-text/components/pl-title1.vue.d.ts +0 -17
  171. package/dist/components/pl-text/components/pl-title2.vue.d.ts +0 -17
  172. package/dist/components/pl-text/components/pl-title3.vue.d.ts +0 -17
  173. package/dist/components/pl-upload-plus/types/FileExtension.d.ts +0 -1
  174. package/dist/mockServiceWorker.js +0 -364
  175. /package/dist/components/{pl-scrollbar → basic/pl-scrollbar}/utils/getSizeWithUnits.d.ts +0 -0
  176. /package/dist/components/{pl-date-picker-plus → form/pl-date-picker-plus}/common/constants.d.ts +0 -0
  177. /package/dist/components/{pl-icon → shared/pl-icon}/types/iconsType.d.ts +0 -0
@@ -1,21 +0,0 @@
1
- interface IProps {
2
- color?: string;
3
- }
4
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<IProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<IProps>>>, {}, {}>, {
5
- default?(_: {}): any;
6
- }>;
7
- export default _default;
8
- declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
9
- declare type __VLS_TypePropsToRuntimeProps<T> = {
10
- [K in keyof T]-?: {} extends Pick<T, K> ? {
11
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
12
- } : {
13
- type: import('vue').PropType<T[K]>;
14
- required: true;
15
- };
16
- };
17
- declare type __VLS_WithTemplateSlots<T, S> = T & {
18
- new (): {
19
- $slots: S;
20
- };
21
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1,17 +0,0 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
- color: {
3
- type: StringConstructor;
4
- };
5
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
- color: {
7
- type: StringConstructor;
8
- };
9
- }>>, {}, {}>, {
10
- default?(_: {}): any;
11
- }>;
12
- export default _default;
13
- declare type __VLS_WithTemplateSlots<T, S> = T & {
14
- new (): {
15
- $slots: S;
16
- };
17
- };
@@ -1 +0,0 @@
1
- export declare type FileExtension = 'doc' | 'docx' | 'pdf' | 'jpeg' | 'jpg' | 'tiff' | 'tif' | 'png' | 'xlsx' | 'xls' | 'txt' | 'p7s' | 'csv' | 'rar' | 'zip' | '7z';
@@ -1,364 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
-
4
- /**
5
- * Mock Service Worker (0.43.1).
6
- * @see https://github.com/mswjs/msw
7
- * - Please do NOT modify this file.
8
- * - Please do NOT serve this file on production.
9
- */
10
-
11
- const INTEGRITY_CHECKSUM = 'c9450df6e4dc5e45740c3b0b640727a2';
12
- const activeClientIds = new Set();
13
-
14
- self.addEventListener('install', function () {
15
- self.skipWaiting();
16
- });
17
-
18
- self.addEventListener('activate', function (event) {
19
- event.waitUntil(self.clients.claim());
20
- });
21
-
22
- self.addEventListener('message', async function (event) {
23
- const clientId = event.source.id;
24
-
25
- if (!clientId || !self.clients) {
26
- return;
27
- }
28
-
29
- const client = await self.clients.get(clientId);
30
-
31
- if (!client) {
32
- return;
33
- }
34
-
35
- const allClients = await self.clients.matchAll({
36
- type: 'window',
37
- });
38
-
39
- switch (event.data) {
40
- case 'KEEPALIVE_REQUEST': {
41
- sendToClient(client, {
42
- type: 'KEEPALIVE_RESPONSE',
43
- });
44
- break;
45
- }
46
-
47
- case 'INTEGRITY_CHECK_REQUEST': {
48
- sendToClient(client, {
49
- type: 'INTEGRITY_CHECK_RESPONSE',
50
- payload: INTEGRITY_CHECKSUM,
51
- });
52
- break;
53
- }
54
-
55
- case 'MOCK_ACTIVATE': {
56
- activeClientIds.add(clientId);
57
-
58
- sendToClient(client, {
59
- type: 'MOCKING_ENABLED',
60
- payload: true,
61
- });
62
- break;
63
- }
64
-
65
- case 'MOCK_DEACTIVATE': {
66
- activeClientIds.delete(clientId);
67
- break;
68
- }
69
-
70
- case 'CLIENT_CLOSED': {
71
- activeClientIds.delete(clientId);
72
-
73
- const remainingClients = allClients.filter((client) => {
74
- return client.id !== clientId;
75
- });
76
-
77
- // Unregister itself when there are no more clients
78
- if (remainingClients.length === 0) {
79
- self.registration.unregister();
80
- }
81
-
82
- break;
83
- }
84
- }
85
- });
86
-
87
- self.addEventListener('fetch', function (event) {
88
- const { request } = event;
89
- const accept = request.headers.get('accept') || '';
90
-
91
- // Bypass server-sent events.
92
- if (accept.includes('text/event-stream')) {
93
- return;
94
- }
95
-
96
- // Bypass navigation requests.
97
- if (request.mode === 'navigate') {
98
- return;
99
- }
100
-
101
- // Opening the DevTools triggers the "only-if-cached" request
102
- // that cannot be handled by the worker. Bypass such requests.
103
- if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
104
- return;
105
- }
106
-
107
- // Bypass all requests when there are no active clients.
108
- // Prevents the self-unregistered worked from handling requests
109
- // after it's been deleted (still remains active until the next reload).
110
- if (activeClientIds.size === 0) {
111
- return;
112
- }
113
-
114
- // Generate unique request ID.
115
- const requestId = Math.random().toString(16).slice(2);
116
-
117
- event.respondWith(
118
- handleRequest(event, requestId).catch((error) => {
119
- if (error.name === 'NetworkError') {
120
- console.warn(
121
- '[MSW] Successfully emulated a network error for the "%s %s" request.',
122
- request.method,
123
- request.url,
124
- );
125
- return;
126
- }
127
-
128
- // At this point, any exception indicates an issue with the original request/response.
129
- console.error(
130
- `\
131
- [MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
132
- request.method,
133
- request.url,
134
- `${error.name}: ${error.message}`,
135
- );
136
- }),
137
- );
138
- });
139
-
140
- async function handleRequest(event, requestId) {
141
- const client = await resolveMainClient(event);
142
- const response = await getResponse(event, client, requestId);
143
-
144
- // Send back the response clone for the "response:*" life-cycle events.
145
- // Ensure MSW is active and ready to handle the message, otherwise
146
- // this message will pend indefinitely.
147
- if (client && activeClientIds.has(client.id)) {
148
- (async function () {
149
- const clonedResponse = response.clone();
150
- sendToClient(client, {
151
- type: 'RESPONSE',
152
- payload: {
153
- requestId,
154
- type: clonedResponse.type,
155
- ok: clonedResponse.ok,
156
- status: clonedResponse.status,
157
- statusText: clonedResponse.statusText,
158
- body: clonedResponse.body === null ? null : await clonedResponse.text(),
159
- headers: Object.fromEntries(clonedResponse.headers.entries()),
160
- redirected: clonedResponse.redirected,
161
- },
162
- });
163
- })();
164
- }
165
-
166
- return response;
167
- }
168
-
169
- // Resolve the main client for the given event.
170
- // Client that issues a request doesn't necessarily equal the client
171
- // that registered the worker. It's with the latter the worker should
172
- // communicate with during the response resolving phase.
173
- async function resolveMainClient(event) {
174
- const client = await self.clients.get(event.clientId);
175
-
176
- if (client.frameType === 'top-level') {
177
- return client;
178
- }
179
-
180
- const allClients = await self.clients.matchAll({
181
- type: 'window',
182
- });
183
-
184
- return allClients
185
- .filter((client) => {
186
- // Get only those clients that are currently visible.
187
- return client.visibilityState === 'visible';
188
- })
189
- .find((client) => {
190
- // Find the client ID that's recorded in the
191
- // set of clients that have registered the worker.
192
- return activeClientIds.has(client.id);
193
- });
194
- }
195
-
196
- async function getResponse(event, client, requestId) {
197
- const { request } = event;
198
- const clonedRequest = request.clone();
199
-
200
- function passthrough() {
201
- // Clone the request because it might've been already used
202
- // (i.e. its body has been read and sent to the cilent).
203
- const headers = Object.fromEntries(clonedRequest.headers.entries());
204
-
205
- // Remove MSW-specific request headers so the bypassed requests
206
- // comply with the server's CORS preflight check.
207
- // Operate with the headers as an object because request "Headers"
208
- // are immutable.
209
- delete headers['x-msw-bypass'];
210
-
211
- return fetch(clonedRequest, { headers });
212
- }
213
-
214
- // Bypass mocking when the client is not active.
215
- if (!client) {
216
- return passthrough();
217
- }
218
-
219
- // Bypass initial page load requests (i.e. static assets).
220
- // The absence of the immediate/parent client in the map of the active clients
221
- // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
222
- // and is not ready to handle requests.
223
- if (!activeClientIds.has(client.id)) {
224
- return passthrough();
225
- }
226
-
227
- // Bypass requests with the explicit bypass header.
228
- // Such requests can be issued by "ctx.fetch()".
229
- if (request.headers.get('x-msw-bypass') === 'true') {
230
- return passthrough();
231
- }
232
-
233
- // Create a communication channel scoped to the current request.
234
- // This way events can be exchanged outside of the worker's global
235
- // "message" event listener (i.e. abstracted into functions).
236
- const operationChannel = new BroadcastChannel(`msw-response-stream-${requestId}`);
237
-
238
- // Notify the client that a request has been intercepted.
239
- const clientMessage = await sendToClient(client, {
240
- type: 'REQUEST',
241
- payload: {
242
- id: requestId,
243
- url: request.url,
244
- method: request.method,
245
- headers: Object.fromEntries(request.headers.entries()),
246
- cache: request.cache,
247
- mode: request.mode,
248
- credentials: request.credentials,
249
- destination: request.destination,
250
- integrity: request.integrity,
251
- redirect: request.redirect,
252
- referrer: request.referrer,
253
- referrerPolicy: request.referrerPolicy,
254
- body: await request.text(),
255
- bodyUsed: request.bodyUsed,
256
- keepalive: request.keepalive,
257
- },
258
- });
259
-
260
- switch (clientMessage.type) {
261
- case 'MOCK_RESPONSE': {
262
- return respondWithMock(clientMessage.payload);
263
- }
264
-
265
- case 'MOCK_RESPONSE_START': {
266
- return respondWithMockStream(operationChannel, clientMessage.payload);
267
- }
268
-
269
- case 'MOCK_NOT_FOUND': {
270
- return passthrough();
271
- }
272
-
273
- case 'NETWORK_ERROR': {
274
- const { name, message } = clientMessage.payload;
275
- const networkError = new Error(message);
276
- networkError.name = name;
277
-
278
- // Rejecting a "respondWith" promise emulates a network error.
279
- throw networkError;
280
- }
281
-
282
- case 'INTERNAL_ERROR': {
283
- const parsedBody = JSON.parse(clientMessage.payload.body);
284
-
285
- console.error(
286
- `\
287
- [MSW] Uncaught exception in the request handler for "%s %s":
288
-
289
- ${parsedBody.location}
290
-
291
- This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error, as it indicates a mistake in your code. If you wish to mock an error response, please see this guide: https://mswjs.io/docs/recipes/mocking-error-responses\
292
- `,
293
- request.method,
294
- request.url,
295
- );
296
-
297
- return respondWithMock(clientMessage.payload);
298
- }
299
- }
300
-
301
- return passthrough();
302
- }
303
-
304
- function sendToClient(client, message) {
305
- return new Promise((resolve, reject) => {
306
- const channel = new MessageChannel();
307
-
308
- channel.port1.onmessage = (event) => {
309
- if (event.data && event.data.error) {
310
- return reject(event.data.error);
311
- }
312
-
313
- resolve(event.data);
314
- };
315
-
316
- client.postMessage(JSON.stringify(message), [channel.port2]);
317
- });
318
- }
319
-
320
- function sleep(timeMs) {
321
- return new Promise((resolve) => {
322
- setTimeout(resolve, timeMs);
323
- });
324
- }
325
-
326
- async function respondWithMock(response) {
327
- await sleep(response.delay);
328
- return new Response(response.body, response);
329
- }
330
-
331
- function respondWithMockStream(operationChannel, mockResponse) {
332
- let streamCtrl;
333
- const stream = new ReadableStream({
334
- start: (controller) => (streamCtrl = controller),
335
- });
336
-
337
- return new Promise(async (resolve, reject) => {
338
- operationChannel.onmessageerror = (event) => {
339
- operationChannel.close();
340
- return reject(event.data.error);
341
- };
342
-
343
- operationChannel.onmessage = (event) => {
344
- if (!event.data) {
345
- return;
346
- }
347
-
348
- switch (event.data.type) {
349
- case 'MOCK_RESPONSE_CHUNK': {
350
- streamCtrl.enqueue(event.data.payload);
351
- break;
352
- }
353
-
354
- case 'MOCK_RESPONSE_END': {
355
- streamCtrl.close();
356
- operationChannel.close();
357
- }
358
- }
359
- };
360
-
361
- await sleep(mockResponse.delay);
362
- return resolve(new Response(stream, mockResponse));
363
- });
364
- }