@zk-tech/rrt-plugin-rspack 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/index.cjs +15 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/middlewares/index.d.ts +4 -0
- package/dist/middlewares/launch-editor.d.ts +2 -0
- package/dist/middlewares/read-file.d.ts +2 -0
- package/dist/middlewares/standalone.d.ts +2 -0
- package/dist/middlewares/types.d.ts +14 -0
- package/dist/middlewares/utils.d.ts +2 -0
- package/package.json +4 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/config.ts","../src/utilities/scripts.ts","../src/index.ts"],"sourcesContent":["export const coreSrc = 'perf-monitor-core.bundle.js';\nexport const clientSrc = 'perf-monitor-client.bundle.js';\n","import type { BackendEnv } from '@zk-tech/rrt-shared';\nimport type { PluginOptions } from '..';\n\nexport const getPluginScripts = (options?: PluginOptions) => {\n const { rendererId, diffMode = 'lite', updateTrace = true, commitTrace = true } = options || {};\n\n const env: BackendEnv = {\n clientHost: 'inpage',\n bundler: 'rspack',\n bundlerVersion: __PLUGIN_VERSION__,\n diffMode,\n updateTrace,\n commitTrace,\n };\n\n let settingScript = `window.__PERF_MONITOR_DEVTOOLS_ENV__ = ${JSON.stringify(env)};`;\n\n if (rendererId) {\n settingScript += `window.__PERF_MONITOR_DEVTOOLS_CONTEXT__ = { rendererId: ${rendererId} };`;\n }\n\n const coreScript = __CORE_SCRIPT__;\n const clientScript = __CLIENT_SCRIPT__;\n\n return {\n settingScript,\n coreScript,\n clientScript,\n };\n};\n","import type { BackendEnv } from '@zk-tech/rrt-shared';\n\nimport { clientSrc, coreSrc } from './config';\nimport { getPluginScripts } from './utilities/scripts';\n\ninterface PluginOptions {\n /**\n * Specifies whether the devtools should be disabled.\n */\n disabled?: boolean;\n /**\n * Sets the rendererId to inspect, only if you know what it is used for.\n *\n * It is recommended to use the plugin's rendererId selection feature before manually configuring the rendererId when using the plugin for the first time.\n */\n rendererId?: number;\n /**\n * The diff mode to use. Defaults to lite diff mode. Full diff mode is not supported yet.\n * - \"off\": No diffs (Performance will be slightly improved).\n * - \"lite\": Only simple diffs (Performance will be slightly impacted).\n * - \"full\": All nested diffs (Performance will be significantly impacted).\n * @default \"lite\"\n */\n diffMode?: BackendEnv['diffMode'];\n /**\n * Whether to record update related events.\n * @default true\n */\n updateTrace?: boolean;\n /**\n * Whether to record commit.\n * @default true\n */\n commitTrace?: boolean;\n}\n\ninterface HtmlTag {\n attributes: Record<string, string | boolean>;\n tagName: string;\n voidTag: boolean;\n innerHTML?: string;\n meta: Record<string, unknown>;\n}\n\ninterface HtmlTagGroupsData {\n headTags: HtmlTag[];\n}\n\ninterface HtmlTagGroupsHook {\n tapPromise: (\n name: string,\n fn: (data: HtmlTagGroupsData) => Promise<HtmlTagGroupsData | void> | HtmlTagGroupsData | void,\n ) => void;\n}\n\ninterface HtmlRspackPluginLike {\n getCompilationHooks: (compilation: CompilationLike) => {\n alterAssetTagGroups: HtmlTagGroupsHook;\n };\n}\n\ninterface RawSourceConstructor {\n new (source: string): unknown;\n}\n\ninterface CompilationLike {\n assets?: Record<string, unknown>;\n emitAsset?: (name: string, source: unknown) => void;\n}\n\ninterface CompilerLike {\n hooks: {\n compilation: {\n tap: (name: string, fn: (compilation: CompilationLike) => void) => void;\n };\n };\n webpack?: {\n sources?: {\n RawSource?: RawSourceConstructor;\n };\n };\n rspack?: {\n HtmlRspackPlugin?: HtmlRspackPluginLike;\n };\n}\n\nconst pluginName = 'PerfMonitorRspackPlugin';\n\nfunction emitAsset(compilation: CompilationLike, filename: string, source: unknown) {\n if (typeof compilation.emitAsset === 'function') {\n compilation.emitAsset(filename, source);\n return;\n }\n\n if (!compilation.assets) {\n compilation.assets = {};\n }\n compilation.assets[filename] = source;\n}\n\nclass PerfMonitorRspackPlugin {\n options: PluginOptions;\n\n constructor(pluginOptions?: PluginOptions) {\n this.options = pluginOptions || {\n disabled: false,\n };\n }\n\n apply(compiler: CompilerLike) {\n if (this.options.disabled) {\n return;\n }\n\n const HtmlRspackPlugin = compiler.rspack?.HtmlRspackPlugin;\n if (!HtmlRspackPlugin?.getCompilationHooks) {\n throw new Error(\n `${pluginName} requires rspack.HtmlRspackPlugin. Add \"new rspack.HtmlRspackPlugin()\" before this plugin.`,\n );\n }\n\n compiler.hooks.compilation.tap(pluginName, (compilation) => {\n const RawSource = compiler.webpack?.sources?.RawSource;\n if (!RawSource) {\n throw new Error(`${pluginName} requires compiler.webpack.sources.RawSource.`);\n }\n\n const { coreScript, clientScript, settingScript } = getPluginScripts(this.options);\n emitAsset(compilation, coreSrc, new RawSource(coreScript));\n emitAsset(compilation, clientSrc, new RawSource(clientScript));\n\n HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTagGroups.tapPromise(\n pluginName,\n async (data) => {\n data.headTags.unshift(\n {\n attributes: { defer: true, src: `/${clientSrc}` },\n tagName: 'script',\n voidTag: false,\n meta: {},\n },\n {\n attributes: { defer: true, src: `/${coreSrc}` },\n tagName: 'script',\n voidTag: false,\n meta: {},\n },\n );\n\n data.headTags.unshift({\n attributes: {},\n tagName: 'script',\n voidTag: false,\n innerHTML: settingScript,\n meta: {},\n });\n\n return data;\n },\n );\n });\n }\n}\n\nexport { PerfMonitorRspackPlugin, type PluginOptions };\n"],"names":["coreSrc","clientSrc","getPluginScripts","options","rendererId","diffMode","updateTrace","commitTrace","settingScript","pluginName","emitAsset","compilation","filename","source","PerfMonitorRspackPlugin","pluginOptions","compiler","HtmlRspackPlugin","_a","RawSource","_b","coreScript","clientScript","data"],"mappings":"gFAAO,MAAMA,EAAU,8BACVC,EAAY,gCCEZC,EAAoBC,GAA4B,CAC3D,KAAM,CAAE,WAAAC,EAAY,SAAAC,EAAW,OAAQ,YAAAC,EAAc,GAAM,YAAAC,EAAc,IAASJ,GAAW,CAAA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ACE,WAAY,CAAE,MAAO,GAAM,IAAK,IAAItB,CAAS,EAAA,EAC7C,QAAS,SACT,QAAS,GACT,KAAM,CAAA,CAAC,EAET,CACE,WAAY,CAAE,MAAO,GAAM,IAAK,IAAID,CAAO,EAAA,EAC3C,QAAS,SACT,QAAS,GACT,KAAM,CAAA,CAAC,CACT,EAGFuB,EAAK,SAAS,QAAQ,CACpB,WAAY,CAAA,EACZ,QAAS,SACT,QAAS,GACT,UAAWf,EACX,KAAM,CAAA,CAAC,CACR,EAEMe,EACT,CAEJ,CAAC,CACH,CACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/config.ts","../../devtools-shared/dist/index.js","../src/middlewares/utils.ts","../src/middlewares/standalone.ts","../src/middlewares/read-file.ts","../src/middlewares/launch-editor.ts","../src/utilities/scripts.ts","../src/index.ts"],"sourcesContent":["export const coreSrc = 'perf-monitor-core.bundle.js';\nexport const clientSrc = 'perf-monitor-client.bundle.js';\n","var commonjsGlobal = typeof globalThis !== \"undefined\" ? globalThis : typeof window !== \"undefined\" ? window : typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : {};\nfunction getDefaultExportFromCjs(x) {\n return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, \"default\") ? x[\"default\"] : x;\n}\nvar lodash_debounce;\nvar hasRequiredLodash_debounce;\nfunction requireLodash_debounce() {\n if (hasRequiredLodash_debounce) return lodash_debounce;\n hasRequiredLodash_debounce = 1;\n var FUNC_ERROR_TEXT = \"Expected a function\";\n var NAN = 0 / 0;\n var symbolTag = \"[object Symbol]\";\n var reTrim = /^\\s+|\\s+$/g;\n var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n var reIsBinary = /^0b[01]+$/i;\n var reIsOctal = /^0o[0-7]+$/i;\n var freeParseInt = parseInt;\n var freeGlobal = typeof commonjsGlobal == \"object\" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;\n var freeSelf = typeof self == \"object\" && self && self.Object === Object && self;\n var root = freeGlobal || freeSelf || Function(\"return this\")();\n var objectProto = Object.prototype;\n var objectToString = objectProto.toString;\n var nativeMax = Math.max, nativeMin = Math.min;\n var now = function() {\n return root.Date.now();\n };\n function debounce(func, wait, options) {\n var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;\n if (typeof func != \"function\") {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = \"maxWait\" in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = \"trailing\" in options ? !!options.trailing : trailing;\n }\n function invokeFunc(time) {\n var args = lastArgs, thisArg = lastThis;\n lastArgs = lastThis = void 0;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n function leadingEdge(time) {\n lastInvokeTime = time;\n timerId = setTimeout(timerExpired, wait);\n return leading ? invokeFunc(time) : result;\n }\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;\n return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;\n }\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;\n return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;\n }\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n function trailingEdge(time) {\n timerId = void 0;\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = void 0;\n return result;\n }\n function cancel() {\n if (timerId !== void 0) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = void 0;\n }\n function flush() {\n return timerId === void 0 ? result : trailingEdge(now());\n }\n function debounced() {\n var time = now(), isInvoking = shouldInvoke(time);\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n if (isInvoking) {\n if (timerId === void 0) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === void 0) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n }\n function isObject(value) {\n var type = typeof value;\n return !!value && (type == \"object\" || type == \"function\");\n }\n function isObjectLike(value) {\n return !!value && typeof value == \"object\";\n }\n function isSymbol(value) {\n return typeof value == \"symbol\" || isObjectLike(value) && objectToString.call(value) == symbolTag;\n }\n function toNumber(value) {\n if (typeof value == \"number\") {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == \"function\" ? value.valueOf() : value;\n value = isObject(other) ? other + \"\" : other;\n }\n if (typeof value != \"string\") {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, \"\");\n var isBinary = reIsBinary.test(value);\n return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;\n }\n lodash_debounce = debounce;\n return lodash_debounce;\n}\nvar lodash_debounceExports = requireLodash_debounce();\nconst index = /* @__PURE__ */ getDefaultExportFromCjs(lodash_debounceExports);\nconst noop = () => null;\nconst groupBy = (array, fn) => array.reduce(\n (acc, item) => {\n const key = fn(item);\n const group = acc[key] || [];\n acc[key] = [...group, item];\n return acc;\n },\n {}\n);\nconst DEVTOOLS_SHADOW_DOM_ID = \"__perf-monitor-devtools-container__\";\nconst DEVTOOLS_SHADOW_DOM_ROOT_ID = \"__perf-monitor-devtools-root__\";\nconst DEVTOOLS_OPEN_EDITOR_ENDPOINT = \"/__react-render-tracker__/open\";\nconst DEVTOOLS_READ_FILE_ENDPOINT = \"/__react-render-tracker__/read\";\nconst DEVTOOLS_STANDALONE = \"/__react-render-tracker__/standalone\";\nconst ElementTypeClass = 1;\nconst ElementTypeFunction = 2;\nconst ElementTypeMemo = 3;\nconst ElementTypeForwardRef = 4;\nconst ElementTypeProvider = 5;\nconst ElementTypeConsumer = 6;\nconst ElementTypeHostRoot = 7;\nconst ElementTypeHostComponent = 8;\nconst ElementTypeHostText = 9;\nconst ElementTypeHostPortal = 10;\nconst ElementTypeSuspense = 11;\nconst ElementTypeSuspenseList = 12;\nconst ElementTypeProfiler = 13;\nconst ElementTypeOtherOrUnknown = 14;\nconst FiberTypeName = {\n [ElementTypeClass]: \"Class component\",\n [ElementTypeFunction]: \"Function component\",\n [ElementTypeMemo]: \"Memo\",\n [ElementTypeForwardRef]: \"ForwardRef\",\n [ElementTypeProvider]: \"Provider\",\n [ElementTypeConsumer]: \"Consumer\",\n [ElementTypeHostRoot]: \"Render root\",\n [ElementTypeHostComponent]: \"Host component\",\n [ElementTypeHostText]: \"Host text\",\n [ElementTypeHostPortal]: \"Host portal\",\n [ElementTypeSuspense]: \"Suspense\",\n [ElementTypeSuspenseList]: \"Suspense list\",\n [ElementTypeProfiler]: \"Profiler\",\n [ElementTypeOtherOrUnknown]: \"Unknown\"\n};\nconst LegacyRoot = 0;\nconst ConcurrentRoot = 1;\nconst fiberRootMode = {\n [LegacyRoot]: \"Legacy Mode\",\n [ConcurrentRoot]: \"Concurrent Mode\"\n};\nconst TrackingObjectFiber = 0;\nconst TrackingObjectAlternate = 1;\nconst TrackingObjectStateNode = 2;\nconst TrackingObjectHook = 3;\nconst TrackingObjectTypeName = {\n [TrackingObjectFiber]: \"fiber\",\n [TrackingObjectAlternate]: \"alternate\",\n [TrackingObjectStateNode]: \"stateNode\",\n [TrackingObjectHook]: \"hook\"\n};\nexport {\n ConcurrentRoot,\n DEVTOOLS_OPEN_EDITOR_ENDPOINT,\n DEVTOOLS_READ_FILE_ENDPOINT,\n DEVTOOLS_SHADOW_DOM_ID,\n DEVTOOLS_SHADOW_DOM_ROOT_ID,\n DEVTOOLS_STANDALONE,\n ElementTypeClass,\n ElementTypeConsumer,\n ElementTypeForwardRef,\n ElementTypeFunction,\n ElementTypeHostComponent,\n ElementTypeHostPortal,\n ElementTypeHostRoot,\n ElementTypeHostText,\n ElementTypeMemo,\n ElementTypeOtherOrUnknown,\n ElementTypeProfiler,\n ElementTypeProvider,\n ElementTypeSuspense,\n ElementTypeSuspenseList,\n FiberTypeName,\n LegacyRoot,\n TrackingObjectAlternate,\n TrackingObjectFiber,\n TrackingObjectHook,\n TrackingObjectStateNode,\n TrackingObjectTypeName,\n index as debounce,\n fiberRootMode,\n groupBy,\n noop\n};\n//# sourceMappingURL=index.js.map\n","export const formatRequestURL = (url: string) => new URL(url, 'https://base.com');\n\nexport const parseQuery = <T = unknown>(searchParams: URLSearchParams) =>\n Object.fromEntries(searchParams.entries()) as T;\n","import { DEVTOOLS_STANDALONE } from '@zk-tech/rrt-shared';\n\nimport { clientSrc } from '@/config';\n\nimport type { RequestHandler } from './types';\nimport { formatRequestURL } from './utils';\n\nexport const standaloneHandler: RequestHandler = (req, res, next) => {\n const url = formatRequestURL(req.url || '');\n\n if (url.pathname.startsWith(DEVTOOLS_STANDALONE)) {\n res.statusCode = 200;\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n return res.end(`\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Perf Monitor Devtools</title>\n <script>\n window.__PERF_MONITOR_DEVTOOLS_CLIENT_SEPARATE__ = true;\n </script>\n </head>\n <body></body>\n <script src=\"/${clientSrc}\"></script>\n </html>\n `);\n }\n\n next();\n};\n","import fs from 'node:fs';\nimport { DEVTOOLS_READ_FILE_ENDPOINT } from '@zk-tech/rrt-shared';\n\nimport type { ReadFileParams, RequestHandler } from './types';\nimport { formatRequestURL, parseQuery } from './utils';\n\nexport const readFileHandler: RequestHandler = (req, res, next) => {\n const url = formatRequestURL(req.url || '');\n\n if (url.pathname.startsWith(DEVTOOLS_READ_FILE_ENDPOINT)) {\n const params = parseQuery<ReadFileParams>(url.searchParams);\n\n if (!params.filename || !fs.existsSync(params.filename)) {\n return next();\n }\n\n const content = fs.readFileSync(params.filename, 'utf-8');\n res.statusCode = 200;\n res.setHeader('Content-Type', 'text/plain; charset=utf-8');\n return res.end(content);\n }\n\n next();\n};\n","import { spawn } from 'node:child_process';\nimport { DEVTOOLS_OPEN_EDITOR_ENDPOINT } from '@zk-tech/rrt-shared';\n\nimport type { Editor, LaunchEditorParams, RequestHandler } from './types';\nimport { formatRequestURL, parseQuery } from './utils';\n\nfunction buildEditorCommand(\n editor: Editor,\n filename: string,\n line?: string,\n col?: string,\n): { command: string; args: string[] } {\n const hasLine = Boolean(line);\n const hasCol = Boolean(col);\n\n if (editor === 'code' || editor === 'code-insiders' || editor === 'cursor' || editor === 'zed') {\n if (hasLine || hasCol) {\n const targetLine = line || '1';\n const targetCol = col || '1';\n return {\n command: editor,\n args: ['-g', `${filename}:${targetLine}:${targetCol}`],\n };\n }\n\n return {\n command: editor,\n args: [filename],\n };\n }\n\n return {\n command: editor,\n args: [filename],\n };\n}\n\nexport const createLaunchEditorHandler = (editor: Editor = 'code') => {\n const handler: RequestHandler = (req, res, next) => {\n const url = formatRequestURL(req.url || '');\n\n if (url.pathname.startsWith(DEVTOOLS_OPEN_EDITOR_ENDPOINT)) {\n const params = parseQuery<LaunchEditorParams>(url.searchParams);\n\n if (!params.filename) {\n return next();\n }\n\n const selectedEditor = params.editor || editor;\n\n try {\n const { command, args } = buildEditorCommand(\n selectedEditor,\n params.filename,\n params.line,\n params.col,\n );\n const child = spawn(command, args, {\n detached: true,\n stdio: 'ignore',\n });\n child.unref();\n } catch (error) {\n res.statusCode = 500;\n return res.end(\n JSON.stringify({\n message: 'Failed to launch editor.',\n error: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n\n res.statusCode = 200;\n return res.end();\n }\n\n next();\n };\n\n return handler;\n};\n","import type { BackendEnv } from '@zk-tech/rrt-shared';\nimport type { PluginOptions } from '..';\n\nexport const getPluginScripts = (options?: PluginOptions) => {\n const { rendererId, separate, diffMode = 'lite', updateTrace = true, commitTrace = true } =\n options || {};\n\n const env: BackendEnv = {\n clientHost: separate ? 'separate' : 'inpage',\n bundler: 'rspack',\n bundlerVersion: __PLUGIN_VERSION__,\n diffMode,\n updateTrace,\n commitTrace,\n };\n\n let settingScript = `window.__PERF_MONITOR_DEVTOOLS_ENV__ = ${JSON.stringify(env)};`;\n\n if (rendererId) {\n settingScript += `window.__PERF_MONITOR_DEVTOOLS_CONTEXT__ = { rendererId: ${rendererId} };`;\n }\n\n const coreScript = __CORE_SCRIPT__;\n const clientScript = __CLIENT_SCRIPT__;\n\n return {\n settingScript,\n coreScript,\n clientScript,\n };\n};\n","import type { BackendEnv } from '@zk-tech/rrt-shared';\n\nimport { clientSrc, coreSrc } from './config';\nimport { createLaunchEditorHandler, type Editor, readFileHandler, standaloneHandler } from './middlewares';\nimport { getPluginScripts } from './utilities/scripts';\n\ninterface PluginOptions {\n /**\n * Specifies whether the devtools should be disabled.\n */\n disabled?: boolean;\n /**\n * Sets the rendererId to inspect, only if you know what it is used for.\n *\n * It is recommended to use the plugin's rendererId selection feature before manually configuring the rendererId when using the plugin for the first time.\n */\n rendererId?: number;\n /**\n * Whether devtools client runs in a separate window.\n */\n separate?: boolean;\n /**\n * The editor instance used to open files from DevTools.\n * @default \"code\"\n */\n editor?: Editor;\n /**\n * The diff mode to use. Defaults to lite diff mode. Full diff mode is not supported yet.\n * - \"off\": No diffs (Performance will be slightly improved).\n * - \"lite\": Only simple diffs (Performance will be slightly impacted).\n * - \"full\": All nested diffs (Performance will be significantly impacted).\n * @default \"lite\"\n */\n diffMode?: BackendEnv['diffMode'];\n /**\n * Whether to record update related events.\n * @default true\n */\n updateTrace?: boolean;\n /**\n * Whether to record commit.\n * @default true\n */\n commitTrace?: boolean;\n}\n\ninterface HtmlTag {\n attributes: Record<string, string | boolean>;\n tagName: string;\n voidTag: boolean;\n innerHTML?: string;\n meta: Record<string, unknown>;\n}\n\ninterface HtmlTagGroupsData {\n headTags: HtmlTag[];\n}\n\ninterface HtmlTagGroupsHook {\n tapPromise: (\n name: string,\n fn: (data: HtmlTagGroupsData) => Promise<HtmlTagGroupsData | void> | HtmlTagGroupsData | void,\n ) => void;\n}\n\ninterface HtmlRspackPluginLike {\n getCompilationHooks: (compilation: CompilationLike) => {\n alterAssetTagGroups: HtmlTagGroupsHook;\n };\n}\n\ninterface RawSourceConstructor {\n new (source: string): unknown;\n}\n\ninterface CompilationLike {\n assets?: Record<string, unknown>;\n emitAsset?: (name: string, source: unknown) => void;\n}\n\ntype DevServerRequestHandler = (\n req: import('node:http').IncomingMessage,\n res: import('node:http').ServerResponse,\n next: () => void,\n) => void;\n\ninterface CompilerLike {\n hooks: {\n compilation: {\n tap: (name: string, fn: (compilation: CompilationLike) => void) => void;\n };\n };\n options?: {\n devServer?: {\n setupMiddlewares?: (\n middlewares: DevServerRequestHandler[],\n devServer: unknown,\n ) => DevServerRequestHandler[] | void;\n };\n };\n webpack?: {\n sources?: {\n RawSource?: RawSourceConstructor;\n };\n };\n rspack?: {\n HtmlRspackPlugin?: HtmlRspackPluginLike;\n };\n}\n\nconst pluginName = 'PerfMonitorRspackPlugin';\n\nfunction emitAsset(compilation: CompilationLike, filename: string, source: unknown) {\n if (typeof compilation.emitAsset === 'function') {\n compilation.emitAsset(filename, source);\n return;\n }\n\n if (!compilation.assets) {\n compilation.assets = {};\n }\n compilation.assets[filename] = source;\n}\n\nfunction attachDevServerMiddlewares(compiler: CompilerLike, options: PluginOptions) {\n if (!compiler.options) {\n return;\n }\n\n const devServer = compiler.options.devServer || (compiler.options.devServer = {});\n const existingSetupMiddlewares = devServer.setupMiddlewares;\n const standalone = Boolean(options.separate);\n const editor = options.editor || 'code';\n let injected = false;\n\n devServer.setupMiddlewares = (middlewares, devServerContext) => {\n const middlewareStack = Array.isArray(middlewares) ? middlewares : [];\n const handled =\n typeof existingSetupMiddlewares === 'function'\n ? existingSetupMiddlewares(middlewareStack, devServerContext)\n : middlewareStack;\n\n const targetMiddlewares = Array.isArray(handled) ? handled : middlewareStack;\n if (injected) {\n return targetMiddlewares;\n }\n\n if (standalone) {\n targetMiddlewares.unshift(standaloneHandler);\n }\n targetMiddlewares.unshift(readFileHandler);\n targetMiddlewares.unshift(createLaunchEditorHandler(editor));\n injected = true;\n\n return targetMiddlewares;\n };\n}\n\nclass PerfMonitorRspackPlugin {\n options: PluginOptions;\n\n constructor(pluginOptions?: PluginOptions) {\n this.options = pluginOptions || {\n disabled: false,\n };\n }\n\n apply(compiler: CompilerLike) {\n if (this.options.disabled) {\n return;\n }\n\n attachDevServerMiddlewares(compiler, this.options);\n\n const HtmlRspackPlugin = compiler.rspack?.HtmlRspackPlugin;\n if (!HtmlRspackPlugin?.getCompilationHooks) {\n throw new Error(\n `${pluginName} requires rspack.HtmlRspackPlugin. Add \"new rspack.HtmlRspackPlugin()\" before this plugin.`,\n );\n }\n\n compiler.hooks.compilation.tap(pluginName, (compilation) => {\n const RawSource = compiler.webpack?.sources?.RawSource;\n if (!RawSource) {\n throw new Error(`${pluginName} requires compiler.webpack.sources.RawSource.`);\n }\n\n const { coreScript, clientScript, settingScript } = getPluginScripts(this.options);\n emitAsset(compilation, coreSrc, new RawSource(coreScript));\n emitAsset(compilation, clientSrc, new RawSource(clientScript));\n\n HtmlRspackPlugin.getCompilationHooks(compilation).alterAssetTagGroups.tapPromise(\n pluginName,\n async (data) => {\n const scripts: HtmlTag[] = [\n {\n attributes: {},\n tagName: 'script',\n voidTag: false,\n innerHTML: settingScript,\n meta: {},\n },\n {\n attributes: { defer: true, src: `/${coreSrc}` },\n tagName: 'script',\n voidTag: false,\n meta: {},\n },\n ];\n\n if (!this.options.separate) {\n scripts.splice(1, 0, {\n attributes: { defer: true, src: `/${clientSrc}` },\n tagName: 'script',\n voidTag: false,\n meta: {},\n });\n }\n\n data.headTags.unshift(...scripts);\n return data;\n },\n );\n });\n }\n}\n\nexport { PerfMonitorRspackPlugin, type PluginOptions };\n"],"names":["coreSrc","clientSrc","commonjsGlobal","lodash_debounce","hasRequiredLodash_debounce","requireLodash_debounce","FUNC_ERROR_TEXT","NAN","symbolTag","reTrim","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","freeGlobal","freeSelf","root","objectProto","objectToString","nativeMax","nativeMin","now","debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","toNumber","isObject","invokeFunc","time","args","thisArg","leadingEdge","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","result2","shouldInvoke","trailingEdge","cancel","flush","debounced","isInvoking","value","type","isObjectLike","isSymbol","other","isBinary","DEVTOOLS_OPEN_EDITOR_ENDPOINT","DEVTOOLS_READ_FILE_ENDPOINT","DEVTOOLS_STANDALONE","formatRequestURL","url","parseQuery","searchParams","standaloneHandler","req","res","next","readFileHandler","params","fs","content","buildEditorCommand","editor","filename","line","col","hasLine","hasCol","createLaunchEditorHandler","selectedEditor","command","spawn","error","getPluginScripts","rendererId","separate","diffMode","updateTrace","commitTrace","settingScript","pluginName","emitAsset","compilation","source","attachDevServerMiddlewares","compiler","devServer","existingSetupMiddlewares","standalone","injected","middlewares","devServerContext","middlewareStack","handled","targetMiddlewares","PerfMonitorRspackPlugin","pluginOptions","HtmlRspackPlugin","_a","RawSource","_b","coreScript","clientScript","data","scripts"],"mappings":"4IAAaA,EAAU,8BACVC,EAAY,gCCDzB,IAAIC,EAAiB,OAAO,WAAe,IAAc,WAAa,OAAO,OAAW,IAAc,OAAS,OAAO,OAAW,IAAc,OAAS,OAAO,KAAS,IAAc,KAAO,CAAA,EAIzLC,EACAC,EACJ,SAASC,IAAyB,CAChC,GAAID,EAA4B,OAAOD,EACvCC,EAA6B,EAC7B,IAAIE,EAAkB,sBAClBC,EAAM,IACNC,EAAY,kBACZC,EAAS,aACTC,EAAa,qBACbC,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,EAAQ,OAAO,EAAG,EAAG,CACnB,WAAY,CAAE,MAAO,GAAM,IAAK,IAAIrH,CAAS,EAAA,EAC7C,QAAS,SACT,QAAS,GACT,KAAM,CAAA,CAAC,CACR,EAGHoH,EAAK,SAAS,QAAQ,GAAGC,CAAO,EACzBD,CACT,CAAA,CAEJ,CAAC,CACH,CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BackendEnv } from '@zk-tech/rrt-shared';
|
|
2
|
+
import { Editor } from './middlewares';
|
|
2
3
|
interface PluginOptions {
|
|
3
4
|
/**
|
|
4
5
|
* Specifies whether the devtools should be disabled.
|
|
@@ -10,6 +11,15 @@ interface PluginOptions {
|
|
|
10
11
|
* It is recommended to use the plugin's rendererId selection feature before manually configuring the rendererId when using the plugin for the first time.
|
|
11
12
|
*/
|
|
12
13
|
rendererId?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Whether devtools client runs in a separate window.
|
|
16
|
+
*/
|
|
17
|
+
separate?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The editor instance used to open files from DevTools.
|
|
20
|
+
* @default "code"
|
|
21
|
+
*/
|
|
22
|
+
editor?: Editor;
|
|
13
23
|
/**
|
|
14
24
|
* The diff mode to use. Defaults to lite diff mode. Full diff mode is not supported yet.
|
|
15
25
|
* - "off": No diffs (Performance will be slightly improved).
|
|
@@ -54,12 +64,18 @@ interface CompilationLike {
|
|
|
54
64
|
assets?: Record<string, unknown>;
|
|
55
65
|
emitAsset?: (name: string, source: unknown) => void;
|
|
56
66
|
}
|
|
67
|
+
type DevServerRequestHandler = (req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse, next: () => void) => void;
|
|
57
68
|
interface CompilerLike {
|
|
58
69
|
hooks: {
|
|
59
70
|
compilation: {
|
|
60
71
|
tap: (name: string, fn: (compilation: CompilationLike) => void) => void;
|
|
61
72
|
};
|
|
62
73
|
};
|
|
74
|
+
options?: {
|
|
75
|
+
devServer?: {
|
|
76
|
+
setupMiddlewares?: (middlewares: DevServerRequestHandler[], devServer: unknown) => DevServerRequestHandler[] | void;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
63
79
|
webpack?: {
|
|
64
80
|
sources?: {
|
|
65
81
|
RawSource?: RawSourceConstructor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
export type NextFunction = () => void;
|
|
3
|
+
export type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
4
|
+
export type Middleware = (middlewares: RequestHandler[]) => void;
|
|
5
|
+
export type Editor = 'code' | 'webstorm' | 'idea' | 'cursor' | 'zed' | 'code-insiders';
|
|
6
|
+
export interface LaunchEditorParams {
|
|
7
|
+
filename?: string;
|
|
8
|
+
line?: string;
|
|
9
|
+
col?: string;
|
|
10
|
+
editor?: Editor;
|
|
11
|
+
}
|
|
12
|
+
export interface ReadFileParams {
|
|
13
|
+
filename?: string;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zk-tech/rrt-plugin-rspack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.cjs",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@zk-tech/rrt-client": "0.0.
|
|
8
|
-
"@zk-tech/rrt-
|
|
9
|
-
"@zk-tech/rrt-
|
|
7
|
+
"@zk-tech/rrt-client": "0.0.3",
|
|
8
|
+
"@zk-tech/rrt-shared": "0.0.3",
|
|
9
|
+
"@zk-tech/rrt-core": "0.0.3"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@rspack/core": ">=0.5.0"
|