@commversion/libs 0.18.2 → 0.18.3

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 (52) hide show
  1. package/.cspell.json +149 -0
  2. package/.editorconfig +10 -0
  3. package/.husky/pre-commit +27 -0
  4. package/.husky/prepare-commit-msg +13 -0
  5. package/.markdownlint.json +4 -0
  6. package/.oxfmtrc.json +6 -0
  7. package/.oxlintrc.json +34 -0
  8. package/.release-it.json +9 -3
  9. package/.vscode/extensions.json +18 -0
  10. package/.vscode/settings.json +12 -0
  11. package/README.md +20 -10
  12. package/dist/lc-attribution.js +1 -0
  13. package/dist/lc-channel-widgets.js +7 -7
  14. package/dist/lc-cookie-banner-update-position.js +3 -3
  15. package/dist/lc-device.js +1 -1
  16. package/dist/lc-exit-intent-debounced.js +1 -1
  17. package/dist/lc-exit-intent.js +1 -1
  18. package/dist/lc-experiment.js +1 -1
  19. package/dist/lc-form-abandonment.js +1 -1
  20. package/dist/lc-form-submission.js +1 -1
  21. package/dist/lc-ga-initialize-event.js +1 -1
  22. package/dist/lc-ga-tags.js +1 -1
  23. package/dist/lc-gclid.js +1 -1
  24. package/dist/lc-geoblocking.js +1 -1
  25. package/dist/lc-gtm.js +1 -1
  26. package/dist/lc-input-error.js +1 -1
  27. package/dist/lc-kill-chat-persist.js +1 -1
  28. package/dist/lc-kill-chat.js +1 -1
  29. package/dist/lc-open-on-button-click.js +1 -1
  30. package/dist/lc-pause-on-url.js +1 -1
  31. package/dist/lc-powered-by.js +1 -1
  32. package/dist/lc-show-by-selector.js +1 -1
  33. package/dist/lc-show-hide.js +1 -1
  34. package/dist/lc-utm-params.js +1 -1
  35. package/dist/lc-whatsapp-widget-combo.js +4 -4
  36. package/dist/lc-whatsapp-widget-only.js +8 -8
  37. package/dist/schedule-event.js +1 -1
  38. package/global.d.ts +320 -0
  39. package/package.json +112 -87
  40. package/pnpm-workspace.yaml +33 -0
  41. package/templates/scaffold.ts +86 -0
  42. package/templates/script/README.md +11 -0
  43. package/templates/script/package.json +4 -0
  44. package/templates/script/src/NAME.ts +6 -0
  45. package/templates/script/src/index.html +57 -0
  46. package/templates/script/src/main.ts +5 -0
  47. package/templates/script/tests/NAME.test.ts +9 -0
  48. package/templates/script/vite.config.ts +19 -0
  49. package/tsconfig.json +32 -0
  50. package/vitest.config.ts +18 -0
  51. package/.prettierignore +0 -4
  52. package/.prettierrc +0 -3
@@ -0,0 +1,11 @@
1
+ # NAME
2
+
3
+ ## Installation
4
+
5
+ Document how this script is supposed to be installed.
6
+ Make sure any configuration requirements are explained here.
7
+
8
+ ## Usage
9
+
10
+ Document how this script is supposed to be used.
11
+ Provide examples for different use cases.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "NAME",
3
+ "type": "module"
4
+ }
@@ -0,0 +1,6 @@
1
+ export const CAMEL_NAME =
2
+ (configuration: CommversionConfiguration) =>
3
+ ({ state, customerData }: LiveChat.ReadyData): void => {
4
+ const { LiveChatWidget } = window;
5
+ console.log({ configuration, state, customerData, LiveChatWidget });
6
+ };
@@ -0,0 +1,57 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>NAME</title>
5
+ </head>
6
+ <body>
7
+ <!-- Start of LiveChat (www.livechatinc.com) code -->
8
+ <script>
9
+ window.__lc = window.__lc || {};
10
+ window.__lc.license = 10793607;
11
+ (function (n, t, c) {
12
+ function i(n) {
13
+ return e._h ? e._h.apply(null, n) : e._q.push(n);
14
+ }
15
+ var e = {
16
+ _q: [],
17
+ _h: null,
18
+ _v: "2.0",
19
+ on: function () {
20
+ i(["on", c.call(arguments)]);
21
+ },
22
+ once: function () {
23
+ i(["once", c.call(arguments)]);
24
+ },
25
+ off: function () {
26
+ i(["off", c.call(arguments)]);
27
+ },
28
+ get: function () {
29
+ if (!e._h) throw new Error("[LiveChatWidget] You can't use getters before load.");
30
+ return i(["get", c.call(arguments)]);
31
+ },
32
+ call: function () {
33
+ i(["call", c.call(arguments)]);
34
+ },
35
+ init: function () {
36
+ var n = t.createElement("script");
37
+ ((n.async = !0),
38
+ (n.type = "text/javascript"),
39
+ (n.src = "https://cdn.livechatinc.com/tracking.js"),
40
+ t.head.appendChild(n));
41
+ },
42
+ };
43
+ (!n.__lc.asyncInit && e.init(), (n.LiveChatWidget = n.LiveChatWidget || e));
44
+ })(window, document, [].slice);
45
+ </script>
46
+ <!-- End of LiveChat code -->
47
+
48
+ <script async src="./main.ts" type="module"></script>
49
+ <script>
50
+ window.commversion = {
51
+ key: "value",
52
+ };
53
+ </script>
54
+
55
+ <h1>NAME</h1>
56
+ </body>
57
+ </html>
@@ -0,0 +1,5 @@
1
+ import { CAMEL_NAME } from "./NAME.js";
2
+
3
+ window.commversion = window.commversion || {};
4
+
5
+ window.LiveChatWidget.once("ready", CAMEL_NAME(window.commversion));
@@ -0,0 +1,9 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { CAMEL_NAME } from "../src/NAME.js";
4
+
5
+ describe("NAME", () => {
6
+ it("is defined as a function", () => {
7
+ expect(CAMEL_NAME).toBeTypeOf("function");
8
+ });
9
+ });
@@ -0,0 +1,19 @@
1
+ import path from "node:path";
2
+
3
+ import type { UserConfig } from "vite";
4
+
5
+ const config: UserConfig = {
6
+ build: {
7
+ outDir: path.resolve("dist"),
8
+ emptyOutDir: false,
9
+ target: "es2015",
10
+ lib: {
11
+ entry: path.resolve(__dirname, "src/main.ts"),
12
+ name: "CAMEL_NAME",
13
+ fileName: () => "NAME.js",
14
+ formats: ["iife"],
15
+ },
16
+ },
17
+ };
18
+
19
+ export default config;
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "include": ["scripts/**/*.ts", "templates/**/*.ts", "global.d.ts"],
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "lib": ["ESNext", "DOM"],
6
+ "types": ["node", "@vitest/browser-playwright"],
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "experimentalDecorators": true,
10
+ "isolatedDeclarations": true,
11
+ "verbatimModuleSyntax": true,
12
+ "resolveJsonModule": false, // ESM doesn't support JSON modules yet.
13
+ "esModuleInterop": true,
14
+ "isolatedModules": true,
15
+ "stripInternal": true,
16
+ "skipLibCheck": true,
17
+ "declaration": true,
18
+ "noEmit": true,
19
+ // Type Checking
20
+ "allowUnreachableCode": false,
21
+ "allowUnusedLabels": false,
22
+ "exactOptionalPropertyTypes": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noImplicitOverride": true,
25
+ "noImplicitReturns": true,
26
+ "noPropertyAccessFromIndexSignature": true,
27
+ "noUncheckedIndexedAccess": true,
28
+ "noUnusedLocals": true,
29
+ "noUnusedParameters": true,
30
+ "strict": true
31
+ }
32
+ }
@@ -0,0 +1,18 @@
1
+ import { playwright } from "@vitest/browser-playwright";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ include: ["scripts/*/tests/**/*.test.{js,ts}"],
7
+ isolate: true,
8
+ restoreMocks: true,
9
+ unstubGlobals: true,
10
+ unstubEnvs: true,
11
+ browser: {
12
+ enabled: true,
13
+ provider: playwright(),
14
+ headless: true,
15
+ instances: [{ browser: "chromium" }],
16
+ },
17
+ },
18
+ });
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- dist
2
- node_modules
3
- *.ejs.t
4
- _templates/generator/**/*.js
package/.prettierrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "semi": true
3
- }