refactor(setup): upgrade to TypeScript 6 with source-first monorepo resolution
This commit is contained in:
@@ -21,7 +21,7 @@ Internal packages:
|
||||
npm start # Start website dev server
|
||||
npm run build # Build all packages
|
||||
npm run build:libs # Build all libraries
|
||||
npm run lint # ESLint with TypeScript strict rules
|
||||
npm run lint # ESLint
|
||||
npm run zip -w @page-agent/ext # Zip the extension package
|
||||
```
|
||||
|
||||
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -36,7 +36,7 @@
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
"prettier": "^3.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript": "^6.0.2",
|
||||
"typescript-eslint": "^8.58.1",
|
||||
"unplugin-dts": "^1.0.0-beta.6",
|
||||
"vite": "^7.3.2",
|
||||
@@ -11349,9 +11349,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz",
|
||||
"integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
"build:website": "npm run build:website --workspace=@page-agent/website",
|
||||
"build:ext": "npm run build:libs && npm run zip -w @page-agent/ext",
|
||||
"version": "node scripts/sync-version.js",
|
||||
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json && tsc --noEmit -p packages/extension/tsconfig.json",
|
||||
"lint": "eslint .",
|
||||
"cleanup": "rm -rf packages/*/dist",
|
||||
"cleanup": "rm -rf packages/*/dist && rm -rf packages/*/.output",
|
||||
"prepare": "husky || true"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -55,7 +56,7 @@
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
"prettier": "^3.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript": "^6.0.2",
|
||||
"typescript-eslint": "^8.58.1",
|
||||
"unplugin-dts": "^1.0.0-beta.6",
|
||||
"vite": "^7.3.2",
|
||||
@@ -63,7 +64,7 @@
|
||||
"vite-plugin-css-injected-by-js": "^4.0.1"
|
||||
},
|
||||
"overrides": {
|
||||
"typescript": "^5.9.3",
|
||||
"typescript": "^6.0.2",
|
||||
"@vitejs/plugin-react": "^5.2.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
@@ -3,14 +3,24 @@
|
||||
"private": false,
|
||||
"version": "1.7.1",
|
||||
"type": "module",
|
||||
"main": "./dist/esm/page-agent-core.js",
|
||||
"module": "./dist/esm/page-agent-core.js",
|
||||
"types": "./dist/esm/PageAgentCore.d.ts",
|
||||
"main": "./src/PageAgentCore.ts",
|
||||
"types": "./src/PageAgentCore.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/esm/PageAgentCore.d.ts",
|
||||
"import": "./dist/esm/page-agent-core.js",
|
||||
"default": "./dist/esm/page-agent-core.js"
|
||||
"types": "./src/PageAgentCore.ts",
|
||||
"default": "./src/PageAgentCore.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"main": "./dist/esm/page-agent-core.js",
|
||||
"module": "./dist/esm/page-agent-core.js",
|
||||
"types": "./dist/esm/PageAgentCore.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/esm/PageAgentCore.d.ts",
|
||||
"import": "./dist/esm/page-agent-core.js",
|
||||
"default": "./dist/esm/page-agent-core.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -39,8 +49,8 @@
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev:iife": "concurrently \"vite build --config vite.iife.config.js --watch\" \"npx serve dist/iife -p 5174\"",
|
||||
"prepublishOnly": "node -e \"const fs=require('fs');['README.md','LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||
"prepublishOnly": "node ../../scripts/prepare-publish.js",
|
||||
"postpublish": "node ../../scripts/restore-dev.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^5.6.2",
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// @workaround DTS bug
|
||||
// dts do not work with monorepo path mapping
|
||||
// disable path mapping for it
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"paths": {
|
||||
//
|
||||
"@page-agent/llms": ["../llms/src/index.ts"],
|
||||
"@page-agent/page-controller": ["../page-controller/src/PageController.ts"]
|
||||
}
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["dist", "node_modules"],
|
||||
"references": [
|
||||
//
|
||||
{ "path": "../llms" },
|
||||
{ "path": "../page-controller" }
|
||||
]
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,15 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
export default defineConfig({
|
||||
clearScreen: false,
|
||||
plugins: [
|
||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
||||
dts({
|
||||
bundleTypes: true,
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: true,
|
||||
declaration: true,
|
||||
},
|
||||
}),
|
||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||
],
|
||||
publicDir: false,
|
||||
|
||||
@@ -24,7 +24,7 @@ export class TabsController {
|
||||
currentTabId: number | null = null
|
||||
|
||||
private disposed = false
|
||||
private port: chrome.runtime.Port | null = null
|
||||
private port?: chrome.runtime.Port
|
||||
private portRetries = 0
|
||||
|
||||
private windowId: number | null = null
|
||||
@@ -44,7 +44,7 @@ export class TabsController {
|
||||
|
||||
this.currentTabId = null
|
||||
this.disposed = false
|
||||
this.port = null
|
||||
this.port = undefined
|
||||
this.portRetries = 0
|
||||
|
||||
this.windowId = null
|
||||
@@ -338,7 +338,7 @@ export class TabsController {
|
||||
})
|
||||
|
||||
this.port.onDisconnect.addListener(() => {
|
||||
this.port = null
|
||||
this.port = undefined
|
||||
if (this.disposed) return
|
||||
if (this.portRetries >= 7) {
|
||||
console.error(PREFIX, 'tab events port failed after 7 retries, giving up')
|
||||
@@ -354,7 +354,7 @@ export class TabsController {
|
||||
debug('dispose')
|
||||
this.disposed = true
|
||||
this.port?.disconnect()
|
||||
this.port = null
|
||||
this.port = undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,26 +3,11 @@
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"useDefineForClassFields": true,
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"strictNullChecks": true,
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": ".",
|
||||
"types": ["node", "chrome"],
|
||||
"paths": {
|
||||
// Self root
|
||||
"@/*": ["src/*"],
|
||||
|
||||
"@page-agent/llms": ["../llms/src/index.ts"],
|
||||
"@page-agent/page-controller": ["../page-controller/src/PageController.ts"],
|
||||
"@page-agent/core": ["../core/src/PageAgentCore.ts"],
|
||||
"@page-agent/ui": ["../ui/src/index.ts"]
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"references": [
|
||||
//
|
||||
{ "path": "../llms" },
|
||||
{ "path": "../page-controller" },
|
||||
{ "path": "../core" },
|
||||
{ "path": "../ui" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,24 @@
|
||||
"name": "@page-agent/llms",
|
||||
"version": "1.7.1",
|
||||
"type": "module",
|
||||
"main": "./dist/lib/page-agent-llms.js",
|
||||
"module": "./dist/lib/page-agent-llms.js",
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"import": "./dist/lib/page-agent-llms.js",
|
||||
"default": "./dist/lib/page-agent-llms.js"
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"main": "./dist/lib/page-agent-llms.js",
|
||||
"module": "./dist/lib/page-agent-llms.js",
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"import": "./dist/lib/page-agent-llms.js",
|
||||
"default": "./dist/lib/page-agent-llms.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -33,8 +43,8 @@
|
||||
"homepage": "https://alibaba.github.io/page-agent/",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||
"prepublishOnly": "node ../../scripts/prepare-publish.js",
|
||||
"postpublish": "node ../../scripts/restore-dev.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^5.6.2"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// @workaround DTS bug
|
||||
// dts do not work with monorepo path mapping
|
||||
// disable path mapping for it
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist"
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
|
||||
@@ -11,7 +11,17 @@ console.log(chalk.cyan(`📦 Building @page-agent/llms`))
|
||||
|
||||
export default defineConfig({
|
||||
clearScreen: false,
|
||||
plugins: [dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true })],
|
||||
plugins: [
|
||||
dts({
|
||||
bundleTypes: true,
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: true,
|
||||
declaration: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
publicDir: false,
|
||||
esbuild: {
|
||||
keepNames: true,
|
||||
|
||||
@@ -3,14 +3,24 @@
|
||||
"private": false,
|
||||
"version": "1.7.1",
|
||||
"type": "module",
|
||||
"main": "./dist/esm/page-agent.js",
|
||||
"module": "./dist/esm/page-agent.js",
|
||||
"types": "./dist/esm/PageAgent.d.ts",
|
||||
"main": "./src/PageAgent.ts",
|
||||
"types": "./src/PageAgent.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/esm/PageAgent.d.ts",
|
||||
"import": "./dist/esm/page-agent.js",
|
||||
"default": "./dist/esm/page-agent.js"
|
||||
"types": "./src/PageAgent.ts",
|
||||
"default": "./src/PageAgent.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"main": "./dist/esm/page-agent.js",
|
||||
"module": "./dist/esm/page-agent.js",
|
||||
"types": "./dist/esm/PageAgent.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/esm/PageAgent.d.ts",
|
||||
"import": "./dist/esm/page-agent.js",
|
||||
"default": "./dist/esm/page-agent.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -40,8 +50,8 @@
|
||||
"build": "vite build && npm run build:demo",
|
||||
"build:demo": "vite build --config vite.iife.config.js",
|
||||
"dev:demo": "concurrently \"vite build --config vite.iife.config.js --watch\" \"npx serve dist/iife -p 5174\"",
|
||||
"prepublishOnly": "node -e \"const fs=require('fs');['README.md','LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||
"prepublishOnly": "node ../../scripts/prepare-publish.js",
|
||||
"postpublish": "node ../../scripts/restore-dev.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@page-agent/core": "1.7.1",
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// @workaround DTS bug
|
||||
// dts do not work with monorepo path mapping
|
||||
// disable path mapping for it
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"paths": {
|
||||
//
|
||||
"@page-agent/llms": ["../llms/src/index.ts"],
|
||||
"@page-agent/page-controller": ["../page-controller/src/PageController.ts"],
|
||||
"@page-agent/core": ["../core/src/PageAgentCore.ts"],
|
||||
"@page-agent/ui": ["../ui/src/index.ts"]
|
||||
}
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["dist", "node_modules"],
|
||||
"references": [
|
||||
//
|
||||
{ "path": "../llms" },
|
||||
{ "path": "../page-controller" },
|
||||
{ "path": "../core" },
|
||||
{ "path": "../ui" }
|
||||
]
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,15 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
export default defineConfig({
|
||||
clearScreen: false,
|
||||
plugins: [
|
||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
||||
dts({
|
||||
bundleTypes: true,
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: true,
|
||||
declaration: true,
|
||||
},
|
||||
}),
|
||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||
],
|
||||
publicDir: false,
|
||||
|
||||
@@ -24,14 +24,7 @@ export default defineConfig(() => ({
|
||||
esbuild: {
|
||||
keepNames: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@page-agent/page-controller': resolve(__dirname, '../page-controller/src/PageController.ts'),
|
||||
'@page-agent/llms': resolve(__dirname, '../llms/src/index.ts'),
|
||||
'@page-agent/core': resolve(__dirname, '../core/src/PageAgentCore.ts'),
|
||||
'@page-agent/ui': resolve(__dirname, '../ui/src/index.ts'),
|
||||
},
|
||||
},
|
||||
resolve: {},
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/demo.ts'),
|
||||
|
||||
@@ -2,14 +2,24 @@
|
||||
"name": "@page-agent/page-controller",
|
||||
"version": "1.7.1",
|
||||
"type": "module",
|
||||
"main": "./dist/lib/page-controller.js",
|
||||
"module": "./dist/lib/page-controller.js",
|
||||
"types": "./dist/lib/PageController.d.ts",
|
||||
"main": "./src/PageController.ts",
|
||||
"types": "./src/PageController.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/PageController.d.ts",
|
||||
"import": "./dist/lib/page-controller.js",
|
||||
"default": "./dist/lib/page-controller.js"
|
||||
"types": "./src/PageController.ts",
|
||||
"default": "./src/PageController.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"main": "./dist/lib/page-controller.js",
|
||||
"module": "./dist/lib/page-controller.js",
|
||||
"types": "./dist/lib/PageController.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/PageController.d.ts",
|
||||
"import": "./dist/lib/page-controller.js",
|
||||
"default": "./dist/lib/page-controller.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -32,8 +42,8 @@
|
||||
"homepage": "https://alibaba.github.io/page-agent/",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||
"prepublishOnly": "node ../../scripts/prepare-publish.js",
|
||||
"postpublish": "node ../../scripts/restore-dev.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ai-motion": "^0.4.8"
|
||||
|
||||
16
packages/page-controller/src/dom/dom_tree/index.d.ts
vendored
Normal file
16
packages/page-controller/src/dom/dom_tree/index.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { FlatDomTree } from './type'
|
||||
|
||||
interface DomTreeArgs {
|
||||
doHighlightElements?: boolean
|
||||
focusHighlightIndex?: number
|
||||
viewportExpansion?: number
|
||||
debugMode?: boolean
|
||||
interactiveBlacklist?: Element[]
|
||||
interactiveWhitelist?: Element[]
|
||||
highlightOpacity?: number
|
||||
highlightLabelOpacity?: number
|
||||
}
|
||||
|
||||
declare const domTree: (args?: DomTreeArgs) => FlatDomTree
|
||||
|
||||
export default domTree
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// @workaround DTS bug
|
||||
// dts do not work with monorepo path mapping
|
||||
// disable path mapping for it
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist"
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.js"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
|
||||
@@ -13,7 +13,15 @@ console.log(chalk.cyan(`📦 Building @page-agent/page-controller`))
|
||||
export default defineConfig({
|
||||
clearScreen: false,
|
||||
plugins: [
|
||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
||||
dts({
|
||||
bundleTypes: true,
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: true,
|
||||
declaration: true,
|
||||
},
|
||||
}),
|
||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||
],
|
||||
publicDir: false,
|
||||
|
||||
@@ -2,14 +2,24 @@
|
||||
"name": "@page-agent/ui",
|
||||
"version": "1.7.1",
|
||||
"type": "module",
|
||||
"main": "./dist/lib/page-agent-ui.js",
|
||||
"module": "./dist/lib/page-agent-ui.js",
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"import": "./dist/lib/page-agent-ui.js",
|
||||
"default": "./dist/lib/page-agent-ui.js"
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"main": "./dist/lib/page-agent-ui.js",
|
||||
"module": "./dist/lib/page-agent-ui.js",
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lib/index.d.ts",
|
||||
"import": "./dist/lib/page-agent-ui.js",
|
||||
"default": "./dist/lib/page-agent-ui.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -32,7 +42,7 @@
|
||||
"homepage": "https://alibaba.github.io/page-agent/",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||
"prepublishOnly": "node ../../scripts/prepare-publish.js",
|
||||
"postpublish": "node ../../scripts/restore-dev.js"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// @workaround DTS bug
|
||||
// dts do not work with monorepo path mapping
|
||||
// disable path mapping for it
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist"
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.js"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
|
||||
@@ -13,7 +13,15 @@ console.log(chalk.cyan(`📦 Building @page-agent/ui`))
|
||||
export default defineConfig({
|
||||
clearScreen: false,
|
||||
plugins: [
|
||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
||||
dts({
|
||||
bundleTypes: true,
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: true,
|
||||
declaration: true,
|
||||
},
|
||||
}),
|
||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||
],
|
||||
publicDir: false,
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
"scripts": {
|
||||
"dev": "vite --host 0.0.0.0",
|
||||
"build:website": "vite build",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
|
||||
@@ -2,31 +2,10 @@
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"paths": {
|
||||
// Self root
|
||||
"@/*": ["src/*"],
|
||||
|
||||
"@page-agent/llms": ["../llms/src/index.ts"],
|
||||
"@page-agent/page-controller": ["../page-controller/src/PageController.ts"],
|
||||
"@page-agent/core": ["../core/src/PageAgentCore.ts"],
|
||||
"@page-agent/ui": ["../ui/src/index.ts"],
|
||||
|
||||
"page-agent": ["../page-agent/src/PageAgent.ts"]
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["dist", "node_modules"],
|
||||
"references": [
|
||||
//
|
||||
{ "path": "../llms" },
|
||||
{ "path": "../page-controller" },
|
||||
{ "path": "../core" },
|
||||
{ "path": "../ui" },
|
||||
|
||||
{ "path": "../page-agent" }
|
||||
]
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
|
||||
@@ -90,16 +90,7 @@ export default defineConfig(({ mode }) => ({
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// Self root
|
||||
'@': resolve(__dirname, 'src'),
|
||||
|
||||
// Monorepo packages (always bundle local code instead of npm versions)
|
||||
'@page-agent/page-controller': resolve(__dirname, '../page-controller/src/PageController.ts'),
|
||||
'@page-agent/llms': resolve(__dirname, '../llms/src/index.ts'),
|
||||
'@page-agent/core': resolve(__dirname, '../core/src/PageAgentCore.ts'),
|
||||
'@page-agent/ui': resolve(__dirname, '../ui/src/index.ts'),
|
||||
|
||||
'page-agent': resolve(__dirname, '../page-agent/src/PageAgent.ts'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
|
||||
48
scripts/prepare-publish.js
Normal file
48
scripts/prepare-publish.js
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Swap source-first dev entrypoints for dist-first publish entrypoints.
|
||||
*
|
||||
* This script is called by `prepublishOnly` in each publishable package.
|
||||
* It reads the `publishConfig` object and promotes its fields to top level,
|
||||
* storing the original dev fields in `_devConfig` so `restore-dev.js` can undo it.
|
||||
*
|
||||
* Usage: node ../../scripts/prepare-publish.js
|
||||
*/
|
||||
import { copyFileSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
const pkgPath = join(process.cwd(), 'package.json')
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
||||
|
||||
const publishConfig = pkg.publishConfig
|
||||
if (!publishConfig) {
|
||||
console.log(' No publishConfig found, skipping manifest rewrite.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const PUBLISH_FIELDS = ['main', 'module', 'types', 'exports']
|
||||
|
||||
const devConfig = {}
|
||||
for (const field of PUBLISH_FIELDS) {
|
||||
if (field in publishConfig) {
|
||||
devConfig[field] = pkg[field]
|
||||
pkg[field] = publishConfig[field]
|
||||
}
|
||||
}
|
||||
|
||||
pkg._devConfig = devConfig
|
||||
delete pkg.publishConfig
|
||||
|
||||
writeFileSync(pkgPath, JSON.stringify(pkg, null, ' ') + '\n')
|
||||
console.log(` ✓ Manifest rewritten for publish (${Object.keys(devConfig).join(', ')})`)
|
||||
|
||||
const root = join(process.cwd(), '../..')
|
||||
copyFileSync(join(root, 'LICENSE'), join(process.cwd(), 'LICENSE'))
|
||||
console.log(' ✓ LICENSE copied')
|
||||
|
||||
const readmeSrc = join(root, 'README.md')
|
||||
const readmeDest = join(process.cwd(), 'README.md')
|
||||
if (pkg.name === 'page-agent') {
|
||||
copyFileSync(readmeSrc, readmeDest)
|
||||
console.log(' ✓ README.md copied')
|
||||
}
|
||||
45
scripts/restore-dev.js
Normal file
45
scripts/restore-dev.js
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Restore source-first dev entrypoints after publish.
|
||||
*
|
||||
* Undoes what `prepare-publish.js` did by reading `_devConfig`
|
||||
* and reinstating the original dev fields + `publishConfig`.
|
||||
*
|
||||
* Usage: node ../../scripts/restore-dev.js
|
||||
*/
|
||||
import { readFileSync, rmSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
const pkgPath = join(process.cwd(), 'package.json')
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
||||
|
||||
const devConfig = pkg._devConfig
|
||||
if (!devConfig) {
|
||||
console.log(' No _devConfig found, skipping manifest restore.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const PUBLISH_FIELDS = ['main', 'module', 'types', 'exports']
|
||||
|
||||
const publishConfig = {}
|
||||
for (const field of PUBLISH_FIELDS) {
|
||||
if (field in devConfig) {
|
||||
publishConfig[field] = pkg[field]
|
||||
pkg[field] = devConfig[field]
|
||||
}
|
||||
}
|
||||
|
||||
pkg.publishConfig = publishConfig
|
||||
delete pkg._devConfig
|
||||
|
||||
writeFileSync(pkgPath, JSON.stringify(pkg, null, ' ') + '\n')
|
||||
console.log(` ✓ Manifest restored for dev (${Object.keys(publishConfig).join(', ')})`)
|
||||
|
||||
const licensePath = join(process.cwd(), 'LICENSE')
|
||||
rmSync(licensePath, { force: true })
|
||||
console.log(' ✓ LICENSE removed')
|
||||
|
||||
if (pkg.name === 'page-agent') {
|
||||
rmSync(join(process.cwd(), 'README.md'), { force: true })
|
||||
console.log(' ✓ README.md removed')
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"target": "ES2024",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
||||
"lib": ["ES2024", "DOM"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"allowJs": true,
|
||||
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||
// "baseUrl": "src",
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
// "incremental": true,
|
||||
|
||||
@@ -27,6 +24,8 @@
|
||||
"noUnusedParameters": false,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
"noUncheckedSideEffectImports": true,
|
||||
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// this is only for IDE ts language server to work.
|
||||
// do not use this for building or linting.
|
||||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"references": [
|
||||
{ "path": "./packages/page-controller" },
|
||||
{ "path": "./packages/ui" },
|
||||
{ "path": "./packages/llms" },
|
||||
{ "path": "./packages/page-agent" },
|
||||
{ "path": "./packages/website" }
|
||||
],
|
||||
"include": ["packages/*/src/**/*.ts", "packages/*/src/**/*.tsx"],
|
||||
"exclude": ["node_modules", "dist", "packages/*/dist"]
|
||||
}
|
||||
25
tsconfig.typecheck.json
Normal file
25
tsconfig.typecheck.json
Normal file
@@ -0,0 +1,25 @@
|
||||
// Unified typecheck config for all lib/website packages.
|
||||
// Run: tsc --noEmit -p tsconfig.typecheck.json
|
||||
// Extension is checked separately (WXT has its own tsconfig base).
|
||||
//
|
||||
// With source-first package.json exports, TS resolves @page-agent/*
|
||||
// to sibling src/ via workspace symlinks — no paths mapping needed.
|
||||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": false,
|
||||
"noEmit": true,
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.typecheck.tsbuildinfo",
|
||||
"paths": {
|
||||
"@/*": ["./packages/website/src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"packages/llms/src/**/*",
|
||||
"packages/page-controller/src/**/*",
|
||||
"packages/ui/src/**/*",
|
||||
"packages/core/src/**/*",
|
||||
"packages/page-agent/src/**/*",
|
||||
"packages/website/src/**/*"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user