@xyd-js/plugin-chatwoot 0.0.0-build

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @xyd-js/plugin-orama
2
+
3
+ ## 0.0.0-build+6952c2c-20250813013245
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
@@ -0,0 +1,3 @@
1
+ declare function ChatwootPlugin(pluginOptions?: any): any;
2
+
3
+ export { ChatwootPlugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ // src/script.ts
2
+ function initChatwoot(websiteToken, baseURL, chatwootSettings) {
3
+ window.chatwootSettings = chatwootSettings || {};
4
+ (function(d, t) {
5
+ var BASE_URL = baseURL;
6
+ var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
7
+ g.src = BASE_URL + "/packs/js/sdk.js";
8
+ g.async = true;
9
+ s.parentNode?.insertBefore(g, s);
10
+ g.onload = function() {
11
+ window.chatwootSDK.run({ websiteToken, baseUrl: BASE_URL });
12
+ };
13
+ })(document, "script");
14
+ }
15
+
16
+ // src/index.ts
17
+ function ChatwootPlugin(pluginOptions = {}) {
18
+ return function() {
19
+ const headScripts = [];
20
+ const {
21
+ websiteToken,
22
+ baseURL = "https://app.chatwoot.com",
23
+ chatwootSettings = {}
24
+ } = pluginOptions;
25
+ if (websiteToken) {
26
+ headScripts.push(
27
+ [
28
+ "script",
29
+ {},
30
+ `(${initChatwoot.toString()})('${websiteToken}', '${baseURL}', ${JSON.stringify(chatwootSettings)})`
31
+ ]
32
+ );
33
+ } else {
34
+ console.warn("Chatwoot website token is not set");
35
+ }
36
+ return {
37
+ name: "plugin-chatwoot",
38
+ vite: [],
39
+ head: headScripts
40
+ };
41
+ };
42
+ }
43
+ export {
44
+ ChatwootPlugin as default
45
+ };
46
+ //# 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 initChatwoot(\n websiteToken: string,\n baseURL: string,\n chatwootSettings: any\n) {\n window.chatwootSettings = chatwootSettings || {};\n\n (function (d, t) {\n var BASE_URL = baseURL;\n var g = d.createElement(t) as HTMLScriptElement, s = d.getElementsByTagName(t)[0];\n g.src = BASE_URL + \"/packs/js/sdk.js\";\n g.async = !0;\n s.parentNode?.insertBefore(g, s);\n g.onload = function () {\n window.chatwootSDK.run({ websiteToken: websiteToken, baseUrl: BASE_URL })\n }\n })(document, \"script\");\n}\n","import { initChatwoot } from './script'\n\nexport default function ChatwootPlugin(\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 websiteToken,\n baseURL = \"https://app.chatwoot.com\",\n chatwootSettings = {}\n } = pluginOptions;\n\n if (websiteToken) {\n headScripts.push(\n [\n \"script\",\n {},\n `(${initChatwoot.toString()})('${websiteToken}', '${baseURL}', ${JSON.stringify(chatwootSettings)})`\n ]\n )\n } else {\n console.warn(\"Chatwoot website token is not set\")\n }\n\n return {\n name: \"plugin-chatwoot\",\n vite: [],\n head: headScripts\n }\n }\n}\n\n"],"mappings":";AAEO,SAAS,aACZ,cACA,SACA,kBACF;AACE,SAAO,mBAAmB,oBAAoB,CAAC;AAE/C,GAAC,SAAU,GAAG,GAAG;AACb,QAAI,WAAW;AACf,QAAI,IAAI,EAAE,cAAc,CAAC,GAAwB,IAAI,EAAE,qBAAqB,CAAC,EAAE,CAAC;AAChF,MAAE,MAAM,WAAW;AACnB,MAAE,QAAQ;AACV,MAAE,YAAY,aAAa,GAAG,CAAC;AAC/B,MAAE,SAAS,WAAY;AACnB,aAAO,YAAY,IAAI,EAAE,cAA4B,SAAS,SAAS,CAAC;AAAA,IAC5E;AAAA,EACJ,GAAG,UAAU,QAAQ;AACzB;;;ACjBe,SAAR,eACH,gBAAqB,CAAC,GACnB;AACH,SAAO,WAAY;AACf,UAAM,cAAyF,CAAC;AAEhG,UAAM;AAAA,MACF;AAAA,MACA,UAAU;AAAA,MACV,mBAAmB,CAAC;AAAA,IACxB,IAAI;AAEJ,QAAI,cAAc;AACd,kBAAY;AAAA,QACR;AAAA,UACI;AAAA,UACA,CAAC;AAAA,UACD,IAAI,aAAa,SAAS,CAAC,MAAM,YAAY,OAAO,OAAO,MAAM,KAAK,UAAU,gBAAgB,CAAC;AAAA,QACrG;AAAA,MACJ;AAAA,IACJ,OAAO;AACH,cAAQ,KAAK,mCAAmC;AAAA,IACpD;AAEA,WAAO;AAAA,MACH,MAAM;AAAA,MACN,MAAM,CAAC;AAAA,MACP,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@xyd-js/plugin-chatwoot",
3
+ "version": "0.0.0-build+6952c2c-20250813013245",
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
+ "react": "^19.1.0",
18
+ "react-dom": "^19.1.0"
19
+ },
20
+ "devDependencies": {
21
+ "vite": "^7.0.0",
22
+ "@vitest/coverage-v8": "^1.6.1",
23
+ "rimraf": "^3.0.2",
24
+ "tsup": "^8.4.0",
25
+ "vitest": "^1.6.1"
26
+ },
27
+ "scripts": {
28
+ "clean": "rimraf build",
29
+ "prebuild": "pnpm clean",
30
+ "build": "tsup",
31
+ "test": "vitest",
32
+ "test:coverage": "vitest run --coverage"
33
+ }
34
+ }
@@ -0,0 +1,8 @@
1
+ declare global {]
2
+ interface Window {
3
+ chatwootSettings: any;
4
+ chatwootSDK: any;
5
+ }
6
+ }
7
+
8
+ export {}
package/src/index.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { initChatwoot } from './script'
2
+
3
+ export default function ChatwootPlugin(
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
+ websiteToken,
11
+ baseURL = "https://app.chatwoot.com",
12
+ chatwootSettings = {}
13
+ } = pluginOptions;
14
+
15
+ if (websiteToken) {
16
+ headScripts.push(
17
+ [
18
+ "script",
19
+ {},
20
+ `(${initChatwoot.toString()})('${websiteToken}', '${baseURL}', ${JSON.stringify(chatwootSettings)})`
21
+ ]
22
+ )
23
+ } else {
24
+ console.warn("Chatwoot website token is not set")
25
+ }
26
+
27
+ return {
28
+ name: "plugin-chatwoot",
29
+ vite: [],
30
+ head: headScripts
31
+ }
32
+ }
33
+ }
34
+
package/src/script.ts ADDED
@@ -0,0 +1,20 @@
1
+ // TODO: in the future better API + more typesafe
2
+
3
+ export function initChatwoot(
4
+ websiteToken: string,
5
+ baseURL: string,
6
+ chatwootSettings: any
7
+ ) {
8
+ window.chatwootSettings = chatwootSettings || {};
9
+
10
+ (function (d, t) {
11
+ var BASE_URL = baseURL;
12
+ var g = d.createElement(t) as HTMLScriptElement, s = d.getElementsByTagName(t)[0];
13
+ g.src = BASE_URL + "/packs/js/sdk.js";
14
+ g.async = !0;
15
+ s.parentNode?.insertBefore(g, s);
16
+ g.onload = function () {
17
+ window.chatwootSDK.run({ websiteToken: websiteToken, baseUrl: BASE_URL })
18
+ }
19
+ })(document, "script");
20
+ }
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);