generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1c4700
commit d1e2d10
Showing
17 changed files
with
7,556 additions
and
2,350 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,18 @@ | ||
{ | ||
"all": true, | ||
"cache": false, | ||
"extension": [ | ||
".js" | ||
], | ||
"include": [ | ||
"__tests__/src/**" | ||
], | ||
"exclude": [ | ||
"__tests__/src/main.js", | ||
"__tests__/types/**" | ||
], | ||
"reporter": [ | ||
"cobertura", | ||
"text" | ||
] | ||
} |
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,5 @@ | ||
{ | ||
"enable-source-maps": true, | ||
"exit": true, | ||
"spec": ["__tests__/**/*.spec.js"] | ||
} |
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,55 @@ | ||
import esbuild from 'esbuild'; | ||
import browserConfig from './esbuild-browser-config.cjs'; | ||
|
||
// cjs bundle for Electron apps. external dependencies bundled except LevelDB | ||
// Remove if/when the following PR is merged and this bundle is no longer needed by Electron apps | ||
// https://github.com/electron/electron/pull/37535 | ||
esbuild.buildSync({ | ||
platform : 'node', | ||
bundle : true, | ||
format : 'cjs', | ||
// packages: 'external', | ||
external : ['level'], | ||
sourcemap : true, | ||
entryPoints : ['./src/main.ts'], | ||
outfile : './dist/electron/main.cjs', | ||
allowOverwrite : true, | ||
}); | ||
|
||
// cjs bundle. external dependencies **not** bundled | ||
esbuild.buildSync({ | ||
platform : 'node', | ||
bundle : true, | ||
format : 'cjs', | ||
packages : 'external', | ||
sourcemap : true, | ||
entryPoints : ['./src/main.ts'], | ||
outfile : './dist/cjs/main.cjs', | ||
allowOverwrite : true, | ||
}); | ||
|
||
// esm bundle. external dependencies **not** bundled | ||
esbuild.buildSync({ | ||
platform : 'node', | ||
bundle : true, | ||
format : 'esm', | ||
packages : 'external', | ||
sourcemap : true, | ||
entryPoints : ['./src/main.ts'], | ||
outfile : './dist/esm/main.mjs', | ||
allowOverwrite : true, | ||
}); | ||
|
||
// esm polyfilled bundle for browser | ||
esbuild.build({ | ||
...browserConfig, | ||
outfile: 'dist/browser.mjs', | ||
}); | ||
|
||
// iife polyfilled bundle for browser | ||
esbuild.build({ | ||
...browserConfig, | ||
format : 'iife', | ||
globalName : 'Web5', | ||
outfile : 'dist/browser.js', | ||
}); |
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,19 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const polyfillProviderPlugin = require('node-stdlib-browser/helpers/esbuild/plugin'); | ||
const stdLibBrowser = require('node-stdlib-browser'); | ||
|
||
/** @type {import('esbuild').BuildOptions} */ | ||
module.exports = { | ||
entryPoints : ['./src/main.ts'], | ||
bundle : true, | ||
format : 'esm', | ||
sourcemap : true, | ||
minify : true, | ||
platform : 'browser', | ||
target : ['chrome101', 'firefox108', 'safari16'], | ||
inject : [require.resolve('node-stdlib-browser/helpers/esbuild/shim')], | ||
plugins : [polyfillProviderPlugin(stdLibBrowser)], | ||
define : { | ||
'global': 'globalThis', | ||
}, | ||
}; |
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,86 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
// Karma is what we're using to run our tests in browser environments | ||
// Karma does not support .mjs | ||
|
||
// playwright acts as a safari executable on windows and mac | ||
const playwright = require('@playwright/test'); | ||
const esbuildBrowserConfig = require('./build/esbuild-browser-config.cjs'); | ||
|
||
// use playwright chrome exec path as run target for chromium tests | ||
process.env.CHROME_BIN = playwright.chromium.executablePath(); | ||
|
||
// use playwright webkit exec path as run target for safari tests | ||
process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath(); | ||
|
||
// use playwright firefox exec path as run target for firefox tests | ||
process.env.FIREFOX_BIN = playwright.firefox.executablePath(); | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
plugins: [ | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-webkit-launcher', | ||
'karma-esbuild', | ||
'karma-mocha', | ||
'karma-mocha-reporter', | ||
], | ||
|
||
// frameworks to use | ||
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter | ||
frameworks: ['mocha'], | ||
|
||
// Increase Mocha's default timeout of 2 seconds to prevent timeouts during GitHub CI runs. | ||
client: { | ||
mocha: { | ||
timeout: 10000 // 10 seconds | ||
} | ||
}, | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
{ pattern: 'tests/**/*.spec.ts', watched: false }, | ||
], | ||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor | ||
preprocessors: { | ||
'tests/**/*.spec.ts': ['esbuild'], | ||
}, | ||
|
||
esbuild: esbuildBrowserConfig, | ||
|
||
// list of files / patterns to exclude | ||
exclude: [], | ||
|
||
// test results reporter to use | ||
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter | ||
reporters: ['mocha'], | ||
|
||
// web server port | ||
port: 9876, | ||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || | ||
// config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
concurrency: 1, | ||
|
||
// start these browsers | ||
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher | ||
browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'], | ||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true, | ||
|
||
// Increase browser timeouts to avoid DISCONNECTED messages during GitHub CI runs. | ||
browserDisconnectTimeout : 10000, // default 2000 | ||
browserDisconnectTolerance : 1, // default 0 | ||
}); | ||
}; |
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,107 @@ | ||
{ | ||
"name": "@tbd54566975/common", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"main": "./dist/cjs/main.cjs", | ||
"module": "./dist/esm/main.mjs", | ||
"types": "./dist/types/main.d.ts", | ||
"scripts": { | ||
"build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", | ||
"lint": "eslint . --ext .ts --max-warnings 0", | ||
"lint:fix": "eslint . --ext .ts --fix", | ||
"test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && c8 mocha", | ||
"test:browser": "karma start karma.conf.cjs" | ||
}, | ||
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/common#readme", | ||
"bugs": "https://github.com/TBD54566975/web5-js/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TBD54566975/web5-js", | ||
"directory": "packages/common" | ||
}, | ||
"license": "Apache-2.0", | ||
"contributors": [ | ||
{ | ||
"name": "Daniel Buchner", | ||
"url": "https://github.com/csuwildcat" | ||
}, | ||
{ | ||
"name": "Frank Hinek", | ||
"url": "https://github.com/frankhinek" | ||
}, | ||
{ | ||
"name": "Moe Jangda", | ||
"url": "https://github.com/mistermoe" | ||
} | ||
], | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/main.mjs", | ||
"require": "./dist/cjs/main.cjs", | ||
"types": "./dist/types/main.d.ts" | ||
}, | ||
"./browser": { | ||
"import": "./dist/browser.mjs", | ||
"require": "./dist/browser.js", | ||
"types": "./dist/types/main.d.ts" | ||
}, | ||
"./electron": { | ||
"import": "./dist/esm/main.mjs", | ||
"require": "./dist/electron/main.cjs", | ||
"types": "./dist/types/main.d.ts" | ||
} | ||
}, | ||
"browser": { | ||
"./dist/esm/main.mjs": "./dist/browser.mjs", | ||
"./dist/cjs/main.cjs": "./dist/browser.js", | ||
"types": "./dist/types/main.d.ts" | ||
}, | ||
"keywords": [ | ||
"decentralized", | ||
"decentralized-applications", | ||
"decentralized-identity", | ||
"decentralized-web", | ||
"vcs", | ||
"verifiable credentials", | ||
"web5" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/chai": "4.3.0", | ||
"@types/eslint": "8.37.0", | ||
"@types/mocha": "10.0.1", | ||
"@typescript-eslint/eslint-plugin": "5.59.0", | ||
"@typescript-eslint/parser": "5.59.0", | ||
"c8": "7.14.0", | ||
"chai": "4.3.7", | ||
"esbuild": "0.16.7", | ||
"eslint": "8.39.0", | ||
"eslint-plugin-mocha": "10.1.0", | ||
"karma": "6.4.1", | ||
"karma-chai": "0.1.0", | ||
"karma-chrome-launcher": "3.1.1", | ||
"karma-esbuild": "2.2.5", | ||
"karma-firefox-launcher": "2.1.2", | ||
"karma-mocha": "2.0.1", | ||
"karma-mocha-reporter": "2.2.5", | ||
"karma-webkit-launcher": "2.1.0", | ||
"mocha": "10.2.0", | ||
"node-stdlib-browser": "1.2.0", | ||
"playwright": "1.31.2", | ||
"rimraf": "4.4.0", | ||
"typescript": "5.0.4" | ||
}, | ||
"overrides": { | ||
"socket.io-parser@>4.0.4 <4.2.3": "4.2.3" | ||
} | ||
} |
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 @@ | ||
export * from './types.js'; |
File renamed without changes.
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,7 @@ | ||
import { expect } from 'chai'; | ||
|
||
describe('example', () => { | ||
it('works', () => { | ||
expect(true).to.be.true; | ||
}); | ||
}); |
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,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"lib": [ | ||
"DOM", | ||
"ES6" | ||
], | ||
"allowJs": true, | ||
"target": "es6", | ||
"module": "ESNext", // Required for enabling JavaScript import assertion support | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"declarationDir": "dist/types", | ||
"sourceMap": true, | ||
// `NodeNext` will throw compilation errors if relative import paths are missing file extension | ||
// reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js | ||
"moduleResolution": "NodeNext", | ||
"esModuleInterop": true | ||
}, | ||
"include": [ | ||
"src", | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
] | ||
} |
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,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"DOM", | ||
"ES6" | ||
], | ||
"target": "es6", | ||
"module": "ESNext", // Required for enabling JavaScript import assertion support | ||
"declaration": true, | ||
"declarationMap": true, | ||
"outDir": "__tests__", | ||
"declarationDir": "__tests__/types", | ||
"sourceMap": true, | ||
// `NodeNext` will throw compilation errors if relative import paths are missing file extension | ||
// reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js | ||
"moduleResolution": "NodeNext", | ||
// allows us to import json files | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": [ | ||
"src", | ||
"tests", | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
] | ||
} |
Oops, something went wrong.