update type imports in @formbricks/js`

This commit is contained in:
Matthias Nannt
2023-05-09 13:36:01 +02:00
parent bc4e2379cf
commit 520f282384
25 changed files with 89 additions and 58 deletions

View File

@@ -7,16 +7,15 @@
<script type="text/javascript">
!(function () {
var t = document.createElement("script");
(t.type = "text/javascript"),
(t.async = !0),
(t.src = "https://unpkg.com/@formbricks/js@0.1.2/dist/index.umd.js");
(t.type = "text/javascript"), (t.async = !0), (t.src = "/dist/index.umd.js");
var e = document.getElementsByTagName("script")[0];
e.parentNode.insertBefore(t, e),
setTimeout(function () {
window.formbricks = window.js;
window.formbricks.init({
environmentId: "clfv982hs003dyzhphibui8as",
environmentId: "clham12520003yz4zeng786vq",
apiHost: "http://localhost:3000",
logLevel: "debug",
});
}, 500);
})();

View File

@@ -1,6 +1,6 @@
{
"name": "@formbricks/js",
"version": "0.1.14",
"version": "0.1.15",
"description": "Formbricks-js allows you to connect your app to Formbricks, display surveys and trigger events.",
"keywords": [
"Formbricks",
@@ -11,11 +11,14 @@
"main": "./dist/index.js",
"module": "./dist/index.module.js",
"unpkg": "./dist/index.umd.js",
"types": "dist/index.d.ts",
"types": "./dist/js/src/index.d.ts",
"exports": {
"types": "./dist/src/index.d.ts",
"require": "./dist/index.js",
"default": "./dist/index.modern.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.module.js"
},
"./package.json": "./package.json",
"./": "./"
},
"scripts": {
"clean": "rimraf .turbo node_modules dist",
@@ -57,7 +60,7 @@
"eslint-config-preact": "^1.3.0",
"jest": "^29.5.0",
"jest-preset-preact": "^4.0.5",
"microbundle": "^0.14.1",
"microbundle": "^0.15.1",
"postcss": "^8.4.23",
"preact": "10.13.2",
"preact-cli": "^3.4.5",

View File

@@ -1,4 +1,4 @@
import type { JsConfig, Survey } from "@formbricks/types/js";
import type { JsConfig, Survey } from "../../types/js";
import { VNode, h } from "preact";
import { useState } from "preact/hooks";
import Modal from "./components/Modal";

View File

@@ -1,7 +1,6 @@
import type { CTAQuestion } from "../../../types/questions";
import { h } from "preact";
import type { CTAQuestion } from "@formbricks/types/questions";
import Headline from "./Headline";
import Subheader from "./Subheader";
import HtmlBody from "./HtmlBody";
interface CTAQuestionProps {

View File

@@ -1,7 +1,7 @@
import type { MultipleChoiceMultiQuestion } from "../../../types/questions";
import { h } from "preact";
import { useEffect, useState } from "preact/hooks";
import { useState } from "preact/hooks";
import { cn } from "../lib/utils";
import type { MultipleChoiceMultiQuestion } from "@formbricks/types/questions";
import Headline from "./Headline";
import Subheader from "./Subheader";

View File

@@ -1,7 +1,7 @@
import { h } from "preact";
import { useState } from "preact/hooks";
import { cn } from "../lib/utils";
import type { MultipleChoiceSingleQuestion } from "@formbricks/types/questions";
import type { MultipleChoiceSingleQuestion } from "../../../types/questions";
import Headline from "./Headline";
import Subheader from "./Subheader";

View File

@@ -1,7 +1,7 @@
import { h } from "preact";
import { useState } from "preact/hooks";
import { cn } from "../lib/utils";
import type { NPSQuestion } from "@formbricks/types/questions";
import type { NPSQuestion } from "../../../types/questions";
import Headline from "./Headline";
import Subheader from "./Subheader";

View File

@@ -1,4 +1,4 @@
import type { OpenTextQuestion } from "@formbricks/types/questions";
import type { OpenTextQuestion } from "../../../types/questions";
import { h } from "preact";
import Headline from "./Headline";
import Subheader from "./Subheader";

View File

@@ -1,5 +1,5 @@
import { h } from "preact";
import type { Question } from "@formbricks/types/questions";
import type { Question } from "../../../types/questions";
import OpenTextQuestion from "./OpenTextQuestion";
import MultipleChoiceSingleQuestion from "./MultipleChoiceSingleQuestion";
import MultipleChoiceMultiQuestion from "./MultipleChoiceMultiQuestion";

View File

@@ -1,7 +1,7 @@
import { h } from "preact";
import { useState } from "preact/hooks";
import { cn } from "../lib/utils";
import type { RatingQuestion } from "@formbricks/types/questions";
import type { RatingQuestion } from "../../../types/questions";
import Headline from "./Headline";
import Subheader from "./Subheader";

View File

@@ -1,4 +1,4 @@
import { JsConfig, Survey } from "@formbricks/types/js";
import type { JsConfig, Survey } from "../../../types/js";
import { h } from "preact";
import { useEffect, useState } from "preact/hooks";
import { createDisplay, markDisplayResponded } from "../lib/display";

View File

@@ -1,4 +1,4 @@
import { InitConfig } from "@formbricks/types/js";
import type { InitConfig } from "../../types/js";
import { CommandQueue } from "./lib/commandQueue";
import { ErrorHandler } from "./lib/errors";
import { trackEvent } from "./lib/event";

View File

@@ -1,4 +1,4 @@
import { JsConfig } from "@formbricks/types/js";
import type { JsConfig } from "../../../types/js";
import { Result, wrapThrows } from "./errors";
export class Config {

View File

@@ -1,4 +1,4 @@
import { DisplayCreateRequest, JsConfig, Response } from "@formbricks/types/js";
import type { DisplayCreateRequest, JsConfig, Response } from "../../../types/js";
import { NetworkError, Result, err, ok, okVoid } from "./errors";
export const createDisplay = async (

View File

@@ -1,6 +1,6 @@
import { Logger } from "./logger";
export { ErrorHandler as IErrorHandler } from "@formbricks/types/js";
export type { ErrorHandler as IErrorHandler } from "../../../types/js";
export type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };

View File

@@ -1,4 +1,4 @@
import { InitConfig } from "@formbricks/types/js";
import type { InitConfig } from "../../../types/js";
import { Config } from "./config";
import {
ErrorHandler,
@@ -12,7 +12,7 @@ import {
} from "./errors";
import { trackEvent } from "./event";
import { Logger } from "./logger";
import { addClickEventListener, addPageUrlEventListeners } from "./noCodeEvents";
import { addClickEventListener, addPageUrlEventListeners, checkPageUrl } from "./noCodeEvents";
import { createPerson } from "./person";
import { createSession, extendOrCreateSession, extendSession, isExpired } from "./session";
import { addStylesToDom } from "./styles";
@@ -123,6 +123,9 @@ export const initialize = async (
logger.debug("Initialized");
// check page url if initialized after page load
checkPageUrl();
return okVoid();
};

View File

@@ -1,5 +1,5 @@
import type { Event } from "@formbricks/types/events";
import type { MatchType } from "@formbricks/types/js";
import type { Event } from "../../../types/events";
import type { MatchType } from "../../../types/js";
import { Config } from "./config";
import { ErrorHandler, InvalidMatchTypeError, NetworkError, Result, err, match, ok, okVoid } from "./errors";
import { trackEvent } from "./event";

View File

@@ -1,5 +1,5 @@
import type { Person } from "@formbricks/types/js";
import { Session, Settings } from "@formbricks/types/js";
import type { Person } from "../../../types/js";
import type { Session, Settings } from "../../../types/js";
import { Config } from "./config";
import {
AttributeAlreadyExistsError,

View File

@@ -1,4 +1,4 @@
import { JsConfig, Response, ResponseCreateRequest, ResponseUpdateRequest } from "@formbricks/types/js";
import type { JsConfig, Response, ResponseCreateRequest, ResponseUpdateRequest } from "../../../types/js";
import { NetworkError, Result, err, ok } from "./errors";
export const createResponse = async (

View File

@@ -1,4 +1,4 @@
import type { Session, Settings } from "@formbricks/types/js";
import type { Session, Settings } from "../../../types/js";
import { Config } from "./config";
import { MissingPersonError, NetworkError, Result, err, ok, okVoid } from "./errors";
import { trackEvent } from "./event";

View File

@@ -1,4 +1,4 @@
import type { Settings } from "@formbricks/types/js";
import type { Settings } from "../../../types/js";
import { Config } from "./config";
import { NetworkError, Result, err, ok, okVoid } from "./errors";
import { Logger } from "./logger";

View File

@@ -1,4 +1,4 @@
import { Survey } from "@formbricks/types/js";
import type { Survey } from "../../../types/js";
import { h, render } from "preact";
import App from "../App";
import { Config } from "./config";

View File

@@ -51,7 +51,12 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true
"esModuleInterop": true,
"declaration": true,
"declarationDir": "dist"
},
"include": ["src"]
"references": [
{ "path": "../../../types/tsconfig.json" } // Add this line, adjust the path to the actual location
],
"include": ["src", "../types"]
}

View File

@@ -1,5 +1,11 @@
{
"extends": "@formbricks/tsconfig/base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "dist",
"composite": true // Add this line
// ...other options
},
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

58
pnpm-lock.yaml generated
View File

@@ -488,8 +488,8 @@ importers:
specifier: ^4.0.5
version: 4.0.5(jest@29.5.0)(preact-render-to-string@6.0.3)(preact@10.13.2)
microbundle:
specifier: ^0.14.1
version: 0.14.1
specifier: ^0.15.1
version: 0.15.1
postcss:
specifier: ^8.4.23
version: 8.4.23
@@ -4222,6 +4222,14 @@ packages:
rollup: 2.79.1
dev: true
/@rollup/pluginutils@4.2.1:
resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==}
engines: {node: '>= 8.0.0'}
dependencies:
estree-walker: 2.0.2
picomatch: 2.3.1
dev: true
/@rushstack/eslint-patch@1.2.0:
resolution: {integrity: sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==}
dev: false
@@ -12475,8 +12483,8 @@ packages:
engines: {node: '>= 0.6'}
dev: true
/microbundle@0.14.1:
resolution: {integrity: sha512-/JAAPKWRyvBV0QjmmhgPU9NGuX3Tk1u8EXuMJ+6npFmnm+EtuL8IpJihxmljpUwaoHLyDy+b2ntfWoN6BkDQzA==}
/microbundle@0.15.1:
resolution: {integrity: sha512-aAF+nwFbkSIJGfrJk+HyzmJOq3KFaimH6OIFBU6J2DPjQeg1jXIYlIyEv81Gyisb9moUkudn+wj7zLNYMOv75Q==}
hasBin: true
dependencies:
'@babel/core': 7.20.12
@@ -12514,7 +12522,8 @@ packages:
rollup-plugin-bundle-size: 1.0.3
rollup-plugin-postcss: 4.0.2(postcss@8.4.23)
rollup-plugin-terser: 7.0.2(rollup@2.79.1)
rollup-plugin-typescript2: 0.29.0(rollup@2.79.1)(typescript@4.9.5)
rollup-plugin-typescript2: 0.32.1(rollup@2.79.1)(typescript@4.9.5)
rollup-plugin-visualizer: 5.9.0(rollup@2.79.1)
sade: 1.8.1
terser: 5.16.0
tiny-glob: 0.2.9
@@ -16083,12 +16092,6 @@ packages:
engines: {node: '>=10'}
dev: true
/resolve@1.17.0:
resolution: {integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==}
dependencies:
path-parse: 1.0.7
dev: true
/resolve@1.22.1:
resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
hasBin: true
@@ -16218,21 +16221,38 @@ packages:
terser: 5.16.0
dev: true
/rollup-plugin-typescript2@0.29.0(rollup@2.79.1)(typescript@4.9.5):
resolution: {integrity: sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw==}
/rollup-plugin-typescript2@0.32.1(rollup@2.79.1)(typescript@4.9.5):
resolution: {integrity: sha512-RanO8bp1WbeMv0bVlgcbsFNCn+Y3rX7wF97SQLDxf0fMLsg0B/QFF005t4AsGUcDgF3aKJHoqt4JF2xVaABeKw==}
peerDependencies:
rollup: '>=1.26.3'
typescript: '>=2.4.0'
dependencies:
'@rollup/pluginutils': 3.1.0(rollup@2.79.1)
'@rollup/pluginutils': 4.2.1
find-cache-dir: 3.3.2
fs-extra: 8.1.0
resolve: 1.17.0
fs-extra: 10.1.0
resolve: 1.22.2
rollup: 2.79.1
tslib: 2.0.1
tslib: 2.4.1
typescript: 4.9.5
dev: true
/rollup-plugin-visualizer@5.9.0(rollup@2.79.1):
resolution: {integrity: sha512-bbDOv47+Bw4C/cgs0czZqfm8L82xOZssk4ayZjG40y9zbXclNk7YikrZTDao6p7+HDiGxrN0b65SgZiVm9k1Cg==}
engines: {node: '>=14'}
hasBin: true
peerDependencies:
rollup: 2.x || 3.x
peerDependenciesMeta:
rollup:
optional: true
dependencies:
open: 8.4.0
picomatch: 2.3.1
rollup: 2.79.1
source-map: 0.7.4
yargs: 17.7.1
dev: true
/rollup-pluginutils@2.8.2:
resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==}
dependencies:
@@ -17841,10 +17861,6 @@ packages:
/tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
/tslib@2.0.1:
resolution: {integrity: sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==}
dev: true
/tslib@2.4.1:
resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==}