-
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.
- Loading branch information
1 parent
de1dbc9
commit a0c4444
Showing
60 changed files
with
6,841 additions
and
1,065 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
extends: ['turbo', '@solana/eslint-config-solana', '@solana/eslint-config-solana/jest'], | ||
root: true, | ||
rules: { | ||
'jest/expect-expect': [ | ||
'error', | ||
{ assertFunctionNames: ['expect', 'expectNewPreOffset', 'expectNewPostOffset'] }, | ||
], | ||
}, | ||
}; |
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,2 @@ | ||
*.template | ||
*.template | ||
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"jsxSingleQuote": true | ||
"singleQuote": true, | ||
"jsxSingleQuote": 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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
] | ||
} |
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,9 +1,12 @@ | ||
# Suiftly | ||
# Suiftly - CDN Optimizations for Sui Walrus | ||
|
||
CDN Optimization for Sui Walrus | ||
Load most Walrus blobs in less than 100 milliseconds! | ||
|
||
Have Webapps load your blobs in less than 50 milliseconds! | ||
Works for any Web2/Web3 browser and NodeJS apps. | ||
|
||
Project status: **Planning** | ||
Join the discussion on [Discord](https://discord.com/invite/Erb6SwsVbH) | ||
|
||
Join the discussion on [Discord](https://discord.com/invite/Erb6SwsVbH) | ||
# Thank you! | ||
- [Mysten Labs](https://mystenlabs.com) and the [Sui foundation](https://sui.io) for their innovations and financial support. | ||
- [kkomelin/sui-dapp-starter](https://github.com/kkomelin/sui-dapp-starter) time saver template | ||
- [Solana](https://github.com/solana-labs/solana-web3.js) inspiring monorepo scoped packages structure, which is mostly re-used for this project. |
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,26 +1,69 @@ | ||
{ | ||
"name": "suiftly.monorepo", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"engineStrict": true, | ||
"engines": { | ||
"node": ">=14.0.0", | ||
"npm": "please-use-pnpm", | ||
"pnpm": "^9", | ||
"yarn": "please-use-pnpm" | ||
}, | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.3", | ||
"ts-jest": "^29.2.5", | ||
"tsup": "^8.2.4", | ||
"typescript": "^5.5.4" | ||
} | ||
"name": "suiftly.monorepo", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"scripts": { | ||
"build": "turbo run --concurrency=${TURBO_CONCURRENCY:-95.84%} build", | ||
"compile": "turbo run --concurrency=${TURBO_CONCURRENCY:-95.84%} compile:js compile:typedefs", | ||
"lint": "turbo run --concurrency=${TURBO_CONCURRENCY:-95.84%} test:lint", | ||
"style:fix": "turbo run --concurrency=${TURBO_CONCURRENCY:-95.84%} style:fix && pnpm prettier --log-level warn --ignore-unknown --write '{.,!packages}/*'", | ||
"test": "turbo run --concurrency=${TURBO_CONCURRENCY:-95.84%} test:unit:browser test:unit:node" | ||
}, | ||
"devDependencies": { | ||
"@changesets/changelog-github": "^0.5.0", | ||
"@changesets/cli": "^2.27.7", | ||
"@solana/eslint-config-solana": "^3.0.4", | ||
"@solana/prettier-config-solana": "0.0.5", | ||
"@suiftly/build-scripts": "workspace:*", | ||
"@suiftly/test-config": "workspace:*", | ||
"@suiftly/test-matchers": "workspace:*", | ||
"@suiftly/tsconfig": "workspace:*", | ||
"@swc/jest": "^0.2.36", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^22", | ||
"@typescript-eslint/eslint-plugin": "^7.18.0", | ||
"@typescript-eslint/parser": "^7.18.0", | ||
"agadoo": "^3.0.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-turbo": "^2.0.14", | ||
"eslint-plugin-jest": "^27.9.0", | ||
"eslint-plugin-react-hooks": "^4.6.2", | ||
"eslint-plugin-simple-import-sort": "^12.1.1", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"eslint-plugin-typescript-sort-keys": "^3.2.0", | ||
"jest": "^30.0.0-alpha.6", | ||
"jest-environment-jsdom": "^30.0.0-alpha.6", | ||
"jest-runner-eslint": "^2.2.0", | ||
"jest-runner-prettier": "^1.0.0", | ||
"jest-watch-master": "^1.0.0", | ||
"jest-watch-select-projects": "^2.0.0", | ||
"jest-watch-typeahead": "^2.2.2", | ||
"prettier": "^3.3.3", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.2.4", | ||
"turbo": "^2.0.14", | ||
"typescript": "^5.5.4" | ||
}, | ||
"engineStrict": true, | ||
"engines": { | ||
"node": ">=14.0.0", | ||
"npm": "please-use-pnpm", | ||
"pnpm": "^9", | ||
"yarn": "please-use-pnpm" | ||
}, | ||
"packageManager": "[email protected]", | ||
"pnpm": { | ||
"overrides": { | ||
"conventional-changelog-conventionalcommits": ">= 8.0.0", | ||
"jsdom": "^22", | ||
"mock-socket": "^9.3.1", | ||
"shelljs": ">=0.8.5" | ||
}, | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
}, | ||
"prettier": "@solana/prettier-config-solana" | ||
} |
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 @@ | ||
# `build-scripts` | ||
|
||
This is the base build script shared across all packages in this monorepo. |
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,42 @@ | ||
import { readFile } from 'fs/promises'; | ||
import jscodeshift from 'jscodeshift'; | ||
import { Options } from 'tsup'; | ||
|
||
type Loader = NonNullable< | ||
NonNullable<Awaited<NonNullable<ReturnType<Parameters<Parameters<Plugin['setup']>[0]['onLoad']>[1]>>>>['loader'] | ||
>; | ||
type Plugin = NonNullable<Options['esbuildPlugins']>[number]; | ||
|
||
function replaceDev(source: string): string { | ||
if (/__DEV__/.test(source) !== true) { | ||
return source; | ||
} | ||
const j = jscodeshift.withParser('tsx'); | ||
const root = j(source); | ||
root.find(j.Identifier, { name: '__DEV__' }).replaceWith(() => | ||
j.binaryExpression( | ||
'!==', | ||
j.memberExpression( | ||
j.memberExpression(j.identifier('process'), j.identifier('env')), | ||
j.identifier('NODE_ENV'), | ||
), | ||
j.stringLiteral('production'), | ||
), | ||
); | ||
return root.toSource(); | ||
} | ||
|
||
export const DevFlagPlugin: Plugin = { | ||
name: 'dev-flag-plugin', | ||
setup(build) { | ||
build.onLoad({ filter: /\.(t|j)sx?$/, namespace: 'file' }, async ({ path }) => { | ||
const contents = await readFile(path, 'utf-8'); | ||
const ext = path.slice(path.lastIndexOf('.') + 1); | ||
const loader = (ext.match(/(j|t)sx?$/) ? ext : 'js') as Loader; | ||
return { | ||
contents: replaceDev(contents), | ||
loader, | ||
}; | ||
}); | ||
}, | ||
}; |
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,87 @@ | ||
import { env } from 'node:process'; | ||
|
||
import browsersListToEsBuild from 'browserslist-to-esbuild'; | ||
import { Format, Options } from 'tsup'; | ||
|
||
import { DevFlagPlugin } from './dev-flag'; | ||
|
||
type Platform = | ||
| 'browser' | ||
// React Native | ||
| 'native' | ||
| 'node'; | ||
|
||
const BROWSERSLIST_TARGETS = browsersListToEsBuild(); | ||
|
||
export function getBaseConfig(platform: Platform, formats: Format[], _options: Options): Options[] { | ||
return [true, false] | ||
.flatMap<Options | null>(isDebugBuild => | ||
formats.map(format => | ||
format !== 'iife' && isDebugBuild | ||
? null // We don't build debug builds for packages; only for the iife bundle. | ||
: { | ||
define: { | ||
__BROWSER__: `${platform === 'browser'}`, | ||
__NODEJS__: `${platform === 'node'}`, | ||
__REACTNATIVE__: `${platform === 'native'}`, | ||
__VERSION__: `"${env.npm_package_version}"`, | ||
}, | ||
entry: [`./src/index.ts`], | ||
esbuildOptions(options, context) { | ||
const { format } = context; | ||
options.minify = format === 'iife' && !isDebugBuild; | ||
if (format === 'iife') { | ||
options.define = { | ||
...options.define, | ||
__DEV__: `${isDebugBuild}`, | ||
}; | ||
options.target = BROWSERSLIST_TARGETS; | ||
} else { | ||
options.define = { | ||
...options.define, | ||
// Preserve `process.env.NODE_ENV` in the output without | ||
// replacing it. This allows consumers' bundlers to replace it | ||
// as they see fit. | ||
'process.env.NODE_ENV': 'process.env.NODE_ENV', | ||
}; | ||
} | ||
}, | ||
esbuildPlugins: [DevFlagPlugin], | ||
external: [ | ||
// Despite inlining `@solana/text-encoding-impl`, do not recursively inline `fastestsmallesttextencoderdecoder`. | ||
'fastestsmallesttextencoderdecoder', | ||
// Despite inlining `@solana/ws-impl`, do not recursively inline `ws`. | ||
'ws', | ||
], | ||
format, | ||
globalName: 'globalThis.solanaWeb3', | ||
name: platform, | ||
// Inline private, non-published packages. | ||
// WARNING: This inlines packages recursively. Make sure these don't have deep dep trees. | ||
noExternal: [ | ||
// @noble/ed25519 is an ESM-only module, so we have to inline it in CJS builds. | ||
...(format === 'cjs' ? ['@noble/ed25519'] : []), | ||
'@solana/crypto-impl', | ||
'@solana/text-encoding-impl', | ||
'@solana/ws-impl', | ||
], | ||
outExtension({ format }) { | ||
let extension; | ||
if (format === 'iife') { | ||
extension = `.${isDebugBuild ? 'development' : 'production.min'}.js`; | ||
} else { | ||
extension = `.${platform}.${format === 'cjs' ? 'cjs' : 'mjs'}`; | ||
} | ||
return { | ||
js: extension, | ||
}; | ||
}, | ||
platform: platform === 'node' ? 'node' : 'browser', | ||
pure: ['process'], | ||
sourcemap: format !== 'iife' || isDebugBuild, | ||
treeshake: true, | ||
}, | ||
), | ||
) | ||
.filter(Boolean) as Options[]; | ||
} |
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,14 @@ | ||
{ | ||
"name": "@suiftly/build-scripts", | ||
"version": "0.0.0", | ||
"private": true, | ||
"files": [ | ||
"tsup.config.library.ts", | ||
"tsup.config.package.ts" | ||
], | ||
"devDependencies": { | ||
"@types/jscodeshift": "^0.11.11", | ||
"browserslist-to-esbuild": "^2.1.1", | ||
"jscodeshift": "^17.0.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,8 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"compilerOptions": { | ||
"types": ["node"] | ||
}, | ||
"display": "Build Scripts", | ||
"extends": "../tsconfig/base.json" | ||
} |
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 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
import { getBaseConfig } from './getBaseConfig'; | ||
|
||
export default defineConfig(options => [...getBaseConfig('browser', ['cjs', 'esm'], options)]); |
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,15 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
import { getBaseConfig } from './getBaseConfig'; | ||
import packageConfigOrConfigsOrPromiseGetterForSame from './tsup.config.package'; | ||
|
||
export default defineConfig(async options => { | ||
const packageConfigOptionOrOptions = | ||
typeof packageConfigOrConfigsOrPromiseGetterForSame === 'function' | ||
? await packageConfigOrConfigsOrPromiseGetterForSame(options) | ||
: packageConfigOrConfigsOrPromiseGetterForSame; | ||
const packageConfigOptions = Array.isArray(packageConfigOptionOrOptions) | ||
? packageConfigOptionOrOptions | ||
: [packageConfigOptionOrOptions]; | ||
return [...packageConfigOptions, ...getBaseConfig('browser', ['iife'], options)]; | ||
}); |
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,9 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
import { getBaseConfig } from './getBaseConfig'; | ||
|
||
export default defineConfig(options => [ | ||
...getBaseConfig('node', ['cjs', 'esm'], options), | ||
...getBaseConfig('browser', ['cjs', 'esm'], options), | ||
...getBaseConfig('native', ['esm'], options), | ||
]); |
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 @@ | ||
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 @@ | ||
engine-strict=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 @@ | ||
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,4 @@ | ||
# Changelog | ||
|
||
## [0.0.1]-[0.0.x] | ||
- alpha test releases. Do not use. |
Oops, something went wrong.