@xyd-js/plugin-supademo 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 +7 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
- package/src/global.d.ts +5 -0
- package/src/index.ts +32 -0
- package/src/script.ts +103 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +21 -0
package/CHANGELOG.md
ADDED
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,104 @@
|
|
|
1
|
+
// src/script.ts
|
|
2
|
+
function initSupademo(supademoId) {
|
|
3
|
+
function trackAnalytics(event, properties) {
|
|
4
|
+
const analytics = window.analytics;
|
|
5
|
+
if (typeof window !== "undefined" && analytics?.track) {
|
|
6
|
+
analytics.track(event, properties);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function setupUrlChangeTracking() {
|
|
10
|
+
if (typeof window === "undefined") return;
|
|
11
|
+
window.addEventListener("xyd::pathnameChange", (event) => {
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
Supademo(supademoId, {
|
|
14
|
+
variables: {
|
|
15
|
+
email: "",
|
|
16
|
+
name: ""
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}, 300);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function patchSupademoClickElements() {
|
|
23
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
24
|
+
const supademoElements = document.querySelectorAll("[data-supademo-demo]");
|
|
25
|
+
supademoElements.forEach((element) => {
|
|
26
|
+
if (element instanceof HTMLElement) {
|
|
27
|
+
element.addEventListener = /* @__PURE__ */ ((original) => function(type, listener, options) {
|
|
28
|
+
if (type === "click") {
|
|
29
|
+
const wrappedListener = function(event) {
|
|
30
|
+
trackAnalytics("supademo.loadDemo");
|
|
31
|
+
if (typeof listener === "function") {
|
|
32
|
+
return listener.call(this, event);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return original.call(this, type, wrappedListener, options);
|
|
36
|
+
}
|
|
37
|
+
return original.call(this, type, listener, options);
|
|
38
|
+
})(element.addEventListener);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function patchSupademoForAnalytics() {
|
|
43
|
+
const originalSupademo = window.Supademo;
|
|
44
|
+
if (typeof window === "undefined" || typeof originalSupademo !== "function") return;
|
|
45
|
+
window.Supademo = function(...args) {
|
|
46
|
+
const supademoInstance = originalSupademo.apply(this, args);
|
|
47
|
+
if (supademoInstance && typeof supademoInstance.loadDemo === "function") {
|
|
48
|
+
const originalLoadDemo = supademoInstance.loadDemo;
|
|
49
|
+
supademoInstance.loadDemo = function(...loadDemoArgs) {
|
|
50
|
+
trackAnalytics("supademo.loadDemo");
|
|
51
|
+
return originalLoadDemo.apply(this, loadDemoArgs);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return supademoInstance;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function initializeSupademo() {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
patchSupademoForAnalytics();
|
|
60
|
+
patchSupademoClickElements();
|
|
61
|
+
setupUrlChangeTracking();
|
|
62
|
+
Supademo(supademoId, {
|
|
63
|
+
variables: {
|
|
64
|
+
email: "",
|
|
65
|
+
name: ""
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}, 300);
|
|
69
|
+
}
|
|
70
|
+
if (typeof Supademo === "function") {
|
|
71
|
+
initializeSupademo();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
window.addEventListener("load", initializeSupademo);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/index.ts
|
|
78
|
+
function SupademoPlugin(pluginOptions = {}) {
|
|
79
|
+
return function(settings) {
|
|
80
|
+
const headScripts = [];
|
|
81
|
+
if (pluginOptions.apiKey) {
|
|
82
|
+
const supademoId = pluginOptions.apiKey;
|
|
83
|
+
headScripts.push(
|
|
84
|
+
["script", { "src": "https://script.supademo.com/script.js", "defer": true }],
|
|
85
|
+
[
|
|
86
|
+
"script",
|
|
87
|
+
{},
|
|
88
|
+
`(${initSupademo.toString()})('${supademoId}')`
|
|
89
|
+
]
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
console.warn("Supademo API key is not set");
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
name: "plugin-supademo",
|
|
96
|
+
vite: [],
|
|
97
|
+
head: headScripts
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
SupademoPlugin as default
|
|
103
|
+
};
|
|
104
|
+
//# 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 initSupademo(supademoId: string) {\n // Track analytics events safely\n function trackAnalytics(event: string, properties?: Record<string, any>) {\n const analytics = (window as any).analytics;\n if (typeof window !== 'undefined' && analytics?.track) {\n analytics.track(event, properties);\n }\n }\n\n // Listen for URL changes via custom event from React\n function setupUrlChangeTracking() {\n if (typeof window === 'undefined') return;\n\n window.addEventListener('xyd::pathnameChange', (event: CustomEvent) => {\n setTimeout(() => {\n Supademo(supademoId, {\n variables: {\n email: '',\n name: ''\n }\n });\n }, 300); // wait for element to render - TODO: better solution\n });\n }\n\n // Patch addEventListener on elements with data-supademo-demo attribute\n function patchSupademoClickElements() {\n if (typeof window === 'undefined' || typeof document === 'undefined') return;\n\n const supademoElements = document.querySelectorAll('[data-supademo-demo]');\n \n supademoElements.forEach((element) => {\n if (element instanceof HTMLElement) {\n element.addEventListener = ((original) => function(type, listener, options) {\n if (type === 'click') {\n const wrappedListener = function(event: Event) {\n trackAnalytics('supademo.loadDemo');\n if (typeof listener === 'function') {\n return listener.call(this, event);\n }\n };\n return original.call(this, type, wrappedListener, options);\n }\n return original.call(this, type, listener, options);\n })(element.addEventListener);\n }\n });\n }\n\n // Patch the Supademo function to add analytics tracking to the returned instance\n function patchSupademoForAnalytics() {\n const originalSupademo = (window as any).Supademo;\n if (typeof window === 'undefined' || typeof originalSupademo !== 'function') return;\n\n (window as any).Supademo = function(...args: any[]) {\n // Call the original Supademo function\n const supademoInstance = originalSupademo.apply(this, args);\n \n // Patch the loadDemo method on the returned instance\n if (supademoInstance && typeof supademoInstance.loadDemo === 'function') {\n const originalLoadDemo = supademoInstance.loadDemo;\n supademoInstance.loadDemo = function(...loadDemoArgs: any[]) {\n trackAnalytics('supademo.loadDemo');\n return originalLoadDemo.apply(this, loadDemoArgs);\n };\n }\n \n return supademoInstance;\n };\n }\n\n // Initialize Supademo and set up analytics tracking\n function initializeSupademo() {\n // Delay is needed to wait for the Supademo script to load\n setTimeout(() => {\n // Patch Supademo before calling it\n patchSupademoForAnalytics();\n \n // Patch click elements\n patchSupademoClickElements();\n \n // Set up URL change tracking\n setupUrlChangeTracking();\n \n Supademo(supademoId, {\n variables: {\n email: '',\n name: ''\n }\n });\n }, 300);\n }\n\n // Start initialization either immediately or on window load\n if (typeof Supademo === 'function') {\n initializeSupademo();\n return\n }\n\n window.addEventListener('load', initializeSupademo);\n}\n","import { initSupademo } from './script'\n\nexport default function SupademoPlugin(\n pluginOptions: any = {} // TODO: fix any\n): any {\n return function (settings: any) {\n const headScripts: ([string, Record<string, any>] | [string, Record<string, any>, string])[] = []\n\n // Add Supademo script if pluginOptions.apiKey is provided\n if (pluginOptions.apiKey) {\n const supademoId = pluginOptions.apiKey\n\n headScripts.push(\n [\"script\", { \"src\": \"https://script.supademo.com/script.js\", \"defer\": true }],\n [\n \"script\",\n {},\n `(${initSupademo.toString()})('${supademoId}')`\n ]\n )\n } else {\n console.warn(\"Supademo API key is not set\")\n }\n\n return {\n name: \"plugin-supademo\",\n vite: [],\n head: headScripts\n }\n }\n}\n\n"],"mappings":";AAEO,SAAS,aAAa,YAAoB;AAE7C,WAAS,eAAe,OAAe,YAAkC;AACrE,UAAM,YAAa,OAAe;AAClC,QAAI,OAAO,WAAW,eAAe,WAAW,OAAO;AACnD,gBAAU,MAAM,OAAO,UAAU;AAAA,IACrC;AAAA,EACJ;AAGA,WAAS,yBAAyB;AAC9B,QAAI,OAAO,WAAW,YAAa;AAEnC,WAAO,iBAAiB,uBAAuB,CAAC,UAAuB;AACnE,iBAAW,MAAM;AACb,iBAAS,YAAY;AAAA,UACjB,WAAW;AAAA,YACP,OAAO;AAAA,YACP,MAAM;AAAA,UACV;AAAA,QACJ,CAAC;AAAA,MACL,GAAG,GAAG;AAAA,IACV,CAAC;AAAA,EACL;AAGA,WAAS,6BAA6B;AAClC,QAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa;AAEtE,UAAM,mBAAmB,SAAS,iBAAiB,sBAAsB;AAEzE,qBAAiB,QAAQ,CAAC,YAAY;AAClC,UAAI,mBAAmB,aAAa;AAChC,gBAAQ,mBAAoB,kBAAC,aAAa,SAAS,MAAM,UAAU,SAAS;AACxE,cAAI,SAAS,SAAS;AAClB,kBAAM,kBAAkB,SAAS,OAAc;AAC3C,6BAAe,mBAAmB;AAClC,kBAAI,OAAO,aAAa,YAAY;AAChC,uBAAO,SAAS,KAAK,MAAM,KAAK;AAAA,cACpC;AAAA,YACJ;AACA,mBAAO,SAAS,KAAK,MAAM,MAAM,iBAAiB,OAAO;AAAA,UAC7D;AACA,iBAAO,SAAS,KAAK,MAAM,MAAM,UAAU,OAAO;AAAA,QACtD,GAAG,QAAQ,gBAAgB;AAAA,MAC/B;AAAA,IACJ,CAAC;AAAA,EACL;AAGA,WAAS,4BAA4B;AACjC,UAAM,mBAAoB,OAAe;AACzC,QAAI,OAAO,WAAW,eAAe,OAAO,qBAAqB,WAAY;AAE7E,IAAC,OAAe,WAAW,YAAY,MAAa;AAEhD,YAAM,mBAAmB,iBAAiB,MAAM,MAAM,IAAI;AAG1D,UAAI,oBAAoB,OAAO,iBAAiB,aAAa,YAAY;AACrE,cAAM,mBAAmB,iBAAiB;AAC1C,yBAAiB,WAAW,YAAY,cAAqB;AACzD,yBAAe,mBAAmB;AAClC,iBAAO,iBAAiB,MAAM,MAAM,YAAY;AAAA,QACpD;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA,EACJ;AAGA,WAAS,qBAAqB;AAE1B,eAAW,MAAM;AAEb,gCAA0B;AAG1B,iCAA2B;AAG3B,6BAAuB;AAEvB,eAAS,YAAY;AAAA,QACjB,WAAW;AAAA,UACP,OAAO;AAAA,UACP,MAAM;AAAA,QACV;AAAA,MACJ,CAAC;AAAA,IACL,GAAG,GAAG;AAAA,EACV;AAGA,MAAI,OAAO,aAAa,YAAY;AAChC,uBAAmB;AACnB;AAAA,EACJ;AAEA,SAAO,iBAAiB,QAAQ,kBAAkB;AACtD;;;ACpGe,SAAR,eACH,gBAAqB,CAAC,GACnB;AACH,SAAO,SAAU,UAAe;AAC5B,UAAM,cAAyF,CAAC;AAGhG,QAAI,cAAc,QAAQ;AACtB,YAAM,aAAa,cAAc;AAEjC,kBAAY;AAAA,QACR,CAAC,UAAU,EAAE,OAAO,yCAAyC,SAAS,KAAK,CAAC;AAAA,QAC5E;AAAA,UACI;AAAA,UACA,CAAC;AAAA,UACD,IAAI,aAAa,SAAS,CAAC,MAAM,UAAU;AAAA,QAC/C;AAAA,MACJ;AAAA,IACJ,OAAO;AACH,cAAQ,KAAK,6BAA6B;AAAA,IAC9C;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,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyd-js/plugin-supademo",
|
|
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
|
+
"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 { initSupademo } from './script'
|
|
2
|
+
|
|
3
|
+
export default function SupademoPlugin(
|
|
4
|
+
pluginOptions: any = {} // TODO: fix any
|
|
5
|
+
): any {
|
|
6
|
+
return function (settings: any) {
|
|
7
|
+
const headScripts: ([string, Record<string, any>] | [string, Record<string, any>, string])[] = []
|
|
8
|
+
|
|
9
|
+
// Add Supademo script if pluginOptions.apiKey is provided
|
|
10
|
+
if (pluginOptions.apiKey) {
|
|
11
|
+
const supademoId = pluginOptions.apiKey
|
|
12
|
+
|
|
13
|
+
headScripts.push(
|
|
14
|
+
["script", { "src": "https://script.supademo.com/script.js", "defer": true }],
|
|
15
|
+
[
|
|
16
|
+
"script",
|
|
17
|
+
{},
|
|
18
|
+
`(${initSupademo.toString()})('${supademoId}')`
|
|
19
|
+
]
|
|
20
|
+
)
|
|
21
|
+
} else {
|
|
22
|
+
console.warn("Supademo API key is not set")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
name: "plugin-supademo",
|
|
27
|
+
vite: [],
|
|
28
|
+
head: headScripts
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
package/src/script.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// TODO: in the future better API + more typesafe
|
|
2
|
+
|
|
3
|
+
export function initSupademo(supademoId: string) {
|
|
4
|
+
// Track analytics events safely
|
|
5
|
+
function trackAnalytics(event: string, properties?: Record<string, any>) {
|
|
6
|
+
const analytics = (window as any).analytics;
|
|
7
|
+
if (typeof window !== 'undefined' && analytics?.track) {
|
|
8
|
+
analytics.track(event, properties);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Listen for URL changes via custom event from React
|
|
13
|
+
function setupUrlChangeTracking() {
|
|
14
|
+
if (typeof window === 'undefined') return;
|
|
15
|
+
|
|
16
|
+
window.addEventListener('xyd::pathnameChange', (event: CustomEvent) => {
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
Supademo(supademoId, {
|
|
19
|
+
variables: {
|
|
20
|
+
email: '',
|
|
21
|
+
name: ''
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}, 300); // wait for element to render - TODO: better solution
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Patch addEventListener on elements with data-supademo-demo attribute
|
|
29
|
+
function patchSupademoClickElements() {
|
|
30
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return;
|
|
31
|
+
|
|
32
|
+
const supademoElements = document.querySelectorAll('[data-supademo-demo]');
|
|
33
|
+
|
|
34
|
+
supademoElements.forEach((element) => {
|
|
35
|
+
if (element instanceof HTMLElement) {
|
|
36
|
+
element.addEventListener = ((original) => function(type, listener, options) {
|
|
37
|
+
if (type === 'click') {
|
|
38
|
+
const wrappedListener = function(event: Event) {
|
|
39
|
+
trackAnalytics('supademo.loadDemo');
|
|
40
|
+
if (typeof listener === 'function') {
|
|
41
|
+
return listener.call(this, event);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return original.call(this, type, wrappedListener, options);
|
|
45
|
+
}
|
|
46
|
+
return original.call(this, type, listener, options);
|
|
47
|
+
})(element.addEventListener);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Patch the Supademo function to add analytics tracking to the returned instance
|
|
53
|
+
function patchSupademoForAnalytics() {
|
|
54
|
+
const originalSupademo = (window as any).Supademo;
|
|
55
|
+
if (typeof window === 'undefined' || typeof originalSupademo !== 'function') return;
|
|
56
|
+
|
|
57
|
+
(window as any).Supademo = function(...args: any[]) {
|
|
58
|
+
// Call the original Supademo function
|
|
59
|
+
const supademoInstance = originalSupademo.apply(this, args);
|
|
60
|
+
|
|
61
|
+
// Patch the loadDemo method on the returned instance
|
|
62
|
+
if (supademoInstance && typeof supademoInstance.loadDemo === 'function') {
|
|
63
|
+
const originalLoadDemo = supademoInstance.loadDemo;
|
|
64
|
+
supademoInstance.loadDemo = function(...loadDemoArgs: any[]) {
|
|
65
|
+
trackAnalytics('supademo.loadDemo');
|
|
66
|
+
return originalLoadDemo.apply(this, loadDemoArgs);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return supademoInstance;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Initialize Supademo and set up analytics tracking
|
|
75
|
+
function initializeSupademo() {
|
|
76
|
+
// Delay is needed to wait for the Supademo script to load
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
// Patch Supademo before calling it
|
|
79
|
+
patchSupademoForAnalytics();
|
|
80
|
+
|
|
81
|
+
// Patch click elements
|
|
82
|
+
patchSupademoClickElements();
|
|
83
|
+
|
|
84
|
+
// Set up URL change tracking
|
|
85
|
+
setupUrlChangeTracking();
|
|
86
|
+
|
|
87
|
+
Supademo(supademoId, {
|
|
88
|
+
variables: {
|
|
89
|
+
email: '',
|
|
90
|
+
name: ''
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}, 300);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Start initialization either immediately or on window load
|
|
97
|
+
if (typeof Supademo === 'function') {
|
|
98
|
+
initializeSupademo();
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
window.addEventListener('load', initializeSupademo);
|
|
103
|
+
}
|
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);
|