tsconfig, core

This commit is contained in:
Max Peintner
2023-04-03 15:38:50 +02:00
parent f9299ad990
commit 987784c1a0
32 changed files with 290 additions and 747 deletions

View File

@@ -10,8 +10,8 @@
"dist/**"
],
"scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
"build": "tsup src/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
@@ -19,9 +19,6 @@
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"react": "^17.0.2",
"tsup": "^5.10.1",
"typescript": "^4.5.3"
},

View File

@@ -1,11 +0,0 @@
import * as React from "react";
export interface ButtonProps {
children: React.ReactNode;
}
export function Button(props: ButtonProps) {
return <button>{props.children}</button>;
}
Button.displayName = "Button";

View File

@@ -0,0 +1,19 @@
/**
* Return a slugified copy of a string.
*
* @param {CoreProps} str The ZITADEL client configuration
* @return {Core} The client implementation.
*/
export interface ZitadelCoreProps {
clientId: string;
}
export interface ZitadelApp {
config: ZitadelCoreProps;
}
export function initializeApp(config: ZitadelCoreProps): ZitadelApp {
const app = { config };
return app;
}

View File

@@ -0,0 +1 @@
export { initializeApp } from "./core";

View File

@@ -0,0 +1,31 @@
{
"name": "@zitadel/next",
"version": "0.0.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"license": "MIT",
"files": [
"dist/**"
],
"scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"tsup": "^5.10.1",
"typescript": "^4.5.3"
},
"peerDependencies": {
"next": "^13"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1 @@
export { toSlug } from "./toSlug";

View File

@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["zitadel"],
};

View File

@@ -1,5 +1,5 @@
{
"name": "@zitadel/utils",
"name": "@zitadel/react",
"version": "0.0.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -17,10 +17,10 @@
},
"devDependencies": {
"@zitadel/tsconfig": "workspace:*",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"react": "^17.0.2",
"tsup": "^5.10.1",
"typescript": "^4.5.3"

View File

@@ -1,5 +1,4 @@
import * as React from "react";
export { Button, type ButtonProps } from "./Button";
export {
SignInWithGoogle,
type SignInWithGoogleProps,

View File

@@ -0,0 +1,5 @@
{
"extends": "@zitadel/tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -3,17 +3,26 @@
"display": "Next.js",
"extends": "./base.json",
"compilerOptions": {
"allowJs": true,
"declaration": false,
"declarationMap": false,
"incremental": true,
"jsx": "preserve",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"rootDir": "src",
"target": "es5"
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"plugins": [
{
"name": "next"
}
]
},
"include": ["src", "next-env.d.ts"],
"exclude": ["node_modules"]

View File

@@ -1,3 +0,0 @@
export { toSlug } from "./toSlug";
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
export { usePrevious } from "./usePrevious";

View File

@@ -1,13 +0,0 @@
import * as React from "react";
/**
* On the server, React emits a warning when calling `useLayoutEffect`.
* This is because neither `useLayoutEffect` nor `useEffect` run on the server.
* We use this safe version which suppresses the warning by replacing it with a noop on the server.
*
* See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
*/
const useIsomorphicLayoutEffect =
typeof window !== "undefined" ? React.useLayoutEffect : () => {};
export { useIsomorphicLayoutEffect };

View File

@@ -1,17 +0,0 @@
import * as React from "react";
function usePrevious<T>(value: T) {
// The ref object is a generic container whose current property is mutable ...
// ... and can hold any value, similar to an instance property on a class
const ref = React.useRef<T>(value);
// Store current value in ref
React.useEffect(() => {
ref.current = value;
}, [value]); // Only re-run if value changes
// Return previous value (happens before update in useEffect above)
return ref.current;
}
export { usePrevious };