@claspo/common 7.3.1-dev.4 → 7.3.1

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 (228) hide show
  1. package/{out/component-manifest → component-manifest}/PropertyPaneManifest.interface.d.ts +7 -0
  2. package/component-manifest/PropertyPaneManifest.interface.js +1 -0
  3. package/document/autofill.interface.d.ts +6 -0
  4. package/document/autofill.interface.js +1 -0
  5. package/document/hidden-fields.interface.d.ts +15 -0
  6. package/document/hidden-fields.interface.js +1 -0
  7. package/document/source.interface.d.ts +32 -0
  8. package/package.json +2 -2
  9. package/velocity/SysVelocityRenderer.js +1 -0
  10. package/coverage/lcov-report/block-navigation.js +0 -87
  11. package/coverage/lcov-report/prettify.js +0 -2
  12. package/coverage/lcov-report/sorter.js +0 -196
  13. package/jest.config.ts +0 -204
  14. package/out/component-manifest/PropertyPaneManifest.interface.js +0 -1
  15. package/out/document/hidden-fields.interface.d.ts +0 -46
  16. package/out/package.json +0 -50
  17. package/out/velocity/SysVelocityRenderer.js +0 -1
  18. package/src/DefaultEventEmitter.test.ts +0 -84
  19. package/src/DefaultEventEmitter.ts +0 -96
  20. package/src/HttpAbortableLoader.ts +0 -35
  21. package/src/InAppLayoutType.ts +0 -6
  22. package/src/LayoutType.ts +0 -18
  23. package/src/PrizePool.interface.ts +0 -32
  24. package/src/RenderMode.ts +0 -10
  25. package/src/UuidGenerator.ts +0 -16
  26. package/src/WidgetInitConfig.interface.ts +0 -163
  27. package/src/WidgetType.ts +0 -18
  28. package/src/action/type.ts +0 -7
  29. package/src/async/createAsyncIterator.ts +0 -33
  30. package/src/async/debounce.ts +0 -28
  31. package/src/async/timeout.ts +0 -3
  32. package/src/component-manifest/ComponentManifest.interface.ts +0 -160
  33. package/src/component-manifest/ContextMenuManifest.interface.ts +0 -52
  34. package/src/component-manifest/DisplayCondition.interface.ts +0 -65
  35. package/src/component-manifest/FloatingControlManifest.interface.ts +0 -89
  36. package/src/component-manifest/PropPathCondition.interface.ts +0 -4
  37. package/src/component-manifest/PropertyPaneManifest.interface.ts +0 -614
  38. package/src/converter/time/TimeConverter.spec.ts +0 -11
  39. package/src/converter/time/TimeUnit.spec.ts +0 -12
  40. package/src/converter/time/TimeUnit.ts +0 -34
  41. package/src/converter/time/TimerConverter.ts +0 -29
  42. package/src/document/ComponentInsertType.ts +0 -6
  43. package/src/document/Document.interface.ts +0 -625
  44. package/src/document/DocumentCssVarsReplace.test.ts +0 -2947
  45. package/src/document/DocumentCssVarsReplace.ts +0 -31
  46. package/src/document/DocumentUtils.test.ts +0 -595
  47. package/src/document/DocumentUtils.ts +0 -194
  48. package/src/document/hidden-fields.interface.ts +0 -54
  49. package/src/dom/ViewportSize.ts +0 -61
  50. package/src/dom/copyToClipboard.ts +0 -17
  51. package/src/dom/getMostNestedNode.ts +0 -9
  52. package/src/dom/insertHtmlIntoElement.ts +0 -36
  53. package/src/dom/sanitizeHTML.test.ts +0 -59
  54. package/src/dom/sanitizeHTML.ts +0 -78
  55. package/src/element/BaseElementInViewportHandler.ts +0 -41
  56. package/src/element/CssVarsOperations.ts +0 -37
  57. package/src/element/ThemeCssVars.ts +0 -28
  58. package/src/element/recursiveFindParentNodeByAttribute.test.ts +0 -63
  59. package/src/element/recursiveFindParentNodeByAttribute.ts +0 -25
  60. package/src/flat.ts +0 -16
  61. package/src/handler/HandlerTypes.ts +0 -4
  62. package/src/math/RandomDistributor.test.ts +0 -35
  63. package/src/math/RandomDistributor.ts +0 -58
  64. package/src/math/sum.ts +0 -3
  65. package/src/network/HttpClient.ts +0 -28
  66. package/src/network/HttpStatus.ts +0 -4
  67. package/src/object/isDictionary.test.ts +0 -24
  68. package/src/object/isDictionary.ts +0 -13
  69. package/src/object/omitKeys.test.ts +0 -19
  70. package/src/object/omitKeys.ts +0 -20
  71. package/src/storage/BaseCachingStorage.test.ts +0 -70
  72. package/src/storage/BaseCachingStorage.ts +0 -37
  73. package/src/storage/CachingCookieStorage.test.ts +0 -75
  74. package/src/storage/CachingCookieStorage.ts +0 -36
  75. package/src/storage/CachingLocalStorage.test.ts +0 -59
  76. package/src/storage/CachingLocalStorage.ts +0 -34
  77. package/src/storage/getCookie.test.ts +0 -53
  78. package/src/storage/getCookie.ts +0 -10
  79. package/src/storage/setCookie.test.ts +0 -97
  80. package/src/storage/setCookie.ts +0 -49
  81. package/src/theme/theme.utils.ts +0 -50
  82. package/src/url/sanitizeUrl.test.ts +0 -62
  83. package/src/url/sanitizeUrl.ts +0 -51
  84. package/src/utils/CaseTransformer.test.ts +0 -16
  85. package/src/utils/CaseTransformer.ts +0 -10
  86. package/src/utils/NullishCoalescingOperator.ts +0 -3
  87. package/src/utils/NumericDecline.ts +0 -25
  88. package/src/utils/addEventListener.ts +0 -23
  89. package/src/utils/allSettled.ts +0 -6
  90. package/src/utils/checkTimeZone.spec.ts +0 -18
  91. package/src/utils/checkTimeZone.ts +0 -6
  92. package/src/utils/deviceUtils.ts +0 -12
  93. package/src/utils/flatMap.test.ts +0 -21
  94. package/src/utils/flatMap.ts +0 -3
  95. package/src/utils/fromEntries.ts +0 -6
  96. package/src/utils/generateRandomNumber.test.ts +0 -23
  97. package/src/utils/generateRandomNumber.ts +0 -3
  98. package/src/utils/objectSort.ts +0 -41
  99. package/src/utils/orientationUtils.ts +0 -18
  100. package/src/velocity/SysVelocityContext.spec.ts +0 -88
  101. package/src/velocity/SysVelocityContext.ts +0 -129
  102. package/src/velocity/SysVelocityRenderer.spec.ts +0 -36
  103. package/src/velocity/SysVelocityRenderer.ts +0 -11
  104. package/test/__mocks/jestGlobalMocks.js +0 -1887
  105. /package/{out/DefaultEventEmitter.d.ts → DefaultEventEmitter.d.ts} +0 -0
  106. /package/{out/DefaultEventEmitter.js → DefaultEventEmitter.js} +0 -0
  107. /package/{out/HttpAbortableLoader.d.ts → HttpAbortableLoader.d.ts} +0 -0
  108. /package/{out/HttpAbortableLoader.js → HttpAbortableLoader.js} +0 -0
  109. /package/{out/InAppLayoutType.d.ts → InAppLayoutType.d.ts} +0 -0
  110. /package/{out/InAppLayoutType.js → InAppLayoutType.js} +0 -0
  111. /package/{out/LayoutType.d.ts → LayoutType.d.ts} +0 -0
  112. /package/{out/LayoutType.js → LayoutType.js} +0 -0
  113. /package/{out/PrizePool.interface.d.ts → PrizePool.interface.d.ts} +0 -0
  114. /package/{out/PrizePool.interface.js → PrizePool.interface.js} +0 -0
  115. /package/{out/RenderMode.d.ts → RenderMode.d.ts} +0 -0
  116. /package/{out/RenderMode.js → RenderMode.js} +0 -0
  117. /package/{out/UuidGenerator.d.ts → UuidGenerator.d.ts} +0 -0
  118. /package/{out/UuidGenerator.js → UuidGenerator.js} +0 -0
  119. /package/{out/WidgetInitConfig.interface.d.ts → WidgetInitConfig.interface.d.ts} +0 -0
  120. /package/{out/WidgetInitConfig.interface.js → WidgetInitConfig.interface.js} +0 -0
  121. /package/{out/WidgetType.d.ts → WidgetType.d.ts} +0 -0
  122. /package/{out/WidgetType.js → WidgetType.js} +0 -0
  123. /package/{out/action → action}/type.d.ts +0 -0
  124. /package/{out/action → action}/type.js +0 -0
  125. /package/{out/async → async}/createAsyncIterator.d.ts +0 -0
  126. /package/{out/async → async}/createAsyncIterator.js +0 -0
  127. /package/{out/async → async}/debounce.d.ts +0 -0
  128. /package/{out/async → async}/debounce.js +0 -0
  129. /package/{out/async → async}/timeout.d.ts +0 -0
  130. /package/{out/async → async}/timeout.js +0 -0
  131. /package/{out/component-manifest → component-manifest}/ComponentManifest.interface.d.ts +0 -0
  132. /package/{out/component-manifest → component-manifest}/ComponentManifest.interface.js +0 -0
  133. /package/{out/component-manifest → component-manifest}/ContextMenuManifest.interface.d.ts +0 -0
  134. /package/{out/component-manifest → component-manifest}/ContextMenuManifest.interface.js +0 -0
  135. /package/{out/component-manifest → component-manifest}/DisplayCondition.interface.d.ts +0 -0
  136. /package/{out/component-manifest → component-manifest}/DisplayCondition.interface.js +0 -0
  137. /package/{out/component-manifest → component-manifest}/FloatingControlManifest.interface.d.ts +0 -0
  138. /package/{out/component-manifest → component-manifest}/FloatingControlManifest.interface.js +0 -0
  139. /package/{out/component-manifest → component-manifest}/PropPathCondition.interface.d.ts +0 -0
  140. /package/{out/component-manifest → component-manifest}/PropPathCondition.interface.js +0 -0
  141. /package/{out/converter → converter}/time/TimeUnit.d.ts +0 -0
  142. /package/{out/converter → converter}/time/TimeUnit.js +0 -0
  143. /package/{out/converter → converter}/time/TimerConverter.d.ts +0 -0
  144. /package/{out/converter → converter}/time/TimerConverter.js +0 -0
  145. /package/{out/document → document}/ComponentInsertType.d.ts +0 -0
  146. /package/{out/document → document}/ComponentInsertType.js +0 -0
  147. /package/{out/document → document}/Document.interface.d.ts +0 -0
  148. /package/{out/document → document}/Document.interface.js +0 -0
  149. /package/{out/document → document}/DocumentCssVarsReplace.d.ts +0 -0
  150. /package/{out/document → document}/DocumentCssVarsReplace.js +0 -0
  151. /package/{out/document → document}/DocumentUtils.d.ts +0 -0
  152. /package/{out/document → document}/DocumentUtils.js +0 -0
  153. /package/{out/document/hidden-fields.interface.js → document/source.interface.js} +0 -0
  154. /package/{out/dom → dom}/ViewportSize.d.ts +0 -0
  155. /package/{out/dom → dom}/ViewportSize.js +0 -0
  156. /package/{out/dom → dom}/copyToClipboard.d.ts +0 -0
  157. /package/{out/dom → dom}/copyToClipboard.js +0 -0
  158. /package/{out/dom → dom}/getMostNestedNode.d.ts +0 -0
  159. /package/{out/dom → dom}/getMostNestedNode.js +0 -0
  160. /package/{out/dom → dom}/insertHtmlIntoElement.d.ts +0 -0
  161. /package/{out/dom → dom}/insertHtmlIntoElement.js +0 -0
  162. /package/{out/dom → dom}/sanitizeHTML.d.ts +0 -0
  163. /package/{out/dom → dom}/sanitizeHTML.js +0 -0
  164. /package/{out/element → element}/BaseElementInViewportHandler.d.ts +0 -0
  165. /package/{out/element → element}/BaseElementInViewportHandler.js +0 -0
  166. /package/{out/element → element}/CssVarsOperations.d.ts +0 -0
  167. /package/{out/element → element}/CssVarsOperations.js +0 -0
  168. /package/{out/element → element}/ThemeCssVars.d.ts +0 -0
  169. /package/{out/element → element}/ThemeCssVars.js +0 -0
  170. /package/{out/element → element}/recursiveFindParentNodeByAttribute.d.ts +0 -0
  171. /package/{out/element → element}/recursiveFindParentNodeByAttribute.js +0 -0
  172. /package/{out/flat.d.ts → flat.d.ts} +0 -0
  173. /package/{out/flat.js → flat.js} +0 -0
  174. /package/{out/handler → handler}/HandlerTypes.d.ts +0 -0
  175. /package/{out/handler → handler}/HandlerTypes.js +0 -0
  176. /package/{out/math → math}/RandomDistributor.d.ts +0 -0
  177. /package/{out/math → math}/RandomDistributor.js +0 -0
  178. /package/{out/math → math}/sum.d.ts +0 -0
  179. /package/{out/math → math}/sum.js +0 -0
  180. /package/{out/network → network}/HttpClient.d.ts +0 -0
  181. /package/{out/network → network}/HttpClient.js +0 -0
  182. /package/{out/network → network}/HttpStatus.d.ts +0 -0
  183. /package/{out/network → network}/HttpStatus.js +0 -0
  184. /package/{out/object → object}/isDictionary.d.ts +0 -0
  185. /package/{out/object → object}/isDictionary.js +0 -0
  186. /package/{out/object → object}/omitKeys.d.ts +0 -0
  187. /package/{out/object → object}/omitKeys.js +0 -0
  188. /package/{out/storage → storage}/BaseCachingStorage.d.ts +0 -0
  189. /package/{out/storage → storage}/BaseCachingStorage.js +0 -0
  190. /package/{out/storage → storage}/CachingCookieStorage.d.ts +0 -0
  191. /package/{out/storage → storage}/CachingCookieStorage.js +0 -0
  192. /package/{out/storage → storage}/CachingLocalStorage.d.ts +0 -0
  193. /package/{out/storage → storage}/CachingLocalStorage.js +0 -0
  194. /package/{out/storage → storage}/getCookie.d.ts +0 -0
  195. /package/{out/storage → storage}/getCookie.js +0 -0
  196. /package/{out/storage → storage}/setCookie.d.ts +0 -0
  197. /package/{out/storage → storage}/setCookie.js +0 -0
  198. /package/{out/theme → theme}/theme.utils.d.ts +0 -0
  199. /package/{out/theme → theme}/theme.utils.js +0 -0
  200. /package/{out/url → url}/sanitizeUrl.d.ts +0 -0
  201. /package/{out/url → url}/sanitizeUrl.js +0 -0
  202. /package/{out/utils → utils}/CaseTransformer.d.ts +0 -0
  203. /package/{out/utils → utils}/CaseTransformer.js +0 -0
  204. /package/{out/utils → utils}/NullishCoalescingOperator.d.ts +0 -0
  205. /package/{out/utils → utils}/NullishCoalescingOperator.js +0 -0
  206. /package/{out/utils → utils}/NumericDecline.d.ts +0 -0
  207. /package/{out/utils → utils}/NumericDecline.js +0 -0
  208. /package/{out/utils → utils}/addEventListener.d.ts +0 -0
  209. /package/{out/utils → utils}/addEventListener.js +0 -0
  210. /package/{out/utils → utils}/allSettled.d.ts +0 -0
  211. /package/{out/utils → utils}/allSettled.js +0 -0
  212. /package/{out/utils → utils}/checkTimeZone.d.ts +0 -0
  213. /package/{out/utils → utils}/checkTimeZone.js +0 -0
  214. /package/{out/utils → utils}/deviceUtils.d.ts +0 -0
  215. /package/{out/utils → utils}/deviceUtils.js +0 -0
  216. /package/{out/utils → utils}/flatMap.d.ts +0 -0
  217. /package/{out/utils → utils}/flatMap.js +0 -0
  218. /package/{out/utils → utils}/fromEntries.d.ts +0 -0
  219. /package/{out/utils → utils}/fromEntries.js +0 -0
  220. /package/{out/utils → utils}/generateRandomNumber.d.ts +0 -0
  221. /package/{out/utils → utils}/generateRandomNumber.js +0 -0
  222. /package/{out/utils → utils}/objectSort.d.ts +0 -0
  223. /package/{out/utils → utils}/objectSort.js +0 -0
  224. /package/{out/utils → utils}/orientationUtils.d.ts +0 -0
  225. /package/{out/utils → utils}/orientationUtils.js +0 -0
  226. /package/{out/velocity → velocity}/SysVelocityContext.d.ts +0 -0
  227. /package/{out/velocity → velocity}/SysVelocityContext.js +0 -0
  228. /package/{out/velocity → velocity}/SysVelocityRenderer.d.ts +0 -0
@@ -1,46 +0,0 @@
1
- export declare enum SourceType {
2
- STATIC = "STATIC",
3
- DATA_LAYER = "DATA_LAYER",
4
- URL_QUERY_PARAMS = "URL_QUERY_PARAMS",
5
- JS_API_VARIABLE = "JS_API_VARIABLE",
6
- COOKIE = "COOKIE",
7
- LOCAL_STORAGE = "LOCAL_STORAGE"
8
- }
9
- export interface HiddenFieldSourceArgumentI {
10
- name: string;
11
- value: string;
12
- type?: string;
13
- placeholder?: string;
14
- [key: string]: any;
15
- }
16
- export interface StaticSourceConfigI {
17
- value: string;
18
- [key: string]: any;
19
- }
20
- export interface HiddenFieldArgumentsConfigI {
21
- arguments?: HiddenFieldSourceArgumentI[];
22
- fallbackValue?: string;
23
- [key: string]: any;
24
- }
25
- export interface HiddenFieldConfigBySource {
26
- [SourceType.STATIC]: StaticSourceConfigI;
27
- [SourceType.DATA_LAYER]: HiddenFieldArgumentsConfigI;
28
- [SourceType.URL_QUERY_PARAMS]: HiddenFieldArgumentsConfigI;
29
- [SourceType.JS_API_VARIABLE]: HiddenFieldArgumentsConfigI;
30
- [SourceType.COOKIE]: HiddenFieldArgumentsConfigI;
31
- [SourceType.LOCAL_STORAGE]: HiddenFieldArgumentsConfigI;
32
- }
33
- export interface HiddenFieldSharedBaseI {
34
- id: string;
35
- name: string;
36
- label: string;
37
- options: [];
38
- type: 'HIDDEN';
39
- }
40
- export type HiddenFieldSharedI<S extends SourceType = SourceType> = HiddenFieldSharedBaseI & {
41
- sourceType: S;
42
- config: HiddenFieldConfigBySource[S];
43
- };
44
- export type AnyHiddenFieldSharedI = {
45
- [S in SourceType]: HiddenFieldSharedI<S>;
46
- }[SourceType];
package/out/package.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "name": "@claspo/common",
3
- "version": "7.3.1-dev.3",
4
- "description": "",
5
- "main": "index.js",
6
- "engines": {
7
- "node": ">=18.16.0"
8
- },
9
- "directories": {
10
- "test": "test"
11
- },
12
- "files": [
13
- "**/*.js",
14
- "**/*.ts",
15
- "**/package.json",
16
- "!**/*.test.js",
17
- "!**/*.test.d.ts",
18
- "!**/*.spec.js",
19
- "!**/*.spec.d.ts"
20
- ],
21
- "scripts": {
22
- "test": "jest --no-cache --coverage",
23
- "build": "rm -rf out && tsc --project tsconfig.json && npm run minify",
24
- "build:docs": "rm -rf ./docs && typedoc --options typedoc.md.json && npx concat-md --decrease-title-levels docs > docs/index.md && find docs -name '*.md' ! -name 'index.md' -delete",
25
- "minify": "find out -name '*.js' ! -name '*.d.js' -exec terser {} --compress --mangle --output {} \\;",
26
- "dev": " tsc --project tsconfig.json --watch",
27
- "package": "npm i && npm run test && npm run build && npm run build:docs && cp package.json README.md LICENSE.md out && cd out && npm publish --access=public && cd ..",
28
- "sync:docs": "node ../../scripts/sync-docs.js --package=common"
29
- },
30
- "dependencies": {
31
- "velocityjs": "2.1.6"
32
- },
33
- "devDependencies": {
34
- "@types/jest": "^27.5.1",
35
- "concat-md": "^0.5.1",
36
- "glob": "^8.0.3",
37
- "jest": "^28.1.0",
38
- "jest-environment-jsdom": "^28.1.0",
39
- "terser": "^5.37.0",
40
- "ts-jest": "^28.0.3",
41
- "ts-node": "^10.8.0",
42
- "typedoc": "^0.28.0",
43
- "typedoc-plugin-markdown": "^4.4.1",
44
- "typedoc-plugin-no-inherit": "^1.6.1",
45
- "typescript": "^5.8.2"
46
- },
47
- "author": "alex-chernysh",
48
- "license": "LICENSE.md",
49
- "homepage": "https://docs.claspo.io/docs/claspocommon"
50
- }
@@ -1 +0,0 @@
1
- import*as Velocity from"velocityjs";import SysVelocityContext from"./SysVelocityContext";const sysCtx=(new SysVelocityContext).create();export default class SysVelocityRenderer{render(e,t){return Velocity.render(e,Object.assign(Object.assign({},sysCtx),t))}}
@@ -1,84 +0,0 @@
1
- import DefaultEventEmitter from './DefaultEventEmitter';
2
-
3
- describe('DefaultEventEmitter', () => {
4
-
5
- it('should not call listeners for event other events', function () {
6
-
7
- // GIVEN
8
- const defaultEventEmitter = new DefaultEventEmitter();
9
- const mockCallback = jest.fn(x => 42 + x);
10
- defaultEventEmitter.on('event 1', mockCallback);
11
- // WHEN
12
- defaultEventEmitter.emit('event 2', 324);
13
-
14
- // THEN
15
- expect(mockCallback.mock.calls.length).toBe(0);
16
- });
17
-
18
- it('should call listeners for event * ', function () {
19
-
20
- // GIVEN
21
- const defaultEventEmitter = new DefaultEventEmitter();
22
- const mockCallback = jest.fn(x => 42 + x);
23
- defaultEventEmitter.on('*', mockCallback);
24
- // WHEN
25
- defaultEventEmitter.emit('any', 324);
26
-
27
- // THEN
28
- expect(mockCallback.mock.calls[0][0]).toBe(324);
29
- });
30
-
31
- it('should call listeners for specific event', function () {
32
-
33
- // GIVEN
34
- const defaultEventEmitter = new DefaultEventEmitter();
35
- const mockCallback = jest.fn(x => 42 + x);
36
- defaultEventEmitter.on('event name', mockCallback);
37
- // WHEN
38
- defaultEventEmitter.emit('event name', 324);
39
-
40
- // THEN
41
- expect(mockCallback.mock.calls[0][0]).toBe(324);
42
- });
43
-
44
- it('off', function () {
45
-
46
- // GIVEN
47
- const emitter = new DefaultEventEmitter();
48
- const mockCallback = jest.fn(x => 42 + x);
49
- const eventName = 'event name';
50
-
51
- // WHEN
52
- const listener = emitter.on(eventName, mockCallback);
53
-
54
- // THEN
55
- expect(Object.keys(emitter.listeners[eventName]).length).toBe(1);
56
-
57
- // WHEN
58
- listener.off();
59
-
60
- // THEN
61
- expect(Object.keys(emitter.listeners[eventName]).length).toBe(0);
62
- });
63
-
64
- it('destroy', function () {
65
- // GIVEN
66
- const emitter = new DefaultEventEmitter();
67
- const mockCallback = jest.fn(x => 42 + x);
68
-
69
- // WHEN
70
- const listener1 = emitter.on('event 1', mockCallback);
71
- const listener2 = emitter.on('event 2', mockCallback);
72
-
73
- // THEN
74
- expect(Object.values(emitter.listeners).length).toBe(2 + 1);
75
-
76
- // WHEN
77
- emitter.destroy();
78
-
79
- // THEN
80
- expect(Object.values(emitter.listeners).length).toBe(1);
81
- });
82
-
83
-
84
- });
@@ -1,96 +0,0 @@
1
- import UuidGenerator from './UuidGenerator';
2
-
3
- /**
4
- * Callback function type for event listeners.
5
- * @param value - The emitted event value
6
- * @param eventName - The name of the emitted event
7
- * @param params - Additional parameters passed with the event
8
- */
9
- type EventCallback = (value: any, eventName: string, params: any) => void;
10
-
11
- /**
12
- * Map structure for storing event listeners.
13
- * Keys are event names, values are maps of listener IDs to callbacks.
14
- */
15
- type ListenersMap = Record<string, Record<string, EventCallback>>;
16
-
17
- /**
18
- * A simple event emitter implementation for pub/sub communication.
19
- * Supports named events and wildcard listeners that receive all events.
20
- * @example
21
- * const emitter = new DefaultEventEmitter();
22
- * const subscription = emitter.on('user:login', (data) => console.log(data));
23
- * emitter.emit('user:login', { userId: 123 });
24
- * subscription.off(); // Unsubscribe
25
- */
26
- export default class DefaultEventEmitter {
27
- /**
28
- * Creates the initial listeners state with wildcard listener support.
29
- * @returns Empty listeners map with wildcard entry
30
- */
31
- static createDefaultListenersState = (): ListenersMap => ({
32
- '*': {}
33
- });
34
-
35
- /** Map of event names to their registered listeners */
36
- listeners: ListenersMap;
37
-
38
- /**
39
- * Creates a new DefaultEventEmitter instance.
40
- */
41
- constructor() {
42
- this.listeners = DefaultEventEmitter.createDefaultListenersState();
43
- }
44
-
45
- /**
46
- * Emits an event to all registered listeners.
47
- * Also triggers wildcard listeners that receive all events.
48
- * @param eventName - The name of the event to emit
49
- * @param value - The value to pass to listeners
50
- * @param params - Optional additional parameters
51
- */
52
- emit(eventName: string, value: any, params: any = null): void {
53
- const eventListeners = this.listeners[eventName];
54
-
55
- if (eventListeners) {
56
- Object.values(eventListeners).forEach(cb => cb(value, eventName, params));
57
- }
58
-
59
- Object.values(this.listeners['*']).forEach(cb => cb(value, eventName, params));
60
- }
61
-
62
- /**
63
- * Registers a listener for a specific event.
64
- * Use '*' as event name to listen to all events.
65
- * @param eventName - The event name to listen for
66
- * @param listener - The callback function to invoke when the event is emitted
67
- * @returns An object with an `off` method to unsubscribe
68
- */
69
- on(eventName: string, listener: EventCallback): { off: () => void } {
70
- const uuid = UuidGenerator.generate();
71
- const eventListeners = this.listeners[eventName];
72
-
73
- if (eventListeners) {
74
- eventListeners[uuid] = listener;
75
- } else {
76
- this.listeners[eventName] = {
77
- [uuid]: listener,
78
- };
79
- }
80
-
81
- return {
82
- off: () => {
83
- if (this.listeners?.[eventName]?.[uuid]) {
84
- delete this.listeners[eventName][uuid];
85
- }
86
- }
87
- };
88
- }
89
-
90
- /**
91
- * Removes all event listeners and resets the emitter to initial state.
92
- */
93
- destroy(): void {
94
- this.listeners = DefaultEventEmitter.createDefaultListenersState();
95
- }
96
- }
@@ -1,35 +0,0 @@
1
- export default class HttpAbortableLoader {
2
- url: string;
3
- headers: Record<string, string>;
4
- httpClient: any;
5
- loaded: boolean;
6
- abortController: AbortController | null = null;
7
-
8
- constructor(url: string, headers: Record<string, string>, httpClient: any) {
9
- this.url = url;
10
- this.headers = headers;
11
- this.httpClient = httpClient;
12
- this.loaded = false;
13
- }
14
-
15
- load(): Promise<any> {
16
- if (window.AbortController) {
17
- this.abortController = new AbortController();
18
- }
19
-
20
- return this.httpClient
21
- .execute(this.url, 'GET', null, this.headers, this.abortController && this.abortController.signal)
22
- .then((r: any) => {
23
- this.loaded = true;
24
- return r;
25
- });
26
- }
27
-
28
- isLoaded(): boolean {
29
- return this.loaded;
30
- }
31
-
32
- abortLoading(): void {
33
- this.abortController && this.abortController.abort();
34
- }
35
- }
@@ -1,6 +0,0 @@
1
- export enum InAppLayoutType {
2
- SLIDE_UP = 'SLIDE_UP',
3
- POP_UP = 'POP_UP',
4
- FULL = 'FULL',
5
- BOTTOM_BAR = 'BOTTOM_BAR',
6
- }
package/src/LayoutType.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Enumeration of widget layout types.
3
- * Determines how the widget is positioned and displayed on the page.
4
- */
5
- export enum LayoutType {
6
- /** Widget embedded directly in the page content */
7
- BUILT_IN= 'BUILT_IN',
8
- /** Dialog / Popup */
9
- DETACHED = 'DETACHED',
10
- /** Floating box positioned relative to viewport corners */
11
- FLOATING_BOX = 'FLOATING_BOX',
12
- /** Horizontal bar fixed to top or bottom of viewport */
13
- FLOATING_BAR = 'FLOATING_BAR',
14
- /** Launcher trigger element that opens the main widget */
15
- LAUNCHER = 'LAUNCHER',
16
- /** Overlay that locks page content until user interaction */
17
- CONTENT_LOCKER = 'CONTENT_LOCKER',
18
- }
@@ -1,32 +0,0 @@
1
- export interface PrizePoolModelI {
2
- id: string;
3
- sourceType: PrizeSourceType;
4
- distributionType?: PrizeDistributionType;
5
- options?: PrizePoolOptionI[];
6
- }
7
-
8
- export enum PrizeSourceType {
9
- MANUAL = 'MANUAL',
10
- }
11
-
12
- export enum PrizeDistributionType {
13
- PERCENT_CHANCE = 'PERCENT_CHANCE',
14
- }
15
-
16
- export interface PrizePoolOptionI {
17
- valueType: PrizeOptionValueType;
18
- value: string;
19
- code: string;
20
- weight: number;
21
- id?: string;
22
- config?: PrizeOptionConfigI;
23
- }
24
-
25
- export enum PrizeOptionValueType {
26
- DISCOUNT_PERCENTAGE = 'DISCOUNT_PERCENTAGE',
27
- CUSTOM = 'CUSTOM',
28
- }
29
-
30
- export interface PrizeOptionConfigI {
31
- imageUrl?: string;
32
- }
package/src/RenderMode.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Enumeration of widget rendering modes.
3
- * Determines how the widget responds to model changes.
4
- */
5
- export enum RenderMode {
6
- /** Runtime mode for end users - optimized for performance */
7
- STATIC = 'STATIC',
8
- /** Editor mode with live updates - responds to model changes in real-time */
9
- UPDATING = 'UPDATING'
10
- }
@@ -1,16 +0,0 @@
1
- export default class UuidGenerator {
2
-
3
- static generate(): string {
4
- let result = '';
5
- let i: string;
6
-
7
- for (let j = 0; j < 32; j++) {
8
- if (j === 8 || j === 12 || j === 16 || j === 20) {
9
- result += '-';
10
- }
11
- i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
12
- result += i;
13
- }
14
- return result;
15
- }
16
- }
@@ -1,163 +0,0 @@
1
- import {PrizePoolModelI} from './PrizePool.interface';
2
- import {ClDocumentI} from './document/Document.interface';
3
- import {WidgetType} from './WidgetType';
4
- import {LayoutType} from './LayoutType';
5
- import {RenderMode} from './RenderMode';
6
-
7
- /**
8
- * Configuration interface for initializing a widget.
9
- */
10
- export interface WidgetInitConfigI {
11
- /** Document model containing widget structure and content */
12
- documentModel: ClDocumentI;
13
- /** Layout type */
14
- layoutType: LayoutType;
15
- /** Widget type */
16
- widgetType: WidgetType;
17
- /** Base URL for loading static resources */
18
- staticResourcesUrl: string;
19
- /** Unique identifier for the form variant
20
- * @internal
21
- * */
22
- formVariantId?: string;
23
- /**
24
- * Site identifier for multi-site deployments
25
- * @internal
26
- * */
27
- siteId?: string;
28
- /** Needs for components localization
29
- * */
30
- browserLanguage?: string;
31
- /** Needed for Multi-language widget.
32
- * */
33
- appearanceLanguage?: string;
34
- /** Additional CSS custom properties to apply * */
35
- optionalDocumentStyles?: Record<string, string>;
36
- /** Enables preview mode (disables tracking and submissions)
37
- * @internal
38
- * */
39
- previewMode?: boolean;
40
- /** Enables editor preview mode
41
- * @internal
42
- * */
43
- editorPreviewMode?: boolean;
44
- /** Enables cabinet template preview mode.
45
- * Widgets may render demo content instead of erroring when external data
46
- * (e.g. Shopify store/products) is unavailable.
47
- * @internal
48
- * */
49
- isTemplatePreview?: boolean;
50
- /** Enables demo mode
51
- * @internal
52
- * */
53
- demoMode?: boolean;
54
- /** Shows branding elements
55
- * @internal
56
- * */
57
- branded?: boolean;
58
- /** Shows upgrade plan button
59
- * @internal
60
- * */
61
- upgradePlanButton?: boolean;
62
- /** Initial view (page) index to display */
63
- viewIndex?: number;
64
- /** Forces mobile environment regardless of actual device
65
- * @internal
66
- * */
67
- forceMobileEnv?: boolean;
68
- /** Custom action factory class
69
- * @internal
70
- * */
71
- actionFactoryClass?: any;
72
- /** Unique widget identifier
73
- * @internal
74
- * @deprecated
75
- * */
76
- widgetId?: number;
77
- /** Prize pool models for gamification features */
78
- prizePoolModels?: PrizePoolModelI[];
79
- /** Pre-bundled component classes for static rendering */
80
- bundledComponentClasses?: any[];
81
- /** Needed only for Multi-language widgets.
82
- * Translation strings for internationalization */
83
- translations?: TranslationsI;
84
- /** Service for tracking user interactions (view, click, etc.)
85
- * */
86
- trackingService?: TrackingServiceI;
87
- /** Disables Google Fonts loading
88
- * @internal
89
- * */
90
- disableGoogleFonts?: boolean;
91
- /** Custom layout factory class
92
- * @internal
93
- * */
94
- layoutFactoryClass?: any;
95
- /** CSS z-index value for the widget container */
96
- zIndex?: number;
97
- /** Indicates if running in mobile environment
98
- * @internal
99
- * */
100
- isMobileEnv?: boolean;
101
- /** Disables widget interactions
102
- * @internal
103
- * */
104
- disabled?: boolean;
105
- /** Disables smart positioning logic
106
- * @internal
107
- * */
108
- disableSmartPosition?: boolean;
109
- /** Disables scrollbar width calculation
110
- * @internal
111
- * */
112
- disableScrollbarCalculation?: boolean;
113
- /** Disables layout animations* */
114
- disableLayoutAnimations?: boolean;
115
- /** CSS position value for widget display
116
- * @internal */
117
- displayPosition?: string;
118
- /** Rendering mode
119
- * @internal */
120
- renderMode?: RenderMode;
121
- /** Disables global scroll locking when widget is open */
122
- disableGlobalScroll?: boolean;
123
- /** Host URL for API requests */
124
- hostUrl?: string;
125
- /** URL endpoint for contact subscription
126
- * @internal */
127
- subscribeContactUrl?: string;
128
- /** Enables autosave-style submit flow before closing the widget */
129
- submitOnClose?: SubmitOnCloseConfigI;
130
- /** Prefix for component tag name in order to resolve conflicts between different sources of components on the same page. */
131
- productKeyPrefix?: string;
132
- /**
133
- * Hostname/URL of the user's Shopify store. Consumed by Shopify-integration
134
- * widgets (e.g. SysShopifyProductCollectionComponent) to fetch products in
135
- * editor / preview contexts. Ignored on real Shopify storefronts where the
136
- * component falls back to relative-path requests via isShopifyStorefront().
137
- */
138
- shopifyStoreUrl?: string;
139
- /** Allows additional custom properties */
140
- [key: string]: any;
141
- }
142
-
143
- export interface SubmitOnCloseConfigI {
144
- enabled: boolean;
145
- skipValidation?: boolean;
146
- }
147
-
148
- /**
149
- * Service interface for tracking user interactions and events.
150
- */
151
- export interface TrackingServiceI {
152
- /** Sends a custom event with optional payload */
153
- send: (eventName: string, payload?: any) => void;
154
- /** Tracks a click event on a specific element */
155
- trackClick: (elementId: string, payload?: any) => void;
156
- /** Tracks a target action (conversion, goal completion, etc.) */
157
- trackTargetAction: (actionType: string, payload?: any) => void;
158
- }
159
-
160
- /**
161
- * Translation dictionary mapping language codes to key-value translation pairs.
162
- */
163
- export type TranslationsI = Record<string, Record<string, string>>;
package/src/WidgetType.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Enumeration of widget types.
3
- * Defines the primary purpose and behavior of a widget.
4
- */
5
- export enum WidgetType {
6
- /** Form for collecting email subscriptions */
7
- SUBSCRIPTION_FORM = 'SUBSCRIPTION_FORM',
8
- /** Informational popup or notification */
9
- INFORMER = 'INFORMER',
10
- /** General-purpose form for collecting user data */
11
- REQUEST_FORM = 'REQUEST_FORM',
12
- /** Trigger element that opens another widget */
13
- LAUNCHER = 'LAUNCHER',
14
- /** Age verification gate */
15
- AGE_VERIFY = 'AGE_VERIFY',
16
- /** Trigger element that opens the main widget */
17
- TEASER = 'TEASER',
18
- }
@@ -1,7 +0,0 @@
1
- export function successAction(type: string): string {
2
- return `${type}_SUCCESS`;
3
- }
4
-
5
- export function failureAction(type: string): string {
6
- return `${type}_FAILED`;
7
- }
@@ -1,33 +0,0 @@
1
- interface RangeIterator extends Iterator<number> {
2
- current: number;
3
- last: number;
4
- next(): IteratorResult<number>;
5
- }
6
-
7
- interface RangeIterable extends Iterable<number> {
8
- from: number;
9
- to: number;
10
- [Symbol.iterator](): RangeIterator;
11
- }
12
-
13
- export default function createAsyncIterator(times: number): RangeIterable {
14
- return {
15
- from: 0,
16
- to: times - 1,
17
-
18
- [Symbol.iterator](): RangeIterator { // called once, in the beginning of for..of
19
- return {
20
- current: this.from,
21
- last: this.to,
22
-
23
- next(): IteratorResult<number> { // called every iteration, to get the next value
24
- if (this.current <= this.last) {
25
- return {done: false, value: this.current++};
26
- } else {
27
- return {done: true, value: undefined};
28
- }
29
- }
30
- };
31
- }
32
- };
33
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Type representing a debounced version of a function.
3
- * Preserves the original function's `this` context and parameters.
4
- * @typeParam T - The original function type
5
- */
6
- type DebouncedFunction<T extends (...args: any[]) => any> = (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
7
-
8
- /**
9
- * Creates a debounced version of a function that delays execution
10
- * until after the specified timeout has elapsed since the last call.
11
- * @typeParam T - The function type to debounce
12
- * @param func - The function to debounce
13
- * @param timeout - Delay in milliseconds before executing (default: 300)
14
- * @returns A debounced version of the function
15
- * @example
16
- * const debouncedSearch = debounce((query: string) => {
17
- * fetch(`/api/search?q=${query}`);
18
- * }, 500);
19
- */
20
- export default function debounce<T extends (...args: any[]) => any>(func: T, timeout = 300): DebouncedFunction<T> {
21
- let timer: ReturnType<typeof setTimeout>;
22
- return function(this: ThisParameterType<T>, ...args: Parameters<T>): void {
23
- clearTimeout(timer);
24
- timer = setTimeout(() => {
25
- func.apply(this, args);
26
- }, timeout);
27
- };
28
- }
@@ -1,3 +0,0 @@
1
- export default function timeout(ms: number): Promise<void> {
2
- return new Promise<void>(resolve => setTimeout(resolve, ms));
3
- }