-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
27 changed files
with
1,210 additions
and
753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const esbuild = require('esbuild'); | ||
const glob = require('glob'); | ||
|
||
/* | ||
The reason why we use esbuild instead of tsc is because esbuild can output .mjs files | ||
*/ | ||
|
||
const filesToInclude = ['./src/**/*.ts'].join(','); | ||
|
||
const allFiles = glob.sync(filesToInclude); | ||
|
||
const files = allFiles.filter((file) => { | ||
const hasTestFiles = file.includes('/tests/') || file.includes('/stories/'); | ||
return !hasTestFiles; | ||
}); | ||
|
||
const executeBuild = () => | ||
esbuild | ||
.build({ | ||
entryPoints: files, | ||
splitting: true, | ||
format: 'esm', | ||
outdir: 'out', | ||
treeShaking: true, | ||
minify: true, | ||
bundle: true, | ||
sourcemap: true, | ||
chunkNames: '__chunks__/[name]-[hash]', | ||
target: ['es2021'], | ||
outExtension: { '.js': '.mjs' }, | ||
tsconfig: './tsconfig.json', | ||
platform: 'node', | ||
define: { | ||
global: 'global', | ||
process: 'process', | ||
Buffer: 'Buffer' | ||
} | ||
}) | ||
.then(() => { | ||
console.log( | ||
'\x1b[36m%s\x1b[0m', | ||
`[${new Date().toLocaleTimeString()}] sdk-dapp-core build succeeded for esm types` | ||
); | ||
}) | ||
.catch((err) => { | ||
console.log(11, err); | ||
process.exit(1); | ||
}); | ||
|
||
executeBuild(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
[ | ||
{ | ||
env: { | ||
es2021: true, | ||
node: true | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2021, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true | ||
}, | ||
project: './tsconfig.json' | ||
}, | ||
settings: { | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx'] | ||
}, | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
moduleDirectory: ['node_modules', 'src/'] | ||
}, | ||
typescript: { | ||
alwaysTryTypes: true | ||
} | ||
} | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
'plugin:prettier/recommended' | ||
], | ||
plugins: ['prettier', 'import'], | ||
rules: { | ||
'import/order': [ | ||
'warn', | ||
{ | ||
groups: ['builtin', 'external', 'internal'], | ||
pathGroups: [ | ||
{ | ||
pattern: 'react', | ||
group: 'external', | ||
position: 'before' | ||
} | ||
], | ||
'newlines-between': 'ignore', | ||
alphabetize: { | ||
order: 'asc', | ||
caseInsensitive: true | ||
} | ||
} | ||
], | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
endOfLine: 'lf' | ||
} | ||
], | ||
'@typescript-eslint/indent': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ functions: false, classes: false } | ||
], | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ argsIgnorePattern: '^_' } | ||
], | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'linebreak-style': ['error', 'unix'], | ||
quotes: ['error', 'single'], | ||
semi: ['error', 'always'], | ||
'object-curly-newline': 'off', | ||
'arrow-body-style': 'off', | ||
'implicit-arrow-linebreak': 'off', | ||
'func-names': 'off', | ||
curly: ['error', 'all'], | ||
'operator-linebreak': 'off', | ||
'function-paren-newline': 'off', | ||
'no-shadow': 'off', | ||
'@typescript-eslint/no-shadow': 'off' | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './getServerConfiguration'; | ||
export * from './getNetworkConfigFromApi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './configuration'; | ||
export * from './endpoints'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './network'; | ||
export * from './storage'; | ||
export * from './window'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './core'; | ||
export * from './constants'; | ||
export * from './apiCalls'; | ||
export * from './store'; | ||
export * from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './constants'; | ||
export * from './sharedActions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { safeWindow } from '../../constants/window'; | ||
|
||
export function createCustomEvent<T>(eventName: string, eventData: T) { | ||
const event = new CustomEvent(eventName, { detail: eventData }); | ||
document.dispatchEvent(event); | ||
safeWindow?.document.dispatchEvent(event); | ||
} | ||
|
||
// Function to listen to the custom event | ||
export function listenToCustomEvent<T>( | ||
eventName: string, | ||
callback: (event: CustomEvent<T>) => void | ||
) { | ||
document.addEventListener(eventName, (evt) => { | ||
safeWindow?.document.addEventListener(eventName, (evt) => { | ||
callback(evt as CustomEvent<T>); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './actions'; | ||
export * from './slices'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './network'; | ||
export * from './account'; |
Oops, something went wrong.