-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add draggable FAB & better plugin typings and definition (#4683)
* feat: re-organize exports * build: update pnpm lock file * fix: can't resolve main * feat: auto configure devtools data source hostname * feat: sizing logo image * fix: disable rspack to fix resolve issues * feat: remove settings button * feat: make action button draggable * feat: add box shadow for framebox * feat: use environment variable `HASH_SUFFIXED_VERSION` control whether use hash suffix for version * build: update pnpm lock file * feat: re-export type `Options` * fix: property `devtools` is missing in return type * build: update pnpm lock file * feat: hosting client in local * build: remove plugin devtools from the dependencies of app tools * fix: not found export `RPC_SERVER_PATHNAME` * feat: disable dynamic prefix * build: update pnpm lock file
- Loading branch information
Showing
22 changed files
with
432 additions
and
298 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,29 @@ | ||
import { URL } from 'url'; | ||
import path from 'path/posix'; | ||
import { execSync } from 'child_process'; | ||
import { logger } from '@modern-js/builder-shared'; | ||
import { appTools, defineConfig } from '@modern-js/app-tools'; | ||
import { proxyPlugin } from '@modern-js/plugin-proxy'; | ||
import { version } from './package.json'; | ||
|
||
const commitShort = execSync('git rev-parse --short=10 HEAD').toString().trim(); | ||
if (!commitShort.match(/^\w{10}$/)) { | ||
throw new Error("Can't resolve git commit hash."); | ||
} | ||
|
||
const basename = new URL(process.env.DEPLOY_HOST || 'https://modernjs.dev'); | ||
if (process.env.BASENAME === 'version' || !process.env.BASENAME) { | ||
basename.pathname = `/devtools/${version}`; | ||
} else if (process.env.BASENAME === 'commit') { | ||
basename.pathname = `/devtools/${commitShort}`; | ||
} else if (process.env.BASENAME === 'false') { | ||
basename.pathname = '/devtools'; | ||
} else { | ||
basename.pathname = path.resolve('/devtools', process.env.BASENAME); | ||
} | ||
|
||
logger.info( | ||
`Access client:`, | ||
`${basename.href}?src=ws://localhost:8080/_modern_js/devtools/rpc`, | ||
); | ||
|
||
// https://modernjs.dev/en/configure/app/usage | ||
export default defineConfig<'rspack'>({ | ||
runtime: { | ||
router: { | ||
basename: basename.pathname, | ||
basename: '/_modern_js/devtools', | ||
}, | ||
}, | ||
dev: { | ||
assetPrefix: '/_modern_js/devtools', | ||
port: 8780, | ||
assetPrefix: basename.pathname, | ||
proxy: { | ||
[basename.href]: new URL(basename.pathname, 'http://localhost:8780').href, | ||
}, | ||
}, | ||
source: { | ||
preEntry: [require.resolve('modern-normalize/modern-normalize.css')], | ||
globalVars: { | ||
'process.env.PKG_VERSION': `${version}-${commitShort}`, | ||
'process.env.PKG_VERSION': version, | ||
}, | ||
}, | ||
output: { | ||
assetPrefix: basename.href, | ||
assetPrefix: '/_modern_js/devtools', | ||
enableCssModuleTSDeclaration: true, | ||
}, | ||
tools: { | ||
devServer: { | ||
client: { | ||
host: 'localhost', | ||
protocol: 'ws', | ||
}, | ||
}, | ||
}, | ||
tools: {}, | ||
html: {}, | ||
plugins: [ | ||
appTools({ | ||
bundler: 'experimental-rspack', | ||
}), | ||
proxyPlugin(), | ||
], | ||
plugins: [appTools({ bundler: 'experimental-rspack' }), proxyPlugin()], | ||
}); |
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
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,10 @@ | ||
import _ from '@modern-js/utils/lodash'; | ||
import { parseURL, stringifyParsedURL } from 'ufo'; | ||
|
||
export interface MountPointFunctions { | ||
getLocation: () => string; | ||
} | ||
|
||
export interface SetupClientOptions { | ||
export interface SetupClientOptions extends Record<string, any> { | ||
endpoint?: string; | ||
|
||
version?: string | boolean; | ||
|
||
dataSource?: string; | ||
} |
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
96 changes: 80 additions & 16 deletions
96
packages/devtools/mount/src/components/Devtools/Action.tsx
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
Oops, something went wrong.