Merge pull request #422 from alibaba/refactor/typescript-6
refactor: upgrade to TypeScript 6 with source-first monorepo resolution
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -25,6 +25,9 @@ dist-ssr
|
|||||||
*.sw?
|
*.sw?
|
||||||
.qoder
|
.qoder
|
||||||
|
|
||||||
|
# publish backup
|
||||||
|
package.json.bak
|
||||||
|
|
||||||
# env files
|
# env files
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Internal packages:
|
|||||||
npm start # Start website dev server
|
npm start # Start website dev server
|
||||||
npm run build # Build all packages
|
npm run build # Build all packages
|
||||||
npm run build:libs # Build all libraries
|
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
|
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",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^16.4.0",
|
"lint-staged": "^16.4.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.8.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^6.0.2",
|
||||||
"typescript-eslint": "^8.58.1",
|
"typescript-eslint": "^8.58.1",
|
||||||
"unplugin-dts": "^1.0.0-beta.6",
|
"unplugin-dts": "^1.0.0-beta.6",
|
||||||
"vite": "^7.3.2",
|
"vite": "^7.3.2",
|
||||||
@@ -11349,9 +11349,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.9.3",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz",
|
||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -33,8 +33,10 @@
|
|||||||
"build:website": "npm run build:website --workspace=@page-agent/website",
|
"build:website": "npm run build:website --workspace=@page-agent/website",
|
||||||
"build:ext": "npm run build:libs && npm run zip -w @page-agent/ext",
|
"build:ext": "npm run build:libs && npm run zip -w @page-agent/ext",
|
||||||
"version": "node scripts/sync-version.js",
|
"version": "node scripts/sync-version.js",
|
||||||
|
"postpublish": "npm run postpublish --workspaces --if-present",
|
||||||
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json && tsc --noEmit -p packages/extension/tsconfig.json",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"cleanup": "rm -rf packages/*/dist",
|
"cleanup": "rm -rf packages/*/dist && rm -rf packages/*/.output",
|
||||||
"prepare": "husky || true"
|
"prepare": "husky || true"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^16.4.0",
|
"lint-staged": "^16.4.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.8.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^6.0.2",
|
||||||
"typescript-eslint": "^8.58.1",
|
"typescript-eslint": "^8.58.1",
|
||||||
"unplugin-dts": "^1.0.0-beta.6",
|
"unplugin-dts": "^1.0.0-beta.6",
|
||||||
"vite": "^7.3.2",
|
"vite": "^7.3.2",
|
||||||
@@ -63,7 +65,7 @@
|
|||||||
"vite-plugin-css-injected-by-js": "^4.0.1"
|
"vite-plugin-css-injected-by-js": "^4.0.1"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^6.0.2",
|
||||||
"@vitejs/plugin-react": "^5.2.0"
|
"@vitejs/plugin-react": "^5.2.0"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|||||||
@@ -3,6 +3,15 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "./src/PageAgentCore.ts",
|
||||||
|
"types": "./src/PageAgentCore.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/PageAgentCore.ts",
|
||||||
|
"default": "./src/PageAgentCore.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
"main": "./dist/esm/page-agent-core.js",
|
"main": "./dist/esm/page-agent-core.js",
|
||||||
"module": "./dist/esm/page-agent-core.js",
|
"module": "./dist/esm/page-agent-core.js",
|
||||||
"types": "./dist/esm/PageAgentCore.d.ts",
|
"types": "./dist/esm/PageAgentCore.d.ts",
|
||||||
@@ -12,6 +21,7 @@
|
|||||||
"import": "./dist/esm/page-agent-core.js",
|
"import": "./dist/esm/page-agent-core.js",
|
||||||
"default": "./dist/esm/page-agent-core.js"
|
"default": "./dist/esm/page-agent-core.js"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
@@ -39,8 +49,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"dev:iife": "concurrently \"vite build --config vite.iife.config.js --watch\" \"npx serve dist/iife -p 5174\"",
|
"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))\"",
|
"prepublishOnly": "node ../../scripts/pre-publish.js",
|
||||||
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node ../../scripts/post-publish.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.6.2",
|
"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",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"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"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["dist", "node_modules"],
|
"exclude": ["dist", "node_modules"]
|
||||||
"references": [
|
|
||||||
//
|
|
||||||
{ "path": "../llms" },
|
|
||||||
{ "path": "../page-controller" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,15 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
dts({
|
||||||
|
bundleTypes: true,
|
||||||
|
compilerOptions: {
|
||||||
|
composite: true,
|
||||||
|
noEmit: false,
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
declaration: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||||
],
|
],
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class TabsController {
|
|||||||
currentTabId: number | null = null
|
currentTabId: number | null = null
|
||||||
|
|
||||||
private disposed = false
|
private disposed = false
|
||||||
private port: chrome.runtime.Port | null = null
|
private port?: chrome.runtime.Port
|
||||||
private portRetries = 0
|
private portRetries = 0
|
||||||
|
|
||||||
private windowId: number | null = null
|
private windowId: number | null = null
|
||||||
@@ -44,7 +44,7 @@ export class TabsController {
|
|||||||
|
|
||||||
this.currentTabId = null
|
this.currentTabId = null
|
||||||
this.disposed = false
|
this.disposed = false
|
||||||
this.port = null
|
this.port = undefined
|
||||||
this.portRetries = 0
|
this.portRetries = 0
|
||||||
|
|
||||||
this.windowId = null
|
this.windowId = null
|
||||||
@@ -338,7 +338,7 @@ export class TabsController {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.port.onDisconnect.addListener(() => {
|
this.port.onDisconnect.addListener(() => {
|
||||||
this.port = null
|
this.port = undefined
|
||||||
if (this.disposed) return
|
if (this.disposed) return
|
||||||
if (this.portRetries >= 7) {
|
if (this.portRetries >= 7) {
|
||||||
console.error(PREFIX, 'tab events port failed after 7 retries, giving up')
|
console.error(PREFIX, 'tab events port failed after 7 retries, giving up')
|
||||||
@@ -354,7 +354,7 @@ export class TabsController {
|
|||||||
debug('dispose')
|
debug('dispose')
|
||||||
this.disposed = true
|
this.disposed = true
|
||||||
this.port?.disconnect()
|
this.port?.disconnect()
|
||||||
this.port = null
|
this.port = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,26 +3,11 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"noEmit": false,
|
|
||||||
"allowImportingTsExtensions": false,
|
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"baseUrl": ".",
|
"types": ["node", "chrome"],
|
||||||
"paths": {
|
"paths": {
|
||||||
// Self root
|
"@/*": ["./src/*"]
|
||||||
"@/*": ["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"]
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"references": [
|
|
||||||
//
|
|
||||||
{ "path": "../llms" },
|
|
||||||
{ "path": "../page-controller" },
|
|
||||||
{ "path": "../core" },
|
|
||||||
{ "path": "../ui" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
"name": "@page-agent/llms",
|
"name": "@page-agent/llms",
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "./src/index.ts",
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"default": "./src/index.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
"main": "./dist/lib/page-agent-llms.js",
|
"main": "./dist/lib/page-agent-llms.js",
|
||||||
"module": "./dist/lib/page-agent-llms.js",
|
"module": "./dist/lib/page-agent-llms.js",
|
||||||
"types": "./dist/lib/index.d.ts",
|
"types": "./dist/lib/index.d.ts",
|
||||||
@@ -11,6 +20,7 @@
|
|||||||
"import": "./dist/lib/page-agent-llms.js",
|
"import": "./dist/lib/page-agent-llms.js",
|
||||||
"default": "./dist/lib/page-agent-llms.js"
|
"default": "./dist/lib/page-agent-llms.js"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
@@ -33,8 +43,8 @@
|
|||||||
"homepage": "https://alibaba.github.io/page-agent/",
|
"homepage": "https://alibaba.github.io/page-agent/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
"prepublishOnly": "node ../../scripts/pre-publish.js",
|
||||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node ../../scripts/post-publish.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.6.2"
|
"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",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||||
"noEmit": false,
|
|
||||||
"allowImportingTsExtensions": false,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist"
|
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"],
|
"include": ["**/*.ts"],
|
||||||
"exclude": ["dist", "node_modules"]
|
"exclude": ["dist", "node_modules"]
|
||||||
|
|||||||
@@ -11,7 +11,17 @@ console.log(chalk.cyan(`📦 Building @page-agent/llms`))
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
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,
|
publicDir: false,
|
||||||
esbuild: {
|
esbuild: {
|
||||||
keepNames: true,
|
keepNames: true,
|
||||||
|
|||||||
@@ -3,6 +3,15 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "./src/PageAgent.ts",
|
||||||
|
"types": "./src/PageAgent.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/PageAgent.ts",
|
||||||
|
"default": "./src/PageAgent.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
"main": "./dist/esm/page-agent.js",
|
"main": "./dist/esm/page-agent.js",
|
||||||
"module": "./dist/esm/page-agent.js",
|
"module": "./dist/esm/page-agent.js",
|
||||||
"types": "./dist/esm/PageAgent.d.ts",
|
"types": "./dist/esm/PageAgent.d.ts",
|
||||||
@@ -12,6 +21,7 @@
|
|||||||
"import": "./dist/esm/page-agent.js",
|
"import": "./dist/esm/page-agent.js",
|
||||||
"default": "./dist/esm/page-agent.js"
|
"default": "./dist/esm/page-agent.js"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
@@ -40,8 +50,8 @@
|
|||||||
"build": "vite build && npm run build:demo",
|
"build": "vite build && npm run build:demo",
|
||||||
"build:demo": "vite build --config vite.iife.config.js",
|
"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\"",
|
"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))\"",
|
"prepublishOnly": "node ../../scripts/pre-publish.js",
|
||||||
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node ../../scripts/post-publish.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@page-agent/core": "1.7.1",
|
"@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",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"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"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["dist", "node_modules"],
|
"exclude": ["dist", "node_modules"]
|
||||||
"references": [
|
|
||||||
//
|
|
||||||
{ "path": "../llms" },
|
|
||||||
{ "path": "../page-controller" },
|
|
||||||
{ "path": "../core" },
|
|
||||||
{ "path": "../ui" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,15 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
dts({
|
||||||
|
bundleTypes: true,
|
||||||
|
compilerOptions: {
|
||||||
|
composite: true,
|
||||||
|
noEmit: false,
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
declaration: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||||
],
|
],
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
|
|||||||
@@ -24,14 +24,7 @@ export default defineConfig(() => ({
|
|||||||
esbuild: {
|
esbuild: {
|
||||||
keepNames: true,
|
keepNames: true,
|
||||||
},
|
},
|
||||||
resolve: {
|
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'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
build: {
|
build: {
|
||||||
lib: {
|
lib: {
|
||||||
entry: resolve(__dirname, 'src/demo.ts'),
|
entry: resolve(__dirname, 'src/demo.ts'),
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
"name": "@page-agent/page-controller",
|
"name": "@page-agent/page-controller",
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "./src/PageController.ts",
|
||||||
|
"types": "./src/PageController.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/PageController.ts",
|
||||||
|
"default": "./src/PageController.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
"main": "./dist/lib/page-controller.js",
|
"main": "./dist/lib/page-controller.js",
|
||||||
"module": "./dist/lib/page-controller.js",
|
"module": "./dist/lib/page-controller.js",
|
||||||
"types": "./dist/lib/PageController.d.ts",
|
"types": "./dist/lib/PageController.d.ts",
|
||||||
@@ -11,6 +20,7 @@
|
|||||||
"import": "./dist/lib/page-controller.js",
|
"import": "./dist/lib/page-controller.js",
|
||||||
"default": "./dist/lib/page-controller.js"
|
"default": "./dist/lib/page-controller.js"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
@@ -32,8 +42,8 @@
|
|||||||
"homepage": "https://alibaba.github.io/page-agent/",
|
"homepage": "https://alibaba.github.io/page-agent/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
"prepublishOnly": "node ../../scripts/pre-publish.js",
|
||||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node ../../scripts/post-publish.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ai-motion": "^0.4.8"
|
"ai-motion": "^0.4.8"
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export class PageController extends EventTarget {
|
|||||||
|
|
||||||
const blacklist = [
|
const blacklist = [
|
||||||
...(this.config.interactiveBlacklist || []),
|
...(this.config.interactiveBlacklist || []),
|
||||||
...document.querySelectorAll('[data-page-agent-not-interactive]').values(),
|
...Array.from(document.querySelectorAll('[data-page-agent-not-interactive]')),
|
||||||
]
|
]
|
||||||
|
|
||||||
this.flatTree = dom.getFlatTree({
|
this.flatTree = dom.getFlatTree({
|
||||||
|
|||||||
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",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||||
"noEmit": false,
|
|
||||||
"allowImportingTsExtensions": false,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist"
|
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "**/*.js"],
|
"include": ["**/*.ts", "**/*.js"],
|
||||||
"exclude": ["dist", "node_modules"]
|
"exclude": ["dist", "node_modules"]
|
||||||
|
|||||||
@@ -13,7 +13,15 @@ console.log(chalk.cyan(`📦 Building @page-agent/page-controller`))
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
dts({
|
||||||
|
bundleTypes: true,
|
||||||
|
compilerOptions: {
|
||||||
|
composite: true,
|
||||||
|
noEmit: false,
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
declaration: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||||
],
|
],
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
"name": "@page-agent/ui",
|
"name": "@page-agent/ui",
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "./src/index.ts",
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"default": "./src/index.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
"main": "./dist/lib/page-agent-ui.js",
|
"main": "./dist/lib/page-agent-ui.js",
|
||||||
"module": "./dist/lib/page-agent-ui.js",
|
"module": "./dist/lib/page-agent-ui.js",
|
||||||
"types": "./dist/lib/index.d.ts",
|
"types": "./dist/lib/index.d.ts",
|
||||||
@@ -11,6 +20,7 @@
|
|||||||
"import": "./dist/lib/page-agent-ui.js",
|
"import": "./dist/lib/page-agent-ui.js",
|
||||||
"default": "./dist/lib/page-agent-ui.js"
|
"default": "./dist/lib/page-agent-ui.js"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
@@ -32,7 +42,7 @@
|
|||||||
"homepage": "https://alibaba.github.io/page-agent/",
|
"homepage": "https://alibaba.github.io/page-agent/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"prepublishOnly": "node -e \"const fs=require('fs');['LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
"prepublishOnly": "node ../../scripts/pre-publish.js",
|
||||||
"postpublish": "node -e \"['LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node ../../scripts/post-publish.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",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
|
||||||
"noEmit": false,
|
|
||||||
"allowImportingTsExtensions": false,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist"
|
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "**/*.js"],
|
"include": ["**/*.ts", "**/*.js"],
|
||||||
"exclude": ["dist", "node_modules"]
|
"exclude": ["dist", "node_modules"]
|
||||||
|
|||||||
@@ -13,7 +13,15 @@ console.log(chalk.cyan(`📦 Building @page-agent/ui`))
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
dts({ tsconfigPath: './tsconfig.dts.json', bundleTypes: true }),
|
dts({
|
||||||
|
bundleTypes: true,
|
||||||
|
compilerOptions: {
|
||||||
|
composite: true,
|
||||||
|
noEmit: false,
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
declaration: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
||||||
],
|
],
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host 0.0.0.0",
|
"dev": "vite --host 0.0.0.0",
|
||||||
"build:website": "vite build",
|
"build:website": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview"
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@radix-ui/react-icons": "^1.3.2",
|
"@radix-ui/react-icons": "^1.3.2",
|
||||||
|
|||||||
@@ -2,31 +2,10 @@
|
|||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||||
"noEmit": false,
|
|
||||||
"allowImportingTsExtensions": false,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist",
|
|
||||||
"paths": {
|
"paths": {
|
||||||
// Self root
|
"@/*": ["./src/*"]
|
||||||
"@/*": ["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"]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "**/*.tsx"],
|
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||||
"exclude": ["dist", "node_modules"],
|
"exclude": ["dist", "node_modules"]
|
||||||
"references": [
|
|
||||||
//
|
|
||||||
{ "path": "../llms" },
|
|
||||||
{ "path": "../page-controller" },
|
|
||||||
{ "path": "../core" },
|
|
||||||
{ "path": "../ui" },
|
|
||||||
|
|
||||||
{ "path": "../page-agent" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,16 +90,7 @@ export default defineConfig(({ mode }) => ({
|
|||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
// Self root
|
|
||||||
'@': resolve(__dirname, 'src'),
|
'@': 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: {
|
define: {
|
||||||
|
|||||||
30
scripts/post-publish.js
Normal file
30
scripts/post-publish.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Restore package.json from the backup created by pre-publish.js,
|
||||||
|
* then clean up temporary files (backup, LICENSE, README.md).
|
||||||
|
*
|
||||||
|
* Usage: node ../../scripts/post-publish.js (from a package dir)
|
||||||
|
*/
|
||||||
|
import { existsSync, readFileSync, renameSync, rmSync } from 'fs'
|
||||||
|
import { join } from 'path'
|
||||||
|
|
||||||
|
const pkgPath = join(process.cwd(), 'package.json')
|
||||||
|
const bakPath = pkgPath + '.bak'
|
||||||
|
|
||||||
|
if (!existsSync(bakPath)) {
|
||||||
|
console.log(' No backup found, nothing to restore.')
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = JSON.parse(readFileSync(pkgPath, 'utf-8')).name
|
||||||
|
|
||||||
|
renameSync(bakPath, pkgPath)
|
||||||
|
console.log(' ✓ package.json restored from backup')
|
||||||
|
|
||||||
|
rmSync(join(process.cwd(), 'LICENSE'), { force: true })
|
||||||
|
console.log(' ✓ LICENSE removed')
|
||||||
|
|
||||||
|
if (name === 'page-agent') {
|
||||||
|
rmSync(join(process.cwd(), 'README.md'), { force: true })
|
||||||
|
console.log(' ✓ README.md removed')
|
||||||
|
}
|
||||||
42
scripts/pre-publish.js
Normal file
42
scripts/pre-publish.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Backup package.json, then rewrite it for publish:
|
||||||
|
* - Promote `publishConfig` fields to top level
|
||||||
|
* - Remove `publishConfig` (npm doesn't need the wrapper)
|
||||||
|
* - Copy LICENSE (and README.md for the main package)
|
||||||
|
*
|
||||||
|
* Usage: node ../../scripts/pre-publish.js (from a package dir)
|
||||||
|
*/
|
||||||
|
import { copyFileSync, readFileSync, writeFileSync } from 'fs'
|
||||||
|
import { join } from 'path'
|
||||||
|
|
||||||
|
const pkgPath = join(process.cwd(), 'package.json')
|
||||||
|
const raw = readFileSync(pkgPath, 'utf-8')
|
||||||
|
const pkg = JSON.parse(raw)
|
||||||
|
|
||||||
|
const publishConfig = pkg.publishConfig
|
||||||
|
if (!publishConfig) {
|
||||||
|
console.log(' No publishConfig found, skipping manifest rewrite.')
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Backup the original file byte-for-byte
|
||||||
|
copyFileSync(pkgPath, pkgPath + '.bak')
|
||||||
|
console.log(' ✓ package.json backed up')
|
||||||
|
|
||||||
|
for (const [field, value] of Object.entries(publishConfig)) {
|
||||||
|
pkg[field] = value
|
||||||
|
}
|
||||||
|
delete pkg.publishConfig
|
||||||
|
|
||||||
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, ' ') + '\n')
|
||||||
|
console.log(` ✓ Manifest rewritten for publish (${Object.keys(publishConfig).join(', ')})`)
|
||||||
|
|
||||||
|
const root = join(process.cwd(), '../..')
|
||||||
|
copyFileSync(join(root, 'LICENSE'), join(process.cwd(), 'LICENSE'))
|
||||||
|
console.log(' ✓ LICENSE copied')
|
||||||
|
|
||||||
|
if (pkg.name === 'page-agent') {
|
||||||
|
copyFileSync(join(root, 'README.md'), join(process.cwd(), 'README.md'))
|
||||||
|
console.log(' ✓ README.md copied')
|
||||||
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"target": "ES2024",
|
"target": "ES2024",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
"lib": ["ES2024", "DOM"],
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
|
||||||
// "baseUrl": "src",
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
// "incremental": true,
|
// "incremental": true,
|
||||||
|
|
||||||
@@ -27,6 +24,8 @@
|
|||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"erasableSyntaxOnly": true,
|
"erasableSyntaxOnly": true,
|
||||||
"noFallthroughCasesInSwitch": 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