@xyd-js/plugin-livechat 0.1.0-build.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
- package/src/global.d.ts +8 -0
- package/src/index.ts +32 -0
- package/src/script.ts +46 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +21 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @xyd-js/plugin-livechat
|
|
2
|
+
|
|
3
|
+
## 0.1.0-build.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- update all packages
|
|
8
|
+
|
|
9
|
+
## 0.1.0-build.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- update all packages
|
|
14
|
+
|
|
15
|
+
## 0.1.0-build.15
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- update all packages
|
|
20
|
+
|
|
21
|
+
## 0.1.0-build.14
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- update all packages
|
|
26
|
+
|
|
27
|
+
## 0.1.0-build.13
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- update all packages
|
|
32
|
+
|
|
33
|
+
## 0.1.0-build.12
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- update all packages
|
|
38
|
+
|
|
39
|
+
## 0.1.0-build.11
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- update all packages
|
|
44
|
+
|
|
45
|
+
## 0.1.0-build.10
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- update all packages
|
|
50
|
+
|
|
51
|
+
## 0.1.0-build.9
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- update all packages
|
|
56
|
+
|
|
57
|
+
## 0.1.0-build.8
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- update all packages
|
|
62
|
+
|
|
63
|
+
## 0.1.0-build.7
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- update all packages
|
|
68
|
+
|
|
69
|
+
## 0.1.0-build.6
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- update all packages
|
|
74
|
+
|
|
75
|
+
## 0.1.0-build.5
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- update all packages
|
|
80
|
+
|
|
81
|
+
## 0.1.0-build.4
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- update all packages
|
|
86
|
+
|
|
87
|
+
## 0.1.0-build.3
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- update all packages
|
|
92
|
+
|
|
93
|
+
## 0.1.0-build.2
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 98583f0: update all packages
|
|
98
|
+
- 98583f0: update all packages
|
|
99
|
+
- update all packages
|
|
100
|
+
|
|
101
|
+
## 0.1.0-build.1
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- update all packages
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 xyd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/script.ts
|
|
2
|
+
function initLivechat(licenseId) {
|
|
3
|
+
window.__lc = window.__lc || {};
|
|
4
|
+
window.__lc.license = licenseId;
|
|
5
|
+
window.__lc.integration_name = "manual_channels";
|
|
6
|
+
window.__lc.product_name = "livechat";
|
|
7
|
+
(function(n, t, c) {
|
|
8
|
+
function i(n2) {
|
|
9
|
+
return e._h ? e._h.apply(null, n2) : e._q.push(n2);
|
|
10
|
+
}
|
|
11
|
+
var e = {
|
|
12
|
+
_q: [],
|
|
13
|
+
_h: null,
|
|
14
|
+
_v: "2.0",
|
|
15
|
+
on: function() {
|
|
16
|
+
i(["on", c.call(arguments)]);
|
|
17
|
+
},
|
|
18
|
+
once: function() {
|
|
19
|
+
i(["once", c.call(arguments)]);
|
|
20
|
+
},
|
|
21
|
+
off: function() {
|
|
22
|
+
i(["off", c.call(arguments)]);
|
|
23
|
+
},
|
|
24
|
+
get: function() {
|
|
25
|
+
if (!e._h)
|
|
26
|
+
throw new Error("[LiveChatWidget] You can't use getters before load.");
|
|
27
|
+
return i(["get", c.call(arguments)]);
|
|
28
|
+
},
|
|
29
|
+
call: function() {
|
|
30
|
+
i(["call", c.call(arguments)]);
|
|
31
|
+
},
|
|
32
|
+
init: function() {
|
|
33
|
+
var n2 = t.createElement("script");
|
|
34
|
+
n2.async = true, n2.type = "text/javascript", n2.src = "https://cdn.livechatinc.com/tracking.js", t.head.appendChild(n2);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
!n.__lc.asyncInit && e.init(), n.LiveChatWidget = n.LiveChatWidget || e;
|
|
38
|
+
})(window, document, [].slice);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
function LivechatPlugin(pluginOptions = {}) {
|
|
43
|
+
return function() {
|
|
44
|
+
const headScripts = [];
|
|
45
|
+
const {
|
|
46
|
+
licenseId
|
|
47
|
+
} = pluginOptions;
|
|
48
|
+
if (licenseId) {
|
|
49
|
+
headScripts.push(
|
|
50
|
+
[
|
|
51
|
+
"script",
|
|
52
|
+
{},
|
|
53
|
+
`(${initLivechat.toString()})('${licenseId}')`
|
|
54
|
+
]
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
console.warn("Livechat licenseId is not set");
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
name: "plugin-livechat",
|
|
61
|
+
vite: [],
|
|
62
|
+
head: headScripts
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
LivechatPlugin as default
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/script.ts","../src/index.ts"],"sourcesContent":["// TODO: in the future better API + more typesafe\n\nexport function initLivechat(\n licenseId: string,\n) {\n window.__lc = window.__lc || {};\n window.__lc.license = licenseId;\n window.__lc.integration_name = \"manual_channels\";\n window.__lc.product_name = \"livechat\";\n\n (function (n, t, c) {\n function i(n) {\n return e._h ? e._h.apply(null, n) : e._q.push(n);\n }\n var e = {\n _q: [],\n _h: null,\n _v: \"2.0\",\n on: function () {\n i([\"on\", c.call(arguments)]);\n },\n once: function () {\n i([\"once\", c.call(arguments)]);\n },\n off: function () {\n i([\"off\", c.call(arguments)]);\n },\n get: function () {\n if (!e._h)\n throw new Error(\"[LiveChatWidget] You can't use getters before load.\");\n return i([\"get\", c.call(arguments)]);\n },\n call: function () {\n i([\"call\", c.call(arguments)]);\n },\n init: function () {\n var n = t.createElement(\"script\");\n ((n.async = !0),\n (n.type = \"text/javascript\"),\n (n.src = \"https://cdn.livechatinc.com/tracking.js\"),\n t.head.appendChild(n));\n },\n };\n (!n.__lc.asyncInit && e.init(), (n.LiveChatWidget = n.LiveChatWidget || e));\n })(window, document, [].slice);\n}\n","import { initLivechat } from './script'\n\nexport default function LivechatPlugin(\n pluginOptions: any = {} // TODO: fix any\n): any {\n return function () {\n const headScripts: ([string, Record<string, any>] | [string, Record<string, any>, string])[] = []\n\n const {\n licenseId,\n } = pluginOptions;\n\n if (licenseId) {\n headScripts.push(\n [\n \"script\",\n {},\n `(${initLivechat.toString()})('${licenseId}')`\n ]\n )\n } else {\n console.warn(\"Livechat licenseId is not set\")\n }\n\n return {\n name: \"plugin-livechat\",\n vite: [],\n head: headScripts\n }\n }\n}\n\n"],"mappings":";AAEO,SAAS,aACZ,WACF;AACE,SAAO,OAAO,OAAO,QAAQ,CAAC;AAC9B,SAAO,KAAK,UAAU;AACtB,SAAO,KAAK,mBAAmB;AAC/B,SAAO,KAAK,eAAe;AAE3B,GAAC,SAAU,GAAG,GAAG,GAAG;AAChB,aAAS,EAAEA,IAAG;AACV,aAAO,EAAE,KAAK,EAAE,GAAG,MAAM,MAAMA,EAAC,IAAI,EAAE,GAAG,KAAKA,EAA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A,IAChD;AAEA,WAAO;AAAA,MACH,MAAM;AAAA,MACN,MAAM,CAAC;AAAA,MACP,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;","names":["n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyd-js/plugin-livechat",
|
|
3
|
+
"version": "0.1.0-build.17",
|
|
4
|
+
"author": "",
|
|
5
|
+
"description": "",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {},
|
|
16
|
+
"peerDependencies": {},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"vite": "^7.0.0",
|
|
19
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
20
|
+
"rimraf": "^3.0.2",
|
|
21
|
+
"tsup": "^8.4.0",
|
|
22
|
+
"vitest": "^1.6.1"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rimraf build",
|
|
26
|
+
"prebuild": "pnpm clean",
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/global.d.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { initLivechat } from './script'
|
|
2
|
+
|
|
3
|
+
export default function LivechatPlugin(
|
|
4
|
+
pluginOptions: any = {} // TODO: fix any
|
|
5
|
+
): any {
|
|
6
|
+
return function () {
|
|
7
|
+
const headScripts: ([string, Record<string, any>] | [string, Record<string, any>, string])[] = []
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
licenseId,
|
|
11
|
+
} = pluginOptions;
|
|
12
|
+
|
|
13
|
+
if (licenseId) {
|
|
14
|
+
headScripts.push(
|
|
15
|
+
[
|
|
16
|
+
"script",
|
|
17
|
+
{},
|
|
18
|
+
`(${initLivechat.toString()})('${licenseId}')`
|
|
19
|
+
]
|
|
20
|
+
)
|
|
21
|
+
} else {
|
|
22
|
+
console.warn("Livechat licenseId is not set")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
name: "plugin-livechat",
|
|
27
|
+
vite: [],
|
|
28
|
+
head: headScripts
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
package/src/script.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// TODO: in the future better API + more typesafe
|
|
2
|
+
|
|
3
|
+
export function initLivechat(
|
|
4
|
+
licenseId: string,
|
|
5
|
+
) {
|
|
6
|
+
window.__lc = window.__lc || {};
|
|
7
|
+
window.__lc.license = licenseId;
|
|
8
|
+
window.__lc.integration_name = "manual_channels";
|
|
9
|
+
window.__lc.product_name = "livechat";
|
|
10
|
+
|
|
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)
|
|
30
|
+
throw new Error("[LiveChatWidget] You can't use getters before load.");
|
|
31
|
+
return i(["get", c.call(arguments)]);
|
|
32
|
+
},
|
|
33
|
+
call: function () {
|
|
34
|
+
i(["call", c.call(arguments)]);
|
|
35
|
+
},
|
|
36
|
+
init: function () {
|
|
37
|
+
var n = t.createElement("script");
|
|
38
|
+
((n.async = !0),
|
|
39
|
+
(n.type = "text/javascript"),
|
|
40
|
+
(n.src = "https://cdn.livechatinc.com/tracking.js"),
|
|
41
|
+
t.head.appendChild(n));
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
(!n.__lc.asyncInit && e.init(), (n.LiveChatWidget = n.LiveChatWidget || e));
|
|
45
|
+
})(window, document, [].slice);
|
|
46
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"target": "esnext",
|
|
7
|
+
"baseUrl": ".",
|
|
8
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": false,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"incremental": false,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"jsx": "preserve",
|
|
17
|
+
"plugins": [],
|
|
18
|
+
"strictNullChecks": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
21
|
+
"exclude": ["node_modules"]
|
|
22
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {defineConfig, Options} from 'tsup';
|
|
2
|
+
|
|
3
|
+
const config: Options = {
|
|
4
|
+
entry: {
|
|
5
|
+
index: 'src/index.ts'
|
|
6
|
+
},
|
|
7
|
+
dts: {
|
|
8
|
+
entry: {
|
|
9
|
+
index: 'src/index.ts'
|
|
10
|
+
},
|
|
11
|
+
resolve: true, // Resolve external types
|
|
12
|
+
},
|
|
13
|
+
format: ['esm'],
|
|
14
|
+
platform: 'node',
|
|
15
|
+
shims: false,
|
|
16
|
+
splitting: false,
|
|
17
|
+
sourcemap: true,
|
|
18
|
+
clean: true,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default defineConfig(config);
|