diff --git a/index.html b/index.html index b3e7569..222565e 100644 --- a/index.html +++ b/index.html @@ -1,153 +1,158 @@ + - - <%= VITE_GLOB_APP_TITLE %> + + + <%= VITE_GLOB_APP_TITLE %> + + -
- -
-
- -
- + + .app-loading .dots { + display: flex; + align-items: center; + justify-content: center; + padding: 98px; + } + + .app-loading .app-loading-title { + display: flex; + align-items: center; + justify-content: center; + margin-top: 30px; + color: rgb(0 0 0 / 85%); + font-size: 30px; + } + + .app-loading .app-loading-logo { + display: block; + width: 200px; + margin: 0 auto; + margin-bottom: 20px; + } + + .dot { + display: inline-block; + position: relative; + box-sizing: border-box; + width: 48px; + height: 48px; + margin-top: 30px; + transform: rotate(45deg); + animation: ant-rotate 1.2s infinite linear; + font-size: 32px; + } + + .dot i { + display: block; + position: absolute; + width: 20px; + height: 20px; + transform: scale(0.75); + transform-origin: 50% 50%; + animation: ant-spin-move 1s infinite linear alternate; + border-radius: 100%; + opacity: 0.3; + background-color: #0065cc; + } + + .dot i:nth-child(1) { + top: 0; + left: 0; + } + + .dot i:nth-child(2) { + top: 0; + right: 0; + animation-delay: 0.4s; + } + + .dot i:nth-child(3) { + right: 0; + bottom: 0; + animation-delay: 0.8s; + } + + .dot i:nth-child(4) { + bottom: 0; + left: 0; + animation-delay: 1.2s; + } + + @keyframes ant-rotate { + to { + transform: rotate(405deg); + } + } + + @keyframes ant-rotate { + to { + transform: rotate(405deg); + } + } + + @keyframes ant-spin-move { + to { + opacity: 1; + } + } + + @keyframes ant-spin-move { + to { + opacity: 1; + } + } + +
+
+ +
+ +
+
-
<%= VITE_GLOB_APP_TITLE %>
-
- + + \ No newline at end of file diff --git a/internal/stylelint-config/package-lock.json b/internal/stylelint-config/package-lock.json new file mode 100644 index 0000000..3ce3c22 --- /dev/null +++ b/internal/stylelint-config/package-lock.json @@ -0,0 +1,539 @@ +{ + "name": "@vben/stylelint-config", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@vben/stylelint-config", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "postcss": "^8.4.38", + "postcss-html": "^1.6.0", + "postcss-less": "^6.0.0", + "postcss-scss": "^4.0.9", + "prettier": "^3.2.5", + "stylelint": "^16.4.0", + "stylelint-config-property-sort-order-smacss": "^10.0.0", + "stylelint-config-recommended-scss": "^14.0.0", + "stylelint-config-recommended-vue": "^1.5.0", + "stylelint-config-standard": "^36.0.0", + "stylelint-config-standard-scss": "^13.1.0", + "stylelint-order": "^6.0.4", + "stylelint-prettier": "^5.0.0" + } + }, + "../../node_modules/.pnpm/postcss-html@1.6.0/node_modules/postcss-html": { + "version": "1.6.0", + "dev": true, + "license": "MIT", + "dependencies": { + "htmlparser2": "^8.0.0", + "js-tokens": "^8.0.0", + "postcss": "^8.4.0", + "postcss-safe-parser": "^6.0.0" + }, + "devDependencies": { + "@ota-meshi/eslint-plugin": "^0.15.0", + "autoprefixer": "^10.3.7", + "chai": "~4.3.4", + "codecov": "^3.8.3", + "eslint": "^8.0.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-json-schema-validator": "^4.0.0", + "eslint-plugin-jsonc": "^2.0.0", + "eslint-plugin-n": "^16.6.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-node-dependencies": "^0.11.0", + "eslint-plugin-prettier": "^5.0.0", + "eslint-plugin-regexp": "^1.4.1", + "eslint-plugin-vue": "^9.0.0", + "eslint-plugin-yml": "^1.0.0", + "mocha": "^10.0.0", + "mocha-chai-jest-snapshot": "^1.1.3", + "nyc": "^15.1.0", + "postcss-less": "^6.0.0", + "postcss-scss": "^4.0.1", + "postcss-styl": "^0.12.0", + "prettier": "^3.0.0", + "stylelint": "^14.4.0", + "stylelint-config-standard": "^28.0.0", + "sugarss": "^4.0.1" + }, + "engines": { + "node": "^12 || >=14" + } + }, + "../../node_modules/.pnpm/postcss-less@6.0.0_postcss@8.4.38/node_modules/postcss-less": { + "version": "6.0.0", + "dev": true, + "license": "MIT", + "devDependencies": { + "@commitlint/cli": "^12.1.4", + "@commitlint/config-conventional": "^12.1.4", + "ava": "^3.15.0", + "cheerio": "^1.0.0-rc.10", + "eslint-config-shellscape": "^2.0.2", + "eslint-plugin-filenames": "^1.2.0", + "is-absolute-url": "^3.0.0", + "less": "^4.1.1", + "lint-staged": "^11.0.0", + "node-fetch": "^2.6.1", + "nyc": "^15.1.0", + "postcss": "^8.3.5", + "postcss-parser-tests": "^8.3.5", + "pre-commit": "^1.2.2", + "url-join": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "postcss": "^8.3.5" + } + }, + "../../node_modules/.pnpm/postcss-scss@4.0.9_postcss@8.4.38/node_modules/postcss-scss": { + "version": "4.0.9", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss-scss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.4.29" + } + }, + "../../node_modules/.pnpm/postcss@8.4.38/node_modules/postcss": { + "version": "8.4.38", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "../../node_modules/.pnpm/prettier@3.2.5/node_modules/prettier": { + "version": "3.2.5", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "../../node_modules/.pnpm/stylelint-config-property-sort-order-smacss@10.0.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-property-sort-order-smacss": { + "version": "10.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "css-property-sort-order-smacss": "~2.2.0", + "stylelint-order": "^6.0.4" + }, + "devDependencies": { + "coveralls": "^3.1.0", + "eslint": "^8.2.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.25.2", + "jest": "^29.0.1", + "jest-light-runner": "^0.6.0", + "prettier": "^3.0.0", + "proxyquire": "^2.0.0", + "stylelint": "^14.0.0 || ^15.0.0 || ^16.0.0" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "stylelint": "^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "../../node_modules/.pnpm/stylelint-config-recommended-scss@14.0.0_postcss@8.4.38_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-recommended-scss": { + "version": "14.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-scss": "^4.0.9", + "stylelint-config-recommended": "^14.0.0", + "stylelint-scss": "^6.0.0" + }, + "devDependencies": { + "@stylelint/prettier-config": "^3.0.0", + "@stylelint/remark-preset": "^5.0.0", + "cross-env": "^7.0.3", + "eslint": "^8.55.0", + "eslint-config-stylelint": "^20.0.0", + "eslint-plugin-jest": "^27.6.0", + "jest": "^29.7.0", + "np": "^9.0.0", + "npm-run-all2": "^5.0.2", + "prettier": "^3.1.0", + "remark-cli": "^12.0.0", + "stylelint": "^16.0.2" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "postcss": "^8.3.3", + "stylelint": "^16.0.2" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + } + } + }, + "../../node_modules/.pnpm/stylelint-config-recommended-vue@1.5.0_postcss-html@1.6.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-recommended-vue": { + "version": "1.5.0", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.3.5", + "stylelint-config-html": ">=1.0.0", + "stylelint-config-recommended": ">=6.0.0" + }, + "devDependencies": { + "@ota-meshi/eslint-plugin": "^0.13.0", + "eslint": "^8.0.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-json-schema-validator": "^4.0.0", + "eslint-plugin-jsonc": "^2.0.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-regexp": "^1.5.0", + "eslint-plugin-vue": "^9.0.0", + "eslint-plugin-yml": "^1.0.0", + "mocha": "^10.0.0", + "prettier": "^2.4.1", + "stylelint": "^15.0.0" + }, + "engines": { + "node": "^12 || >=14" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "postcss-html": "^1.0.0", + "stylelint": ">=14.0.0" + } + }, + "../../node_modules/.pnpm/stylelint-config-standard-scss@13.1.0_postcss@8.4.38_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-standard-scss": { + "version": "13.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "stylelint-config-recommended-scss": "^14.0.0", + "stylelint-config-standard": "^36.0.0" + }, + "devDependencies": { + "@stylelint/prettier-config": "^3.0.0", + "@stylelint/remark-preset": "^5.0.0", + "eslint": "^8.57.0", + "eslint-config-stylelint": "^21.0.0", + "np": "^10.0.2", + "npm-run-all2": "^5.0.2", + "prettier": "^3.2.5", + "remark-cli": "^12.0.0", + "stylelint": "^16.3.1" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "postcss": "^8.3.3", + "stylelint": "^16.3.1" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + } + } + }, + "../../node_modules/.pnpm/stylelint-config-standard@36.0.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-standard": { + "version": "36.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "stylelint-config-recommended": "^14.0.0" + }, + "devDependencies": { + "@stylelint/prettier-config": "^3.0.0", + "@stylelint/remark-preset": "^5.0.0", + "eslint": "^8.56.0", + "eslint-config-stylelint": "^20.0.0", + "husky": "^8.0.3", + "lint-staged": "^15.2.0", + "np": "^9.2.0", + "npm-run-all": "^4.1.5", + "prettier": "^3.1.1", + "remark-cli": "^12.0.0", + "stylelint": "^16.1.0" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "stylelint": "^16.1.0" + } + }, + "../../node_modules/.pnpm/stylelint-order@6.0.4_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-order": { + "version": "6.0.4", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss": "^8.4.32", + "postcss-sorting": "^8.0.2" + }, + "devDependencies": { + "eslint": "^8.55.0", + "eslint-config-hudochenkov": "^9.0.0", + "eslint-config-prettier": "^9.1.0", + "husky": "^8.0.3", + "jest": "^29.7.0", + "jest-light-runner": "^0.6.0", + "jest-preset-stylelint": "^7.0.0", + "jest-watch-typeahead": "^2.2.2", + "lint-staged": "^15.2.0", + "postcss-html": "^1.5.0", + "postcss-less": "^6.0.0", + "postcss-styled-syntax": "^0.5.0", + "prettier": "~3.1.0", + "prettier-config-hudochenkov": "^0.4.0", + "stylelint": "^16.0.1" + }, + "peerDependencies": { + "stylelint": "^14.0.0 || ^15.0.0 || ^16.0.1" + } + }, + "../../node_modules/.pnpm/stylelint-prettier@5.0.0_prettier@3.2.5_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-prettier": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.0" + }, + "devDependencies": { + "eslint": "^8.44.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-n": "^16.3.1", + "eslint-plugin-prettier": "^5.0.0", + "postcss": "^8.4.25", + "postcss-html": "^1.5.0", + "postcss-markdown": "^1.2.0", + "postcss-scss": "^4.0.6", + "postcss-styled-syntax": "^0.5.0", + "postcss-syntax": "^0.36.2", + "prettier": "^3.0.0", + "prettier-plugin-astro": "^0.12.1", + "prettier-plugin-svelte": "^3.0.0", + "strip-ansi": "^7.1.0", + "stylelint": "^16.0.1", + "stylelint-test-rule-node": "^0.2.0", + "svelte": "^4.1.0", + "typescript": "5.3.2" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "prettier": ">=3.0.0", + "stylelint": ">=16.0.0" + } + }, + "../../node_modules/.pnpm/stylelint@16.4.0_typescript@5.4.5/node_modules/stylelint": { + "version": "16.4.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-parser-algorithms": "^2.6.1", + "@csstools/css-tokenizer": "^2.2.4", + "@csstools/media-query-list-parser": "^2.1.9", + "@csstools/selector-specificity": "^3.0.3", + "@dual-bundle/import-meta-resolve": "^4.0.0", + "balanced-match": "^2.0.0", + "colord": "^2.9.3", + "cosmiconfig": "^9.0.0", + "css-functions-list": "^3.2.2", + "css-tree": "^2.3.1", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "fastest-levenshtein": "^1.0.16", + "file-entry-cache": "^8.0.0", + "global-modules": "^2.0.0", + "globby": "^11.1.0", + "globjoin": "^0.1.4", + "html-tags": "^3.3.1", + "ignore": "^5.3.1", + "imurmurhash": "^0.1.4", + "is-plain-object": "^5.0.0", + "known-css-properties": "^0.30.0", + "mathml-tag-names": "^2.1.3", + "meow": "^13.2.0", + "micromatch": "^4.0.5", + "normalize-path": "^3.0.0", + "picocolors": "^1.0.0", + "postcss": "^8.4.38", + "postcss-resolve-nested-selector": "^0.1.1", + "postcss-safe-parser": "^7.0.0", + "postcss-selector-parser": "^6.0.16", + "postcss-value-parser": "^4.2.0", + "resolve-from": "^5.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^7.1.0", + "supports-hyperlinks": "^3.0.0", + "svg-tags": "^1.0.0", + "table": "^6.8.2", + "write-file-atomic": "^5.0.1" + }, + "bin": { + "stylelint": "bin/stylelint.mjs" + }, + "devDependencies": { + "@changesets/cli": "^2.27.1", + "@changesets/get-github-info": "^0.6.0", + "@jest/globals": "^29.7.0", + "@stylelint/prettier-config": "^3.0.0", + "@stylelint/remark-preset": "^5.0.0", + "@types/balanced-match": "^1.0.4", + "@types/css-tree": "^2.3.7", + "@types/debug": "^4.1.12", + "@types/file-entry-cache": "^5.0.4", + "@types/global-modules": "^2.0.2", + "@types/globjoin": "^0.1.2", + "@types/imurmurhash": "^0.1.4", + "@types/micromatch": "^4.0.7", + "@types/normalize-path": "^3.0.2", + "@types/postcss-less": "^4.0.6", + "@types/postcss-resolve-nested-selector": "^0.1.3", + "@types/postcss-safe-parser": "^5.0.4", + "@types/svg-tags": "^1.0.2", + "@types/write-file-atomic": "^4.0.3", + "benchmark": "^2.1.4", + "common-tags": "^1.8.2", + "deepmerge": "^4.3.1", + "eslint": "^8.57.0", + "eslint-config-stylelint": "^21.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^28.2.0", + "husky": "^9.0.11", + "jest": "^29.7.0", + "jest-preset-stylelint": "^7.0.0", + "jest-watch-typeahead": "^2.2.2", + "lint-staged": "^15.2.2", + "np": "^10.0.5", + "npm-run-all": "^4.1.5", + "patch-package": "^8.0.0", + "postcss-html": "^1.6.0", + "postcss-import": "^16.1.0", + "postcss-less": "^6.0.0", + "postcss-sass": "^0.5.0", + "postcss-scss": "^4.0.9", + "remark-cli": "^12.0.0", + "rollup": "^4.16.3", + "sugarss": "^4.0.1", + "typescript": "^5.4.5" + }, + "engines": { + "node": ">=18.12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/stylelint" + } + }, + "node_modules/postcss": { + "resolved": "../../node_modules/.pnpm/postcss@8.4.38/node_modules/postcss", + "link": true + }, + "node_modules/postcss-html": { + "resolved": "../../node_modules/.pnpm/postcss-html@1.6.0/node_modules/postcss-html", + "link": true + }, + "node_modules/postcss-less": { + "resolved": "../../node_modules/.pnpm/postcss-less@6.0.0_postcss@8.4.38/node_modules/postcss-less", + "link": true + }, + "node_modules/postcss-scss": { + "resolved": "../../node_modules/.pnpm/postcss-scss@4.0.9_postcss@8.4.38/node_modules/postcss-scss", + "link": true + }, + "node_modules/prettier": { + "resolved": "../../node_modules/.pnpm/prettier@3.2.5/node_modules/prettier", + "link": true + }, + "node_modules/stylelint": { + "resolved": "../../node_modules/.pnpm/stylelint@16.4.0_typescript@5.4.5/node_modules/stylelint", + "link": true + }, + "node_modules/stylelint-config-property-sort-order-smacss": { + "resolved": "../../node_modules/.pnpm/stylelint-config-property-sort-order-smacss@10.0.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-property-sort-order-smacss", + "link": true + }, + "node_modules/stylelint-config-recommended-scss": { + "resolved": "../../node_modules/.pnpm/stylelint-config-recommended-scss@14.0.0_postcss@8.4.38_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-recommended-scss", + "link": true + }, + "node_modules/stylelint-config-recommended-vue": { + "resolved": "../../node_modules/.pnpm/stylelint-config-recommended-vue@1.5.0_postcss-html@1.6.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-recommended-vue", + "link": true + }, + "node_modules/stylelint-config-standard": { + "resolved": "../../node_modules/.pnpm/stylelint-config-standard@36.0.0_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-standard", + "link": true + }, + "node_modules/stylelint-config-standard-scss": { + "resolved": "../../node_modules/.pnpm/stylelint-config-standard-scss@13.1.0_postcss@8.4.38_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-config-standard-scss", + "link": true + }, + "node_modules/stylelint-order": { + "resolved": "../../node_modules/.pnpm/stylelint-order@6.0.4_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-order", + "link": true + }, + "node_modules/stylelint-prettier": { + "resolved": "../../node_modules/.pnpm/stylelint-prettier@5.0.0_prettier@3.2.5_stylelint@16.4.0_typescript@5.4.5_/node_modules/stylelint-prettier", + "link": true + } + } +} diff --git a/internal/ts-config/package-lock.json b/internal/ts-config/package-lock.json new file mode 100644 index 0000000..8eb7984 --- /dev/null +++ b/internal/ts-config/package-lock.json @@ -0,0 +1,148 @@ +{ + "name": "@vben/ts-config", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@vben/ts-config", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@types/node": "^20.12.7", + "vite": "^5.2.10" + } + }, + "../../node_modules/.pnpm/@types+node@20.12.7/node_modules/@types/node": { + "version": "20.12.7", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "../../node_modules/.pnpm/vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3/node_modules/vite": { + "version": "5.2.10", + "license": "MIT", + "dependencies": { + "esbuild": "^0.20.1", + "postcss": "^8.4.38", + "rollup": "^4.13.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "devDependencies": { + "@ampproject/remapping": "^2.3.0", + "@babel/parser": "^7.24.4", + "@jridgewell/trace-mapping": "^0.3.25", + "@polka/compression": "^1.0.0-next.25", + "@rollup/plugin-alias": "^5.1.0", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-dynamic-import-vars": "^2.1.2", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "15.2.3", + "@rollup/plugin-typescript": "^11.1.6", + "@rollup/pluginutils": "^5.1.0", + "@types/escape-html": "^1.0.4", + "@types/pnpapi": "^0.0.5", + "acorn": "^8.11.3", + "acorn-walk": "^8.3.2", + "artichokie": "^0.2.0", + "cac": "^6.7.14", + "chokidar": "^3.6.0", + "connect": "^3.7.0", + "convert-source-map": "^2.0.0", + "cors": "^2.8.5", + "cross-spawn": "^7.0.3", + "debug": "^4.3.4", + "dep-types": "link:./src/types", + "dotenv": "^16.4.5", + "dotenv-expand": "^11.0.6", + "es-module-lexer": "^1.5.0", + "escape-html": "^1.0.3", + "estree-walker": "^3.0.3", + "etag": "^1.8.1", + "fast-glob": "^3.3.2", + "http-proxy": "^1.18.1", + "launch-editor-middleware": "^2.6.1", + "lightningcss": "^1.24.1", + "magic-string": "^0.30.9", + "micromatch": "^4.0.5", + "mlly": "^1.6.1", + "mrmime": "^2.0.0", + "open": "^8.4.2", + "parse5": "^7.1.2", + "pathe": "^1.1.2", + "periscopic": "^4.0.2", + "picocolors": "^1.0.0", + "picomatch": "^2.3.1", + "postcss-import": "^16.1.0", + "postcss-load-config": "^4.0.2", + "postcss-modules": "^6.0.0", + "resolve.exports": "^2.0.2", + "rollup-plugin-dts": "^6.1.0", + "rollup-plugin-esbuild": "^6.1.1", + "rollup-plugin-license": "^3.3.1", + "sass": "^1.74.1", + "sirv": "^2.0.4", + "source-map-support": "^0.5.21", + "strip-ansi": "^7.1.0", + "strip-literal": "^2.1.0", + "tsconfck": "^3.0.3", + "tslib": "^2.6.2", + "types": "link:./types", + "ufo": "^1.5.3", + "ws": "^8.16.0" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/@types/node": { + "resolved": "../../node_modules/.pnpm/@types+node@20.12.7/node_modules/@types/node", + "link": true + }, + "node_modules/vite": { + "resolved": "../../node_modules/.pnpm/vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3/node_modules/vite", + "link": true + } + } +} diff --git a/internal/vite-config/package-lock.json b/internal/vite-config/package-lock.json new file mode 100644 index 0000000..491cb7a --- /dev/null +++ b/internal/vite-config/package-lock.json @@ -0,0 +1,1050 @@ +{ + "name": "@vben/vite-config", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@vben/vite-config", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@ant-design/colors": "^7.0.2", + "vite": "^5.2.10" + }, + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@vitejs/plugin-vue": "^5.0.4", + "@vitejs/plugin-vue-jsx": "^3.1.0", + "ant-design-vue": "^4.2.1", + "dayjs": "^1.11.10", + "dotenv": "^16.4.5", + "fs-extra": "^11.2.0", + "less": "^4.2.0", + "picocolors": "^1.0.0", + "pkg-types": "^1.1.0", + "rollup-plugin-visualizer": "^5.12.0", + "sass": "^1.75.0", + "unocss": "0.59.4", + "vite-plugin-compression": "^0.5.1", + "vite-plugin-dts": "^3.9.0", + "vite-plugin-html": "^3.2.2", + "vite-plugin-mock": "^2.9.6", + "vite-plugin-purge-icons": "^0.10.0", + "vite-plugin-svg-icons": "^2.0.1" + } + }, + "../../node_modules/.pnpm/@ant-design+colors@7.0.2/node_modules/@ant-design/colors": { + "version": "7.0.2", + "license": "MIT", + "dependencies": { + "@ctrl/tinycolor": "^3.6.1" + }, + "devDependencies": { + "@types/jest": "^26.0.0", + "@umijs/fabric": "^3.0.0", + "eslint": "^7.1.0", + "father": "^4.1.2", + "jest": "^26.0.1", + "np": "^7.0.0", + "prettier": "^2.0.0", + "ts-jest": "^26.0.0", + "typescript": "^4.0.2" + } + }, + "../../node_modules/.pnpm/@types+fs-extra@11.0.4/node_modules/@types/fs-extra": { + "version": "11.0.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/jsonfile": "*", + "@types/node": "*" + } + }, + "../../node_modules/.pnpm/@vitejs+plugin-vue-jsx@3.1.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5._xa6xqdyhe5pkglb7lytn5kyk3a/node_modules/@vitejs/plugin-vue-jsx": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.23.3", + "@babel/plugin-transform-typescript": "^7.23.3", + "@vue/babel-plugin-jsx": "^1.1.5" + }, + "devDependencies": { + "vite": "^4.5.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.0.0 || ^5.0.0", + "vue": "^3.0.0" + } + }, + "../../node_modules/.pnpm/@vitejs+plugin-vue@5.0.4_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_p5z73732rkoe4bvfii6xrtzs34/node_modules/@vitejs/plugin-vue": { + "version": "5.0.4", + "dev": true, + "license": "MIT", + "devDependencies": { + "@jridgewell/gen-mapping": "^0.3.3", + "@jridgewell/trace-mapping": "^0.3.22", + "debug": "^4.3.4", + "rollup": "^4.9.6", + "slash": "^5.1.0", + "source-map-js": "^1.0.2", + "vite": "^5.0.12", + "vue": "^3.4.15" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "vite": "^5.0.0", + "vue": "^3.2.25" + } + }, + "../../node_modules/.pnpm/ant-design-vue@4.2.1_vue@3.4.25_typescript@5.4.5_/node_modules/ant-design-vue": { + "version": "4.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@ant-design/colors": "^6.0.0", + "@ant-design/icons-vue": "^7.0.0", + "@babel/runtime": "^7.10.5", + "@ctrl/tinycolor": "^3.5.0", + "@emotion/hash": "^0.9.0", + "@emotion/unitless": "^0.8.0", + "@simonwep/pickr": "~1.8.0", + "array-tree-filter": "^2.1.0", + "async-validator": "^4.0.0", + "csstype": "^3.1.1", + "dayjs": "^1.10.5", + "dom-align": "^1.12.1", + "dom-scroll-into-view": "^2.0.0", + "lodash": "^4.17.21", + "lodash-es": "^4.17.15", + "resize-observer-polyfill": "^1.5.1", + "scroll-into-view-if-needed": "^2.2.25", + "shallow-equal": "^1.0.0", + "stylis": "^4.1.3", + "throttle-debounce": "^5.0.0", + "vue-types": "^3.0.0", + "warning": "^4.0.0" + }, + "devDependencies": { + "@babel/cli": "^7.8.4", + "@babel/core": "^7.10.5", + "@babel/plugin-proposal-class-properties": "^7.8.3", + "@babel/plugin-proposal-export-default-from": "^7.8.3", + "@babel/plugin-proposal-export-namespace-from": "^7.12.1", + "@babel/plugin-proposal-object-rest-spread": "^7.9.6", + "@babel/plugin-proposal-optional-chaining": "^7.10.1", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-transform-member-expression-literals": "^7.8.3", + "@babel/plugin-transform-object-assign": "^7.8.3", + "@babel/plugin-transform-property-literals": "^7.8.3", + "@babel/plugin-transform-runtime": "^7.10.5", + "@babel/plugin-transform-template-literals": "^7.8.3", + "@babel/plugin-transform-typescript": "^7.12.1", + "@babel/polyfill": "^7.8.7", + "@babel/preset-env": "^7.9.6", + "@babel/preset-typescript": "^7.10.4", + "@commitlint/cli": "^12.0.0", + "@commitlint/config-conventional": "^12.0.0", + "@octokit/rest": "^18.0.0", + "@rollup/plugin-babel": "^5.3.0", + "@types/compression": "^1.7.0", + "@types/fs-extra": "^9.0.8", + "@types/jest": "^28.1.4", + "@types/koa": "^2.11.6", + "@types/lodash-es": "^4.17.3", + "@types/lru-cache": "^5.1.0", + "@types/markdown-it": "^10.0.2", + "@types/node": "^14.0.0", + "@types/postcss-load-config": "^2.0.1", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "@typescript-eslint/parser": "^5.4.0", + "@vitejs/plugin-legacy": "^2.2.0", + "@vitejs/plugin-vue": "^3.0.0", + "@vitejs/plugin-vue-jsx": "^2.0.0", + "@vue/babel-plugin-jsx": "^1.0.0", + "@vue/cli-plugin-eslint": "^5.0.0", + "@vue/eslint-config-prettier": "^8.0.0", + "@vue/eslint-config-typescript": "^11.0.0", + "@vue/test-utils": "^2.0.2", + "@vue/vue3-jest": "28", + "@vueuse/core": "^8.3.1", + "@webpack-cli/serve": "^1.3.1", + "acorn": "^8.0.0", + "ali-oss": "^6.16.0", + "autoprefixer": "^10.2.0", + "axios": "^0.22.0", + "babel-eslint": "^10.0.1", + "babel-jest": "^28.1.2", + "babel-loader": "^8.0.0", + "babel-plugin-import": "^1.1.1", + "babel-plugin-inline-import-data-uri": "^1.0.1", + "babel-plugin-istanbul": "^6.0.0", + "babel-plugin-transform-require-context": "^0.1.1", + "case-sensitive-paths-webpack-plugin": "^2.1.2", + "chalk": "^4.1.1", + "cheerio": "^1.0.0-rc.2", + "codecov": "^3.0.0", + "codesandbox": "^2.2.3", + "colorful": "^2.1.0", + "commander": "^6.1.0", + "compare-versions": "^3.3.0", + "cross-env": "^7.0.0", + "css-loader": "^5.0.0", + "css-minimizer-webpack-plugin": "^3.0.0", + "cz-git": "^1.3.8", + "date-fns": "^2.24.0", + "diacritics": "^1.3.0", + "docsearch.js": "^2.6.3", + "duplicate-package-checker-webpack-plugin": "^3.0.0", + "enquire-js": "^0.2.1", + "esbuild": "~0.12.29", + "esbuild-loader": "^3.0.0", + "escape-html": "^1.0.3", + "eslint": "^8.3.0", + "eslint-config-prettier": "^8.0.0", + "eslint-plugin-html": "^6.0.0", + "eslint-plugin-import": "^2.24.2", + "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-markdown": "^2.0.0", + "eslint-plugin-no-explicit-type-exports": "^0.12.0", + "eslint-plugin-prettier": "^3.1.0", + "eslint-plugin-vue": "^9.17.0", + "fast-glob": "^3.2.7", + "fetch-jsonp": "^1.1.3", + "fs-extra": "^10.0.0", + "glob": "^7.1.2", + "globby": "^11.1.0", + "gray-matter": "^4.0.3", + "gulp": "^4.0.1", + "gulp-babel": "^8.0.0", + "gulp-strip-code": "^0.1.4", + "gulp-typescript": "^6.0.0-alpha.1", + "html-webpack-plugin": "^5.3.1", + "husky": "^6.0.0", + "ignore-emit-webpack-plugin": "^2.0.6", + "is-windows": "^1.0.2", + "jest": "^28.1.2", + "jest-environment-jsdom": "^28.0.0", + "jest-environment-node": "^28.0.2", + "jest-serializer-vue": "^2.0.0", + "jest-transform-stub": "^2.0.0", + "js-base64": "^3.0.0", + "json-templater": "^1.2.0", + "jsonp": "^0.2.1", + "less": "^4.0.0", + "less-loader": "^10.0.0", + "less-plugin-npm-import": "^2.1.0", + "less-vars-to-js": "^1.3.0", + "lint-staged": "^11.0.0", + "majo": "^0.10.1", + "markdown-it": "^8.4.2", + "markdown-it-anchor": "^8.0.4", + "markdown-it-container": "^3.0.0", + "markdown-it-emoji": "^2.0.0", + "markdown-it-table-of-contents": "^0.5.2", + "marked": "0.3.18", + "merge2": "^1.2.1", + "mini-css-extract-plugin": "^2.4.5", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "mockdate": "^2.0.2", + "moment": "^2.29.1", + "nprogress": "^0.2.0", + "postcss": "^8.2.12", + "postcss-loader": "^6.0.0", + "prettier": "^2.2.0", + "pretty-quick": "^3.0.0", + "prismjs": "^1.23.0", + "progress": "^2.0.3", + "qs": "^6.10.3", + "raw-loader": "^4.0.2", + "remark-frontmatter": "^2.0.0", + "remark-parse": "^8.0.0", + "remark-stringify": "^8.0.0", + "remark-yaml-config": "^4.1.0", + "remove-files-webpack-plugin": "^1.5.0", + "reqwest": "^2.0.5", + "rimraf": "^3.0.0", + "rucksack-css": "^1.0.2", + "selenium-server": "^3.0.1", + "semver": "^7.0.0", + "slash": "^3.0.0", + "string-replace-loader": "^3.1.0", + "style-loader": "^3.0.0", + "stylelint": "^14.0.0", + "stylelint-config-prettier": "^9.0.0", + "stylelint-config-rational-order": "^0.1.2", + "stylelint-config-standard": "^25.0.0", + "stylelint-declaration-block-no-ignored-properties": "^2.1.0", + "stylelint-order": "^5.0.0", + "terser-webpack-plugin": "^5.1.1", + "through2": "^3.0.0", + "tinycolor2": "^1.6.0", + "ts-jest": "^28.0.5", + "ts-loader": "^9.1.0", + "tsx": "^3.12.10", + "typedoc": "^0.23.25", + "typescript": "~4.9.3", + "umi-request": "^1.3.5", + "unified": "9.2.2", + "url-loader": "^3.0.0", + "vanilla-jsoneditor": "^0.15.1", + "vite": "^3.0.0", + "vue": "^3.2.0", + "vue-clipboard2": "0.3.3", + "vue-drag-resize": "^2.0.3", + "vue-eslint-parser": "^9.3.1", + "vue-i18n": "^9.1.7", + "vue-infinite-scroll": "^2.0.2", + "vue-loader": "^17.0.0", + "vue-request": "^1.0.2", + "vue-router": "^4.0.0", + "vue-style-loader": "^4.1.2", + "vue-tsc": "^1.0.6", + "vuex": "^4.0.0", + "webpack": "^5.0.0", + "webpack-bundle-analyzer": "^4.4.2", + "webpack-cli": "^4.6.0", + "webpack-dev-server": "^4.0.0", + "webpack-merge": "^5.0.0", + "webpackbar": "^5.0.2", + "xhr-mock": "^2.5.1" + }, + "engines": { + "node": ">=12.22.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ant-design-vue" + }, + "peerDependencies": { + "vue": ">=3.2.0" + } + }, + "../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs": { + "version": "1.11.11", + "dev": true, + "license": "MIT", + "devDependencies": { + "@babel/cli": "^7.0.0-beta.44", + "@babel/core": "^7.0.0-beta.44", + "@babel/node": "^7.0.0-beta.44", + "@babel/preset-env": "^7.0.0-beta.44", + "babel-core": "^7.0.0-bridge.0", + "babel-jest": "^22.4.3", + "babel-plugin-external-helpers": "^6.22.0", + "cross-env": "^5.1.6", + "eslint": "^4.19.1", + "eslint-config-airbnb-base": "^12.1.0", + "eslint-plugin-import": "^2.10.0", + "eslint-plugin-jest": "^21.15.0", + "gzip-size-cli": "^2.1.0", + "jasmine-core": "^2.99.1", + "jest": "^22.4.3", + "karma": "^2.0.2", + "karma-jasmine": "^1.1.2", + "karma-sauce-launcher": "^1.1.0", + "mockdate": "^2.0.2", + "moment": "2.29.2", + "moment-timezone": "0.5.31", + "ncp": "^2.0.0", + "pre-commit": "^1.2.2", + "prettier": "^1.16.1", + "rollup": "^2.45.1", + "rollup-plugin-babel": "^4.4.0", + "rollup-plugin-terser": "^7.0.2", + "size-limit": "^0.18.0", + "typescript": "^2.8.3" + } + }, + "../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv": { + "version": "16.4.5", + "dev": true, + "license": "BSD-2-Clause", + "devDependencies": { + "@definitelytyped/dtslint": "^0.0.133", + "@types/node": "^18.11.3", + "decache": "^4.6.1", + "sinon": "^14.0.1", + "standard": "^17.0.0", + "standard-markdown": "^7.1.0", + "standard-version": "^9.5.0", + "tap": "^16.3.0", + "tar": "^6.1.11", + "typescript": "^4.8.4" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "../../node_modules/.pnpm/fs-extra@11.2.0/node_modules/fs-extra": { + "version": "11.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "devDependencies": { + "klaw": "^2.1.1", + "klaw-sync": "^3.0.2", + "minimist": "^1.1.1", + "mocha": "^10.1.0", + "nyc": "^15.0.0", + "proxyquire": "^2.0.1", + "read-dir-files": "^0.1.1", + "standard": "^17.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "../../node_modules/.pnpm/less@4.2.0/node_modules/less": { + "version": "4.2.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "copy-anything": "^2.0.1", + "parse-node-version": "^1.0.1", + "tslib": "^2.3.0" + }, + "bin": { + "lessc": "bin/lessc" + }, + "devDependencies": { + "@less/test-data": "^4.2.0", + "@less/test-import-module": "^4.0.0", + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^11.0.0", + "@typescript-eslint/eslint-plugin": "^4.28.0", + "@typescript-eslint/parser": "^4.28.0", + "benny": "^3.6.12", + "bootstrap-less-port": "0.3.0", + "chai": "^4.2.0", + "cross-env": "^7.0.3", + "diff": "^3.2.0", + "eslint": "^7.29.0", + "fs-extra": "^8.1.0", + "git-rev": "^0.2.1", + "globby": "^10.0.1", + "grunt": "^1.0.4", + "grunt-cli": "^1.3.2", + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-connect": "^1.0.2", + "grunt-eslint": "^23.0.0", + "grunt-saucelabs": "^9.0.1", + "grunt-shell": "^1.3.0", + "html-template-tag": "^3.2.0", + "jit-grunt": "^0.10.0", + "less-plugin-autoprefix": "^1.5.1", + "less-plugin-clean-css": "^1.5.1", + "minimist": "^1.2.0", + "mocha": "^6.2.1", + "mocha-headless-chrome": "^4.0.0", + "mocha-teamcity-reporter": "^3.0.0", + "nock": "^11.8.2", + "npm-run-all": "^4.1.5", + "performance-now": "^0.2.0", + "phin": "^2.2.3", + "promise": "^7.1.1", + "read-glob": "^3.0.0", + "resolve": "^1.17.0", + "rollup": "^2.52.2", + "rollup-plugin-terser": "^5.1.1", + "rollup-plugin-typescript2": "^0.29.0", + "semver": "^6.3.0", + "shx": "^0.3.2", + "time-grunt": "^1.3.0", + "ts-node": "^9.1.1", + "typescript": "^4.3.4", + "uikit": "2.27.4" + }, + "engines": { + "node": ">=6" + }, + "optionalDependencies": { + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^3.1.0", + "source-map": "~0.6.0" + } + }, + "../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors": { + "version": "1.0.0", + "dev": true, + "license": "ISC" + }, + "../../node_modules/.pnpm/pkg-types@1.1.0/node_modules/pkg-types": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.1.7", + "mlly": "^1.6.1", + "pathe": "^1.1.2" + }, + "devDependencies": { + "@types/node": "^20.12.7", + "@vitest/coverage-v8": "^1.5.0", + "automd": "^0.3.7", + "changelogen": "^0.5.5", + "eslint": "^9.0.0", + "eslint-config-unjs": "^0.3.0-rc.6", + "expect-type": "^0.19.0", + "jiti": "^1.21.0", + "prettier": "^3.2.5", + "typescript": "^5.4.5", + "unbuild": "^2.0.0", + "vitest": "^1.5.0" + } + }, + "../../node_modules/.pnpm/rollup-plugin-visualizer@5.12.0_rollup@4.17.0/node_modules/rollup-plugin-visualizer": { + "version": "5.12.0", + "dev": true, + "license": "MIT", + "dependencies": { + "open": "^8.4.0", + "picomatch": "^2.3.1", + "source-map": "^0.7.4", + "yargs": "^17.5.1" + }, + "bin": { + "rollup-plugin-visualizer": "dist/bin/cli.js" + }, + "devDependencies": { + "@jest/globals": "^29.3.1", + "@rollup/plugin-alias": "^5.0.0", + "@rollup/plugin-commonjs": "^25.0.1", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.1", + "@types/bytes": "^3.1.1", + "@types/d3-array": "^3.0.3", + "@types/d3-color": "^3.1.0", + "@types/d3-force": "^3.0.3", + "@types/d3-hierarchy": "^3.1.0", + "@types/d3-scale": "^4.0.2", + "@types/d3-shape": "^3.1.0", + "@types/node": "^18.8.5", + "@types/picomatch": "^2.3.0", + "@types/yargs": "^17.0.10", + "@typescript-eslint/eslint-plugin": "^6.12.0", + "@typescript-eslint/parser": "^6.12.0", + "bytes": "^3.1.2", + "d3-array": "^3.1.6", + "d3-color": "^3.1.0", + "d3-force": "^3.0.0", + "d3-hierarchy": "^3.1.2", + "d3-scale": "^4.0.2", + "d3-shape": "^3.1.0", + "del-cli": "^5.0.0", + "eslint": "^8.16.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.1", + "jest": "^29.3.1", + "npm-run-all": "^4.1.5", + "picomatch-browser": "^2.2.6", + "postcss": "^8.4.14", + "postcss-url": "^10.1.3", + "preact": "^10.7.2", + "prettier": "^3.1.0", + "rollup": "^4.5.2", + "rollup-plugin-postcss": "^4.0.2", + "sass": "^1.52.1", + "ts-jest": "^29.0.3", + "typescript": "~5.3.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "rollup": "2.x || 3.x || 4.x" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "../../node_modules/.pnpm/sass@1.75.0/node_modules/sass": { + "version": "1.75.0", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "../../node_modules/.pnpm/unocss@0.59.4_postcss@5.2.18_rollup@4.17.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/unocss": { + "version": "0.59.4", + "dev": true, + "license": "MIT", + "dependencies": { + "@unocss/astro": "0.59.4", + "@unocss/cli": "0.59.4", + "@unocss/core": "0.59.4", + "@unocss/extractor-arbitrary-variants": "0.59.4", + "@unocss/postcss": "0.59.4", + "@unocss/preset-attributify": "0.59.4", + "@unocss/preset-icons": "0.59.4", + "@unocss/preset-mini": "0.59.4", + "@unocss/preset-tagify": "0.59.4", + "@unocss/preset-typography": "0.59.4", + "@unocss/preset-uno": "0.59.4", + "@unocss/preset-web-fonts": "0.59.4", + "@unocss/preset-wind": "0.59.4", + "@unocss/reset": "0.59.4", + "@unocss/transformer-attributify-jsx": "0.59.4", + "@unocss/transformer-attributify-jsx-babel": "0.59.4", + "@unocss/transformer-compile-class": "0.59.4", + "@unocss/transformer-directives": "0.59.4", + "@unocss/transformer-variant-group": "0.59.4", + "@unocss/vite": "0.59.4" + }, + "devDependencies": { + "@unocss/webpack": "0.59.4", + "vite": "^5.2.9" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@unocss/webpack": "0.59.4", + "vite": "^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0" + }, + "peerDependenciesMeta": { + "@unocss/webpack": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "../../node_modules/.pnpm/vite-plugin-compression@0.5.1_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-compression": { + "version": "0.5.1", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.2", + "debug": "^4.3.3", + "fs-extra": "^10.0.0" + }, + "devDependencies": { + "@types/chalk": "^2.2.0", + "@types/debug": "^4.1.7", + "@types/fs-extra": "^9.0.13", + "@types/node": "^17.0.13" + }, + "peerDependencies": { + "vite": ">=2.0.0" + } + }, + "../../node_modules/.pnpm/vite-plugin-dts@3.9.0_@types+node@20.12.7_rollup@4.17.0_typescript@5.4.5_vite@5.2.10_@types+n_fufyeow7or3ddm4dyjka2mjzvy/node_modules/vite-plugin-dts": { + "version": "3.9.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@microsoft/api-extractor": "7.43.0", + "@rollup/pluginutils": "^5.1.0", + "@vue/language-core": "^1.8.27", + "debug": "^4.3.4", + "kolorist": "^1.8.0", + "magic-string": "^0.30.8", + "vue-tsc": "^1.8.27" + }, + "devDependencies": { + "@commitlint/cli": "^19.2.1", + "@types/debug": "^4.1.12", + "@types/minimist": "^1.2.5", + "@types/node": "^20.11.30", + "@types/prompts": "^2.4.9", + "@types/semver": "^7.5.8", + "@vexip-ui/commitlint-config": "^0.4.0", + "@vexip-ui/eslint-config": "^0.12.0", + "@vexip-ui/prettier-config": "^0.2.0", + "@vue/eslint-config-standard": "^8.0.1", + "@vue/eslint-config-typescript": "^13.0.0", + "conventional-changelog-cli": "^4.1.0", + "eslint": "^8.57.0", + "execa": "^8.0.1", + "husky": "^9.0.11", + "is-ci": "^3.0.1", + "lint-staged": "^15.2.2", + "minimist": "^1.2.8", + "pinst": "^3.0.0", + "prettier": "^3.2.5", + "pretty-quick": "^4.0.0", + "prompts": "^2.4.2", + "rimraf": "^5.0.5", + "semver": "^7.6.0", + "tsx": "^4.7.1", + "typescript": "5.4.3", + "unbuild": "^2.0.0", + "vite": "^5.2.6", + "vitest": "^1.4.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "typescript": "*", + "vite": "*" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "../../node_modules/.pnpm/vite-plugin-html@3.2.2_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-html": { + "version": "3.2.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^4.2.0", + "colorette": "^2.0.16", + "connect-history-api-fallback": "^1.6.0", + "consola": "^2.15.3", + "dotenv": "^16.0.0", + "dotenv-expand": "^8.0.2", + "ejs": "^3.1.6", + "fast-glob": "^3.2.11", + "fs-extra": "^10.0.1", + "html-minifier-terser": "^6.1.0", + "node-html-parser": "^5.3.3", + "pathe": "^0.2.0" + }, + "devDependencies": { + "@babel/types": "^7.17.0", + "@types/ejs": "^3.1.0", + "@types/fs-extra": "^9.0.13", + "@types/html-minifier-terser": "^6.1.0", + "@types/node": "^17.0.21", + "typescript": "^4.6.2", + "vite": "^2.8.6" + }, + "peerDependencies": { + "vite": ">=2.0.0" + } + }, + "../../node_modules/.pnpm/vite-plugin-mock@2.9.8_mockjs@1.1.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-mock": { + "version": "2.9.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mockjs": "^1.0.4", + "chalk": "^4.1.2", + "chokidar": "^3.5.2", + "connect": "^3.7.0", + "debug": "^4.3.2", + "esbuild": "^0.14.36", + "fast-glob": "^3.2.7", + "path-to-regexp": "^6.2.0" + }, + "devDependencies": { + "@commitlint/cli": "^13.1.0", + "@commitlint/config-conventional": "^13.1.0", + "@types/connect": "^3.4.35", + "@types/debug": "^4.1.7", + "@types/jest": "^27.0.1", + "@types/node": "^16.7.1", + "@typescript-eslint/eslint-plugin": "^4.29.2", + "@typescript-eslint/parser": "^4.29.2", + "commitizen": "^4.2.4", + "conventional-changelog-cli": "^2.1.1", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-jest": "^24.4.0", + "husky": "^7.0.1", + "jest": "^27.0.6", + "lint-staged": "^11.1.2", + "mockjs": "^1.1.0", + "prettier": "^2.3.2", + "rimraf": "^3.0.2", + "ts-jest": "^27.0.5", + "tsup": "4.8.21", + "typescript": "^4.3.5", + "vite": "2.1.5" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "mockjs": ">=1.1.0", + "vite": ">=2.0.0" + } + }, + "../../node_modules/.pnpm/vite-plugin-purge-icons@0.10.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-purge-icons": { + "version": "0.10.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@purge-icons/core": "^0.10.0", + "@purge-icons/generated": "^0.10.0", + "rollup-plugin-purge-icons": "^0.10.0" + }, + "devDependencies": { + "esno": "^0.4.6", + "tsup": "^4.14.0", + "typescript": "^4.9.5", + "vite": "^5" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "vite": ">=2" + } + }, + "../../node_modules/.pnpm/vite-plugin-svg-icons@2.0.1_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-svg-icons": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/svgo": "^2.6.1", + "cors": "^2.8.5", + "debug": "^4.3.3", + "etag": "^1.8.1", + "fs-extra": "^10.0.0", + "pathe": "^0.2.0", + "svg-baker": "1.7.0", + "svgo": "^2.8.0" + }, + "devDependencies": { + "@types/cors": "^2.8.12", + "@types/debug": "^4.1.7", + "@types/etag": "^1.8.1", + "@types/fs-extra": "^9.0.13", + "@types/node": "^17.0.13" + }, + "peerDependencies": { + "vite": ">=2.0.0" + } + }, + "../../node_modules/.pnpm/vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3/node_modules/vite": { + "version": "5.2.10", + "license": "MIT", + "dependencies": { + "esbuild": "^0.20.1", + "postcss": "^8.4.38", + "rollup": "^4.13.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "devDependencies": { + "@ampproject/remapping": "^2.3.0", + "@babel/parser": "^7.24.4", + "@jridgewell/trace-mapping": "^0.3.25", + "@polka/compression": "^1.0.0-next.25", + "@rollup/plugin-alias": "^5.1.0", + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-dynamic-import-vars": "^2.1.2", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "15.2.3", + "@rollup/plugin-typescript": "^11.1.6", + "@rollup/pluginutils": "^5.1.0", + "@types/escape-html": "^1.0.4", + "@types/pnpapi": "^0.0.5", + "acorn": "^8.11.3", + "acorn-walk": "^8.3.2", + "artichokie": "^0.2.0", + "cac": "^6.7.14", + "chokidar": "^3.6.0", + "connect": "^3.7.0", + "convert-source-map": "^2.0.0", + "cors": "^2.8.5", + "cross-spawn": "^7.0.3", + "debug": "^4.3.4", + "dep-types": "link:./src/types", + "dotenv": "^16.4.5", + "dotenv-expand": "^11.0.6", + "es-module-lexer": "^1.5.0", + "escape-html": "^1.0.3", + "estree-walker": "^3.0.3", + "etag": "^1.8.1", + "fast-glob": "^3.3.2", + "http-proxy": "^1.18.1", + "launch-editor-middleware": "^2.6.1", + "lightningcss": "^1.24.1", + "magic-string": "^0.30.9", + "micromatch": "^4.0.5", + "mlly": "^1.6.1", + "mrmime": "^2.0.0", + "open": "^8.4.2", + "parse5": "^7.1.2", + "pathe": "^1.1.2", + "periscopic": "^4.0.2", + "picocolors": "^1.0.0", + "picomatch": "^2.3.1", + "postcss-import": "^16.1.0", + "postcss-load-config": "^4.0.2", + "postcss-modules": "^6.0.0", + "resolve.exports": "^2.0.2", + "rollup-plugin-dts": "^6.1.0", + "rollup-plugin-esbuild": "^6.1.1", + "rollup-plugin-license": "^3.3.1", + "sass": "^1.74.1", + "sirv": "^2.0.4", + "source-map-support": "^0.5.21", + "strip-ansi": "^7.1.0", + "strip-literal": "^2.1.0", + "tsconfck": "^3.0.3", + "tslib": "^2.6.2", + "types": "link:./types", + "ufo": "^1.5.3", + "ws": "^8.16.0" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/@ant-design/colors": { + "resolved": "../../node_modules/.pnpm/@ant-design+colors@7.0.2/node_modules/@ant-design/colors", + "link": true + }, + "node_modules/@types/fs-extra": { + "resolved": "../../node_modules/.pnpm/@types+fs-extra@11.0.4/node_modules/@types/fs-extra", + "link": true + }, + "node_modules/@vitejs/plugin-vue": { + "resolved": "../../node_modules/.pnpm/@vitejs+plugin-vue@5.0.4_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_p5z73732rkoe4bvfii6xrtzs34/node_modules/@vitejs/plugin-vue", + "link": true + }, + "node_modules/@vitejs/plugin-vue-jsx": { + "resolved": "../../node_modules/.pnpm/@vitejs+plugin-vue-jsx@3.1.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5._xa6xqdyhe5pkglb7lytn5kyk3a/node_modules/@vitejs/plugin-vue-jsx", + "link": true + }, + "node_modules/ant-design-vue": { + "resolved": "../../node_modules/.pnpm/ant-design-vue@4.2.1_vue@3.4.25_typescript@5.4.5_/node_modules/ant-design-vue", + "link": true + }, + "node_modules/dayjs": { + "resolved": "../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs", + "link": true + }, + "node_modules/dotenv": { + "resolved": "../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv", + "link": true + }, + "node_modules/fs-extra": { + "resolved": "../../node_modules/.pnpm/fs-extra@11.2.0/node_modules/fs-extra", + "link": true + }, + "node_modules/less": { + "resolved": "../../node_modules/.pnpm/less@4.2.0/node_modules/less", + "link": true + }, + "node_modules/picocolors": { + "resolved": "../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors", + "link": true + }, + "node_modules/pkg-types": { + "resolved": "../../node_modules/.pnpm/pkg-types@1.1.0/node_modules/pkg-types", + "link": true + }, + "node_modules/rollup-plugin-visualizer": { + "resolved": "../../node_modules/.pnpm/rollup-plugin-visualizer@5.12.0_rollup@4.17.0/node_modules/rollup-plugin-visualizer", + "link": true + }, + "node_modules/sass": { + "resolved": "../../node_modules/.pnpm/sass@1.75.0/node_modules/sass", + "link": true + }, + "node_modules/unocss": { + "resolved": "../../node_modules/.pnpm/unocss@0.59.4_postcss@5.2.18_rollup@4.17.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/unocss", + "link": true + }, + "node_modules/vite": { + "resolved": "../../node_modules/.pnpm/vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3/node_modules/vite", + "link": true + }, + "node_modules/vite-plugin-compression": { + "resolved": "../../node_modules/.pnpm/vite-plugin-compression@0.5.1_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-compression", + "link": true + }, + "node_modules/vite-plugin-dts": { + "resolved": "../../node_modules/.pnpm/vite-plugin-dts@3.9.0_@types+node@20.12.7_rollup@4.17.0_typescript@5.4.5_vite@5.2.10_@types+n_fufyeow7or3ddm4dyjka2mjzvy/node_modules/vite-plugin-dts", + "link": true + }, + "node_modules/vite-plugin-html": { + "resolved": "../../node_modules/.pnpm/vite-plugin-html@3.2.2_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-html", + "link": true + }, + "node_modules/vite-plugin-mock": { + "resolved": "../../node_modules/.pnpm/vite-plugin-mock@2.9.8_mockjs@1.1.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-mock", + "link": true + }, + "node_modules/vite-plugin-purge-icons": { + "resolved": "../../node_modules/.pnpm/vite-plugin-purge-icons@0.10.0_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-purge-icons", + "link": true + }, + "node_modules/vite-plugin-svg-icons": { + "resolved": "../../node_modules/.pnpm/vite-plugin-svg-icons@2.0.1_vite@5.2.10_@types+node@20.12.7_less@4.2.0_sass@1.75.0_terser@5.19.3_/node_modules/vite-plugin-svg-icons", + "link": true + } + } +} diff --git a/node-jiti/ansi-styles-index.js.ccdcb812.js b/node-jiti/ansi-styles-index.js.ccdcb812.js new file mode 100644 index 0000000..88071f8 --- /dev/null +++ b/node-jiti/ansi-styles-index.js.ccdcb812.js @@ -0,0 +1,223 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.modifierNames = exports.foregroundColorNames = exports.default = exports.colorNames = exports.backgroundColorNames = void 0;const ANSI_BACKGROUND_OFFSET = 10; + +const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`; + +const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`; + +const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`; + +const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + overline: [53, 55], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + + // Bright color + blackBright: [90, 39], + gray: [90, 39], // Alias of `blackBright` + grey: [90, 39], // Alias of `blackBright` + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + + // Bright color + bgBlackBright: [100, 49], + bgGray: [100, 49], // Alias of `bgBlackBright` + bgGrey: [100, 49], // Alias of `bgBlackBright` + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } +}; + +const modifierNames = Object.keys(styles.modifier);exports.modifierNames = modifierNames; +const foregroundColorNames = Object.keys(styles.color);exports.foregroundColorNames = foregroundColorNames; +const backgroundColorNames = Object.keys(styles.bgColor);exports.backgroundColorNames = backgroundColorNames; +const colorNames = [...foregroundColorNames, ...backgroundColorNames];exports.colorNames = colorNames; + +function assembleStyles() { + const codes = new Map(); + + for (const [groupName, group] of Object.entries(styles)) { + for (const [styleName, style] of Object.entries(group)) { + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + }; + + group[styleName] = styles[styleName]; + + codes.set(style[0], style[1]); + } + + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); + } + + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }); + + styles.color.close = '\u001B[39m'; + styles.bgColor.close = '\u001B[49m'; + + styles.color.ansi = wrapAnsi16(); + styles.color.ansi256 = wrapAnsi256(); + styles.color.ansi16m = wrapAnsi16m(); + styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); + styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); + styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); + + // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js + Object.defineProperties(styles, { + rgbToAnsi256: { + value(red, green, blue) { + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (red === green && green === blue) { + if (red < 8) { + return 16; + } + + if (red > 248) { + return 231; + } + + return Math.round((red - 8) / 247 * 24) + 232; + } + + return 16 + + 36 * Math.round(red / 255 * 5) + + 6 * Math.round(green / 255 * 5) + + Math.round(blue / 255 * 5); + }, + enumerable: false + }, + hexToRgb: { + value(hex) { + const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); + if (!matches) { + return [0, 0, 0]; + } + + let [colorString] = matches; + + if (colorString.length === 3) { + colorString = [...colorString].map((character) => character + character).join(''); + } + + const integer = Number.parseInt(colorString, 16); + + return [ + /* eslint-disable no-bitwise */ + integer >> 16 & 0xFF, + integer >> 8 & 0xFF, + integer & 0xFF + /* eslint-enable no-bitwise */]; + + }, + enumerable: false + }, + hexToAnsi256: { + value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), + enumerable: false + }, + ansi256ToAnsi: { + value(code) { + if (code < 8) { + return 30 + code; + } + + if (code < 16) { + return 90 + (code - 8); + } + + let red; + let green; + let blue; + + if (code >= 232) { + red = ((code - 232) * 10 + 8) / 255; + green = red; + blue = red; + } else { + code -= 16; + + const remainder = code % 36; + + red = Math.floor(code / 36) / 5; + green = Math.floor(remainder / 6) / 5; + blue = remainder % 6 / 5; + } + + const value = Math.max(red, green, blue) * 2; + + if (value === 0) { + return 30; + } + + // eslint-disable-next-line no-bitwise + let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); + + if (value === 2) { + result += 60; + } + + return result; + }, + enumerable: false + }, + rgbToAnsi: { + value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), + enumerable: false + }, + hexToAnsi: { + value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), + enumerable: false + } + }); + + return styles; +} + +const ansiStyles = assembleStyles();var _default = + +ansiStyles;exports.default = _default; /* v7-28b0a5febe3644a0 */ \ No newline at end of file diff --git a/node-jiti/cjs-index.js.46633104.js b/node-jiti/cjs-index.js.46633104.js new file mode 100644 index 0000000..c21c3c1 --- /dev/null +++ b/node-jiti/cjs-index.js.46633104.js @@ -0,0 +1,1359 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var path = require('path'); +var isBuiltinModule = require('is-builtin-module'); +var deepMerge = require('deepmerge'); +var isModule = require('is-module'); +var fs = require('fs'); +var util = require('util'); +var url = require('url'); +var resolve = require('resolve'); +var pluginutils = require('@rollup/pluginutils'); + +var version = "15.2.1"; +var peerDependencies = { + rollup: "^2.78.0||^3.0.0" +}; + +util.promisify(fs.access); +const readFile$1 = util.promisify(fs.readFile); +const realpath = util.promisify(fs.realpath); +const stat = util.promisify(fs.stat); +async function fileExists(filePath) { + try { + const res = await stat(filePath); + return res.isFile(); + } + catch { + return false; + } +} +async function resolveSymlink(path) { + return (await fileExists(path)) ? realpath(path) : path; +} + +const onError = (error) => { + if (error.code === 'ENOENT') { + return false; + } + throw error; +}; + +const makeCache = (fn) => { + const cache = new Map(); + const wrapped = async (param, done) => { + if (cache.has(param) === false) { + cache.set( + param, + fn(param).catch((err) => { + cache.delete(param); + throw err; + }) + ); + } + + try { + const result = cache.get(param); + const value = await result; + return done(null, value); + } catch (error) { + return done(error); + } + }; + + wrapped.clear = () => cache.clear(); + + return wrapped; +}; + +const isDirCached = makeCache(async (file) => { + try { + const stats = await stat(file); + return stats.isDirectory(); + } catch (error) { + return onError(error); + } +}); + +const isFileCached = makeCache(async (file) => { + try { + const stats = await stat(file); + return stats.isFile(); + } catch (error) { + return onError(error); + } +}); + +const readCachedFile = makeCache(readFile$1); + +function handleDeprecatedOptions(opts) { + const warnings = []; + + if (opts.customResolveOptions) { + const { customResolveOptions } = opts; + if (customResolveOptions.moduleDirectory) { + // eslint-disable-next-line no-param-reassign + opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory) ? + customResolveOptions.moduleDirectory : + [customResolveOptions.moduleDirectory]; + + warnings.push( + 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.' + ); + } + + if (customResolveOptions.preserveSymlinks) { + throw new Error( + 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.' + ); + } + + [ + 'basedir', + 'package', + 'extensions', + 'includeCoreModules', + 'readFile', + 'isFile', + 'isDirectory', + 'realpath', + 'packageFilter', + 'pathFilter', + 'paths', + 'packageIterator']. + forEach((resolveOption) => { + if (customResolveOptions[resolveOption]) { + throw new Error( + `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.` + ); + } + }); + } + + return { warnings }; +} + +// returns the imported package name for bare module imports +function getPackageName(id) { + if (id.startsWith('.') || id.startsWith('/')) { + return null; + } + + const split = id.split('/'); + + // @my-scope/my-package/foo.js -> @my-scope/my-package + // @my-scope/my-package -> @my-scope/my-package + if (split[0][0] === '@') { + return `${split[0]}/${split[1]}`; + } + + // my-package/foo.js -> my-package + // my-package -> my-package + return split[0]; +} + +function getMainFields(options) { + let mainFields; + if (options.mainFields) { + ({ mainFields } = options); + } else { + mainFields = ['module', 'main']; + } + if (options.browser && mainFields.indexOf('browser') === -1) { + return ['browser'].concat(mainFields); + } + if (!mainFields.length) { + throw new Error('Please ensure at least one `mainFields` value is specified'); + } + return mainFields; +} + +function getPackageInfo(options) { + const { + cache, + extensions, + pkg, + mainFields, + preserveSymlinks, + useBrowserOverrides, + rootDir, + ignoreSideEffectsForRoot + } = options; + let { pkgPath } = options; + + if (cache.has(pkgPath)) { + return cache.get(pkgPath); + } + + // browserify/resolve doesn't realpath paths returned in its packageFilter callback + if (!preserveSymlinks) { + pkgPath = fs.realpathSync(pkgPath); + } + + const pkgRoot = path.dirname(pkgPath); + + const packageInfo = { + // copy as we are about to munge the `main` field of `pkg`. + packageJson: { ...pkg }, + + // path to package.json file + packageJsonPath: pkgPath, + + // directory containing the package.json + root: pkgRoot, + + // which main field was used during resolution of this module (main, module, or browser) + resolvedMainField: 'main', + + // whether the browser map was used to resolve the entry point to this module + browserMappedMain: false, + + // the entry point of the module with respect to the selected main field and any + // relevant browser mappings. + resolvedEntryPoint: '' + }; + + let overriddenMain = false; + for (let i = 0; i < mainFields.length; i++) { + const field = mainFields[i]; + if (typeof pkg[field] === 'string') { + pkg.main = pkg[field]; + packageInfo.resolvedMainField = field; + overriddenMain = true; + break; + } + } + + const internalPackageInfo = { + cachedPkg: pkg, + hasModuleSideEffects: () => null, + hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1, + packageBrowserField: + useBrowserOverrides && + typeof pkg.browser === 'object' && + Object.keys(pkg.browser).reduce((browser, key) => { + let resolved = pkg.browser[key]; + if (resolved && resolved[0] === '.') { + resolved = path.resolve(pkgRoot, resolved); + } + /* eslint-disable no-param-reassign */ + browser[key] = resolved; + if (key[0] === '.') { + const absoluteKey = path.resolve(pkgRoot, key); + browser[absoluteKey] = resolved; + if (!path.extname(key)) { + extensions.reduce((subBrowser, ext) => { + subBrowser[absoluteKey + ext] = subBrowser[key]; + return subBrowser; + }, browser); + } + } + return browser; + }, {}), + packageInfo + }; + + const browserMap = internalPackageInfo.packageBrowserField; + if ( + useBrowserOverrides && + typeof pkg.browser === 'object' && + // eslint-disable-next-line no-prototype-builtins + browserMap.hasOwnProperty(pkg.main)) + { + packageInfo.resolvedEntryPoint = browserMap[pkg.main]; + packageInfo.browserMappedMain = true; + } else { + // index.node is technically a valid default entrypoint as well... + packageInfo.resolvedEntryPoint = path.resolve(pkgRoot, pkg.main || 'index.js'); + packageInfo.browserMappedMain = false; + } + + if (!ignoreSideEffectsForRoot || rootDir !== pkgRoot) { + const packageSideEffects = pkg.sideEffects; + if (typeof packageSideEffects === 'boolean') { + internalPackageInfo.hasModuleSideEffects = () => packageSideEffects; + } else if (Array.isArray(packageSideEffects)) { + const finalPackageSideEffects = packageSideEffects.map((sideEffect) => { + /* + * The array accepts simple glob patterns to the relevant files... Patterns like .css, which do not include a /, will be treated like **\/.css. + * https://webpack.js.org/guides/tree-shaking/ + */ + if (sideEffect.includes('/')) { + return sideEffect; + } + return `**/${sideEffect}`; + }); + internalPackageInfo.hasModuleSideEffects = pluginutils.createFilter(finalPackageSideEffects, null, { + resolve: pkgRoot + }); + } + } + + cache.set(pkgPath, internalPackageInfo); + return internalPackageInfo; +} + +function normalizeInput(input) { + if (Array.isArray(input)) { + return input; + } else if (typeof input === 'object') { + return Object.values(input); + } + + // otherwise it's a string + return [input]; +} + +/* eslint-disable no-await-in-loop */ +function isModuleDir(current, moduleDirs) { + return moduleDirs.some((dir) => current.endsWith(dir)); +} +async function findPackageJson(base, moduleDirs) { + const { root } = path.parse(base); + let current = base; + while (current !== root && !isModuleDir(current, moduleDirs)) { + const pkgJsonPath = path.join(current, 'package.json'); + if (await fileExists(pkgJsonPath)) { + const pkgJsonString = fs.readFileSync(pkgJsonPath, 'utf-8'); + return { pkgJson: JSON.parse(pkgJsonString), pkgPath: current, pkgJsonPath }; + } + current = path.resolve(current, '..'); + } + return null; +} +function isUrl(str) { + try { + return !!new URL(str); + } + catch (_) { + return false; + } +} +/** + * Conditions is an export object where all keys are conditions like 'node' (aka do not with '.') + */ +function isConditions(exports) { + return typeof exports === 'object' && Object.keys(exports).every((k) => !k.startsWith('.')); +} +/** + * Mappings is an export object where all keys start with '. + */ +function isMappings(exports) { + return typeof exports === 'object' && !isConditions(exports); +} +/** + * Check for mixed exports, which are exports where some keys start with '.' and some do not + */ +function isMixedExports(exports) { + const keys = Object.keys(exports); + return keys.some((k) => k.startsWith('.')) && keys.some((k) => !k.startsWith('.')); +} +function createBaseErrorMsg(importSpecifier, importer) { + return `Could not resolve import "${importSpecifier}" in ${importer}`; +} +function createErrorMsg(context, reason, isImports) { + const { importSpecifier, importer, pkgJsonPath } = context; + const base = createBaseErrorMsg(importSpecifier, importer); + const field = isImports ? 'imports' : 'exports'; + return `${base} using ${field} defined in ${pkgJsonPath}.${reason ? ` ${reason}` : ''}`; +} +class ResolveError extends Error {} + +class InvalidConfigurationError extends ResolveError { + constructor(context, reason) { + super(createErrorMsg(context, `Invalid "exports" field. ${reason}`)); + } +} +class InvalidModuleSpecifierError extends ResolveError { + constructor(context, isImports, reason) { + super(createErrorMsg(context, reason, isImports)); + } +} +class InvalidPackageTargetError extends ResolveError { + constructor(context, reason) { + super(createErrorMsg(context, reason)); + } +} + +/* eslint-disable no-await-in-loop, no-undefined */ +/** + * Check for invalid path segments + */ +function includesInvalidSegments(pathSegments, moduleDirs) { + const invalidSegments = ['', '.', '..', ...moduleDirs]; + // contains any "", ".", "..", or "node_modules" segments, including percent encoded variants + return pathSegments.some((v) => invalidSegments.includes(v) || invalidSegments.includes(decodeURI(v))); +} +async function resolvePackageTarget(context, { target, patternMatch, isImports }) { + // If target is a String, then + if (typeof target === 'string') { + // If target does not start with "./", then + if (!target.startsWith('./')) { + // If isImports is false, or if target starts with "../" or "/", or if target is a valid URL, then + if (!isImports || ['/', '../'].some((p) => target.startsWith(p)) || isUrl(target)) { + // Throw an Invalid Package Target error. + throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`); + } + // If patternMatch is a String, then + if (typeof patternMatch === 'string') { + // Return PACKAGE_RESOLVE(target with every instance of "*" replaced by patternMatch, packageURL + "/") + const result = await context.resolveId(target.replace(/\*/g, patternMatch), context.pkgURL.href); + return result ? url.pathToFileURL(result.location).href : null; + } + // Return PACKAGE_RESOLVE(target, packageURL + "/"). + const result = await context.resolveId(target, context.pkgURL.href); + return result ? url.pathToFileURL(result.location).href : null; + } + // TODO: Drop if we do not support Node <= 16 anymore + // This behavior was removed in Node 17 (deprecated in Node 14), see DEP0148 + if (context.allowExportsFolderMapping) { + target = target.replace(/\/$/, '/*'); + } + // If target split on "/" or "\" + { + const pathSegments = target.split(/\/|\\/); + // after the first "." segment + const firstDot = pathSegments.indexOf('.'); + firstDot !== -1 && pathSegments.slice(firstDot); + if (firstDot !== -1 && + firstDot < pathSegments.length - 1 && + includesInvalidSegments(pathSegments.slice(firstDot + 1), context.moduleDirs)) { + throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`); + } + } + // Let resolvedTarget be the URL resolution of the concatenation of packageURL and target. + const resolvedTarget = new URL(target, context.pkgURL); + // Assert: resolvedTarget is contained in packageURL. + if (!resolvedTarget.href.startsWith(context.pkgURL.href)) { + throw new InvalidPackageTargetError(context, `Resolved to ${resolvedTarget.href} which is outside package ${context.pkgURL.href}`); + } + // If patternMatch is null, then + if (!patternMatch) { + // Return resolvedTarget. + return resolvedTarget; + } + // If patternMatch split on "/" or "\" contains invalid segments + if (includesInvalidSegments(patternMatch.split(/\/|\\/), context.moduleDirs)) { + // throw an Invalid Module Specifier error. + throw new InvalidModuleSpecifierError(context); + } + // Return the URL resolution of resolvedTarget with every instance of "*" replaced with patternMatch. + return resolvedTarget.href.replace(/\*/g, patternMatch); + } + // Otherwise, if target is an Array, then + if (Array.isArray(target)) { + // If _target.length is zero, return null. + if (target.length === 0) { + return null; + } + let lastError = null; + // For each item in target, do + for (const item of target) { + // Let resolved be the result of PACKAGE_TARGET_RESOLVE of the item + // continuing the loop on any Invalid Package Target error. + try { + const resolved = await resolvePackageTarget(context, { + target: item, + patternMatch, + isImports + }); + // If resolved is undefined, continue the loop. + // Else Return resolved. + if (resolved !== undefined) { + return resolved; + } + } + catch (error) { + if (!(error instanceof InvalidPackageTargetError)) { + throw error; + } else + { + lastError = error; + } + } + } + // Return or throw the last fallback resolution null return or error + if (lastError) { + throw lastError; + } + return null; + } + // Otherwise, if target is a non-null Object, then + if (target && typeof target === 'object') { + // For each property of target + for (const [key, value] of Object.entries(target)) { + // If exports contains any index property keys, as defined in ECMA-262 6.1.7 Array Index, throw an Invalid Package Configuration error. + // TODO: We do not check if the key is a number here... + // If key equals "default" or conditions contains an entry for the key, then + if (key === 'default' || context.conditions.includes(key)) { + // Let targetValue be the value of the property in target. + // Let resolved be the result of PACKAGE_TARGET_RESOLVE of the targetValue + const resolved = await resolvePackageTarget(context, { + target: value, + patternMatch, + isImports + }); + // If resolved is equal to undefined, continue the loop. + // Return resolved. + if (resolved !== undefined) { + return resolved; + } + } + } + // Return undefined. + return undefined; + } + // Otherwise, if target is null, return null. + if (target === null) { + return null; + } + // Otherwise throw an Invalid Package Target error. + throw new InvalidPackageTargetError(context, `Invalid exports field.`); +} + +/* eslint-disable no-await-in-loop */ +/** + * Implementation of Node's `PATTERN_KEY_COMPARE` function + */ +function nodePatternKeyCompare(keyA, keyB) { + // Let baseLengthA be the index of "*" in keyA plus one, if keyA contains "*", or the length of keyA otherwise. + const baseLengthA = keyA.includes('*') ? keyA.indexOf('*') + 1 : keyA.length; + // Let baseLengthB be the index of "*" in keyB plus one, if keyB contains "*", or the length of keyB otherwise. + const baseLengthB = keyB.includes('*') ? keyB.indexOf('*') + 1 : keyB.length; + // if baseLengthA is greater, return -1, if lower 1 + const rval = baseLengthB - baseLengthA; + if (rval !== 0) + return rval; + // If keyA does not contain "*", return 1. + if (!keyA.includes('*')) + return 1; + // If keyB does not contain "*", return -1. + if (!keyB.includes('*')) + return -1; + // If the length of keyA is greater than the length of keyB, return -1. + // If the length of keyB is greater than the length of keyA, return 1. + // Else Return 0. + return keyB.length - keyA.length; +} +async function resolvePackageImportsExports(context, { matchKey, matchObj, isImports }) { + // If matchKey is a key of matchObj and does not contain "*", then + if (!matchKey.includes('*') && matchKey in matchObj) { + // Let target be the value of matchObj[matchKey]. + const target = matchObj[matchKey]; + // Return the result of PACKAGE_TARGET_RESOLVE(packageURL, target, null, isImports, conditions). + const resolved = await resolvePackageTarget(context, { target, patternMatch: '', isImports }); + return resolved; + } + // Let expansionKeys be the list of keys of matchObj containing only a single "*" + const expansionKeys = Object.keys(matchObj) + // Assert: ends with "/" or contains only a single "*". + .filter((k) => k.endsWith('/') || k.includes('*')) + // sorted by the sorting function PATTERN_KEY_COMPARE which orders in descending order of specificity. + .sort(nodePatternKeyCompare); + // For each key expansionKey in expansionKeys, do + for (const expansionKey of expansionKeys) { + const indexOfAsterisk = expansionKey.indexOf('*'); + // Let patternBase be the substring of expansionKey up to but excluding the first "*" character. + const patternBase = indexOfAsterisk === -1 ? expansionKey : expansionKey.substring(0, indexOfAsterisk); + // If matchKey starts with but is not equal to patternBase, then + if (matchKey.startsWith(patternBase) && matchKey !== patternBase) { + // Let patternTrailer be the substring of expansionKey from the index after the first "*" character. + const patternTrailer = indexOfAsterisk !== -1 ? expansionKey.substring(indexOfAsterisk + 1) : ''; + // If patternTrailer has zero length, + if (patternTrailer.length === 0 || + // or if matchKey ends with patternTrailer and the length of matchKey is greater than or equal to the length of expansionKey, then + matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length) { + // Let target be the value of matchObj[expansionKey]. + const target = matchObj[expansionKey]; + // Let patternMatch be the substring of matchKey starting at the index of the length of patternBase up to the length + // of matchKey minus the length of patternTrailer. + const patternMatch = matchKey.substring(patternBase.length, matchKey.length - patternTrailer.length); + // Return the result of PACKAGE_TARGET_RESOLVE + const resolved = await resolvePackageTarget(context, { + target, + patternMatch, + isImports + }); + return resolved; + } + } + } + throw new InvalidModuleSpecifierError(context, isImports); +} + +/** + * Implementation of PACKAGE_EXPORTS_RESOLVE + */ +async function resolvePackageExports(context, subpath, exports) { + // If exports is an Object with both a key starting with "." and a key not starting with "." + if (isMixedExports(exports)) { + // throw an Invalid Package Configuration error. + throw new InvalidConfigurationError(context, 'All keys must either start with ./, or without one.'); + } + // If subpath is equal to ".", then + if (subpath === '.') { + // Let mainExport be undefined. + let mainExport; + // If exports is a String or Array, or an Object containing no keys starting with ".", then + if (typeof exports === 'string' || Array.isArray(exports) || isConditions(exports)) { + // Set mainExport to exports + mainExport = exports; + // Otherwise if exports is an Object containing a "." property, then + } else + if (isMappings(exports)) { + // Set mainExport to exports["."] + mainExport = exports['.']; + } + // If mainExport is not undefined, then + if (mainExport) { + // Let resolved be the result of PACKAGE_TARGET_RESOLVE with target = mainExport + const resolved = await resolvePackageTarget(context, { + target: mainExport, + patternMatch: '', + isImports: false + }); + // If resolved is not null or undefined, return resolved. + if (resolved) { + return resolved; + } + } + // Otherwise, if exports is an Object and all keys of exports start with ".", then + } else + if (isMappings(exports)) { + // Let resolved be the result of PACKAGE_IMPORTS_EXPORTS_RESOLVE + const resolvedMatch = await resolvePackageImportsExports(context, { + matchKey: subpath, + matchObj: exports, + isImports: false + }); + // If resolved is not null or undefined, return resolved. + if (resolvedMatch) { + return resolvedMatch; + } + } + // Throw a Package Path Not Exported error. + throw new InvalidModuleSpecifierError(context); +} + +async function resolvePackageImports({ importSpecifier, importer, moduleDirs, conditions, resolveId }) { + const result = await findPackageJson(importer, moduleDirs); + if (!result) { + throw new Error(`${createBaseErrorMsg(importSpecifier, importer)}. Could not find a parent package.json.`); + } + const { pkgPath, pkgJsonPath, pkgJson } = result; + const pkgURL = url.pathToFileURL(`${pkgPath}/`); + const context = { + importer, + importSpecifier, + moduleDirs, + pkgURL, + pkgJsonPath, + conditions, + resolveId + }; + // Assert: specifier begins with "#". + if (!importSpecifier.startsWith('#')) { + throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.'); + } + // If specifier is exactly equal to "#" or starts with "#/", then + if (importSpecifier === '#' || importSpecifier.startsWith('#/')) { + // Throw an Invalid Module Specifier error. + throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.'); + } + const { imports } = pkgJson; + if (!imports) { + throw new InvalidModuleSpecifierError(context, true); + } + // Let packageURL be the result of LOOKUP_PACKAGE_SCOPE(parentURL). + // If packageURL is not null, then + return resolvePackageImportsExports(context, { + matchKey: importSpecifier, + matchObj: imports, + isImports: true + }); +} + +const resolveImportPath = util.promisify(resolve); +const readFile = util.promisify(fs.readFile); + +async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectories) { + if (importer) { + const selfPackageJsonResult = await findPackageJson(importer, moduleDirectories); + if (selfPackageJsonResult && selfPackageJsonResult.pkgJson.name === pkgName) { + // the referenced package name is the current package + return selfPackageJsonResult; + } + } + + try { + const pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions); + const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8')); + return { pkgJsonPath, pkgJson, pkgPath: path.dirname(pkgJsonPath) }; + } catch (_) { + return null; + } +} + +async function resolveIdClassic({ + importSpecifier, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot +}) { + let hasModuleSideEffects = () => null; + let hasPackageEntry = true; + let packageBrowserField = false; + let packageInfo; + + const filter = (pkg, pkgPath) => { + const info = getPackageInfo({ + cache: packageInfoCache, + extensions, + pkg, + pkgPath, + mainFields, + preserveSymlinks, + useBrowserOverrides, + rootDir, + ignoreSideEffectsForRoot + }); + + ({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info); + + return info.cachedPkg; + }; + + const resolveOptions = { + basedir: baseDir, + readFile: readCachedFile, + isFile: isFileCached, + isDirectory: isDirCached, + extensions, + includeCoreModules: false, + moduleDirectory: moduleDirectories, + paths: modulePaths, + preserveSymlinks, + packageFilter: filter + }; + + let location; + try { + location = await resolveImportPath(importSpecifier, resolveOptions); + } catch (error) { + if (error.code !== 'MODULE_NOT_FOUND') { + throw error; + } + return null; + } + + return { + location: preserveSymlinks ? location : await resolveSymlink(location), + hasModuleSideEffects, + hasPackageEntry, + packageBrowserField, + packageInfo + }; +} + +async function resolveWithExportMap({ + importer, + importSpecifier, + exportConditions, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot, + allowExportsFolderMapping +}) { + if (importSpecifier.startsWith('#')) { + // this is a package internal import, resolve using package imports field + const resolveResult = await resolvePackageImports({ + importSpecifier, + importer, + moduleDirs: moduleDirectories, + conditions: exportConditions, + resolveId(id /* , parent*/) { + return resolveIdClassic({ + importSpecifier: id, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths + }); + } + }); + + const location = url.fileURLToPath(resolveResult); + return { + location: preserveSymlinks ? location : await resolveSymlink(location), + hasModuleSideEffects: () => null, + hasPackageEntry: true, + packageBrowserField: false, + // eslint-disable-next-line no-undefined + packageInfo: undefined + }; + } + + const pkgName = getPackageName(importSpecifier); + if (pkgName) { + // it's a bare import, find the package.json and resolve using package exports if available + let hasModuleSideEffects = () => null; + let hasPackageEntry = true; + let packageBrowserField = false; + let packageInfo; + + const filter = (pkg, pkgPath) => { + const info = getPackageInfo({ + cache: packageInfoCache, + extensions, + pkg, + pkgPath, + mainFields, + preserveSymlinks, + useBrowserOverrides, + rootDir, + ignoreSideEffectsForRoot + }); + + ({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info); + + return info.cachedPkg; + }; + + const resolveOptions = { + basedir: baseDir, + readFile: readCachedFile, + isFile: isFileCached, + isDirectory: isDirCached, + extensions, + includeCoreModules: false, + moduleDirectory: moduleDirectories, + paths: modulePaths, + preserveSymlinks, + packageFilter: filter + }; + + const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories); + + if (result && result.pkgJson.exports) { + const { pkgJson, pkgJsonPath } = result; + const subpath = + pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`; + const pkgDr = pkgJsonPath.replace('package.json', ''); + const pkgURL = url.pathToFileURL(pkgDr); + + const context = { + importer, + importSpecifier, + moduleDirs: moduleDirectories, + pkgURL, + pkgJsonPath, + allowExportsFolderMapping, + conditions: exportConditions + }; + const resolvedPackageExport = await resolvePackageExports(context, subpath, pkgJson.exports); + const location = url.fileURLToPath(resolvedPackageExport); + if (location) { + return { + location: preserveSymlinks ? location : await resolveSymlink(location), + hasModuleSideEffects, + hasPackageEntry, + packageBrowserField, + packageInfo + }; + } + } + } + + return null; +} + +async function resolveWithClassic({ + importer, + importSpecifierList, + exportConditions, + warn, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot +}) { + for (let i = 0; i < importSpecifierList.length; i++) { + // eslint-disable-next-line no-await-in-loop + const result = await resolveIdClassic({ + importer, + importSpecifier: importSpecifierList[i], + exportConditions, + warn, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot + }); + + if (result) { + return result; + } + } + + return null; +} + +// Resolves to the module if found or `null`. +// The first import specifier will first be attempted with the exports algorithm. +// If this is unsuccessful because export maps are not being used, then all of `importSpecifierList` +// will be tried with the classic resolution algorithm +async function resolveImportSpecifiers({ + importer, + importSpecifierList, + exportConditions, + warn, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot, + allowExportsFolderMapping +}) { + try { + const exportMapRes = await resolveWithExportMap({ + importer, + importSpecifier: importSpecifierList[0], + exportConditions, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot, + allowExportsFolderMapping + }); + if (exportMapRes) return exportMapRes; + } catch (error) { + if (error instanceof ResolveError) { + warn(error); + return null; + } + throw error; + } + + // package has no imports or exports, use classic node resolve + return resolveWithClassic({ + importer, + importSpecifierList, + exportConditions, + warn, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot + }); +} + +const versionRegexp = /\^(\d+\.\d+\.\d+)/g; + +function validateVersion(actualVersion, peerDependencyVersion) { + let minMajor = Infinity; + let minMinor = Infinity; + let minPatch = Infinity; + let foundVersion; + // eslint-disable-next-line no-cond-assign + while (foundVersion = versionRegexp.exec(peerDependencyVersion)) { + const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split('.').map(Number); + if (foundMajor < minMajor) { + minMajor = foundMajor; + minMinor = foundMinor; + minPatch = foundPatch; + } + } + if (!actualVersion) { + throw new Error( + `Insufficient Rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch}.` + ); + } + const [major, minor, patch] = actualVersion.split('.').map(Number); + if ( + major < minMajor || + major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) + { + throw new Error( + `Insufficient rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch} but found rollup@${actualVersion}.` + ); + } +} + +/* eslint-disable no-param-reassign, no-shadow, no-undefined */ + +const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js'; +const deepFreeze = (object) => { + Object.freeze(object); + + for (const value of Object.values(object)) { + if (typeof value === 'object' && !Object.isFrozen(value)) { + deepFreeze(value); + } + } + + return object; +}; + +const baseConditions = ['default', 'module']; +const baseConditionsEsm = [...baseConditions, 'import']; +const baseConditionsCjs = [...baseConditions, 'require']; +const defaults = { + dedupe: [], + // It's important that .mjs is listed before .js so that Rollup will interpret npm modules + // which deploy both ESM .mjs and CommonJS .js files as ESM. + extensions: ['.mjs', '.js', '.json', '.node'], + resolveOnly: [], + moduleDirectories: ['node_modules'], + ignoreSideEffectsForRoot: false, + // TODO: set to false in next major release or remove + allowExportsFolderMapping: true +}; +const DEFAULTS = deepFreeze(deepMerge({}, defaults)); + +function nodeResolve(opts = {}) { + const { warnings } = handleDeprecatedOptions(opts); + + const options = { ...defaults, ...opts }; + const { extensions, jail, moduleDirectories, modulePaths, ignoreSideEffectsForRoot } = options; + const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])]; + const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])]; + const packageInfoCache = new Map(); + const idToPackageInfo = new Map(); + const mainFields = getMainFields(options); + const useBrowserOverrides = mainFields.indexOf('browser') !== -1; + const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; + const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; + const rootDir = path.resolve(options.rootDir || process.cwd()); + let { dedupe } = options; + let rollupOptions; + + if (moduleDirectories.some((name) => name.includes('/'))) { + throw new Error( + '`moduleDirectories` option must only contain directory names. If you want to load modules from somewhere not supported by the default module resolution algorithm, see `modulePaths`.' + ); + } + + if (typeof dedupe !== 'function') { + dedupe = (importee) => + options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee)); + } + + // creates a function from the patterns to test if a particular module should be bundled. + const allowPatterns = (patterns) => { + const regexPatterns = patterns.map((pattern) => { + if (pattern instanceof RegExp) { + return pattern; + } + const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); + return new RegExp(`^${normalized}$`); + }); + return (id) => !regexPatterns.length || regexPatterns.some((pattern) => pattern.test(id)); + }; + + const resolveOnly = + typeof options.resolveOnly === 'function' ? + options.resolveOnly : + allowPatterns(options.resolveOnly); + + const browserMapCache = new Map(); + let preserveSymlinks; + + const resolveLikeNode = async (context, importee, importer, custom) => { + // strip query params from import + const [importPath, params] = importee.split('?'); + const importSuffix = `${params ? `?${params}` : ''}`; + importee = importPath; + + const baseDir = !importer || dedupe(importee) ? rootDir : path.dirname(importer); + + // https://github.com/defunctzombie/package-browser-field-spec + const browser = browserMapCache.get(importer); + if (useBrowserOverrides && browser) { + const resolvedImportee = path.resolve(baseDir, importee); + if (browser[importee] === false || browser[resolvedImportee] === false) { + return { id: ES6_BROWSER_EMPTY }; + } + const browserImportee = + importee[0] !== '.' && browser[importee] || + browser[resolvedImportee] || + browser[`${resolvedImportee}.js`] || + browser[`${resolvedImportee}.json`]; + if (browserImportee) { + importee = browserImportee; + } + } + + const parts = importee.split(/[/\\]/); + let id = parts.shift(); + let isRelativeImport = false; + + if (id[0] === '@' && parts.length > 0) { + // scoped packages + id += `/${parts.shift()}`; + } else if (id[0] === '.') { + // an import relative to the parent dir of the importer + id = path.resolve(baseDir, importee); + isRelativeImport = true; + } + + // if it's not a relative import, and it's not requested, reject it. + if (!isRelativeImport && !resolveOnly(id)) { + if (normalizeInput(rollupOptions.input).includes(importee)) { + return null; + } + return false; + } + + const importSpecifierList = [importee]; + + if (importer === undefined && !importee[0].match(/^\.?\.?\//)) { + // For module graph roots (i.e. when importer is undefined), we + // need to handle 'path fragments` like `foo/bar` that are commonly + // found in rollup config files. If importee doesn't look like a + // relative or absolute path, we make it relative and attempt to + // resolve it. + importSpecifierList.push(`./${importee}`); + } + + // TypeScript files may import '.mjs' or '.cjs' to refer to either '.mts' or '.cts'. + // They may also import .js to refer to either .ts or .tsx, and .jsx to refer to .tsx. + if (importer && /\.(ts|mts|cts|tsx)$/.test(importer)) { + for (const [importeeExt, resolvedExt] of [ + ['.js', '.ts'], + ['.js', '.tsx'], + ['.jsx', '.tsx'], + ['.mjs', '.mts'], + ['.cjs', '.cts']]) + { + if (importee.endsWith(importeeExt) && extensions.includes(resolvedExt)) { + importSpecifierList.push(importee.slice(0, -importeeExt.length) + resolvedExt); + } + } + } + + const warn = (...args) => context.warn(...args); + const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire; + const exportConditions = isRequire ? conditionsCjs : conditionsEsm; + + if (useBrowserOverrides && !exportConditions.includes('browser')) + exportConditions.push('browser'); + + const resolvedWithoutBuiltins = await resolveImportSpecifiers({ + importer, + importSpecifierList, + exportConditions, + warn, + packageInfoCache, + extensions, + mainFields, + preserveSymlinks, + useBrowserOverrides, + baseDir, + moduleDirectories, + modulePaths, + rootDir, + ignoreSideEffectsForRoot, + allowExportsFolderMapping: options.allowExportsFolderMapping + }); + + const importeeIsBuiltin = isBuiltinModule(importee); + const resolved = + importeeIsBuiltin && preferBuiltins ? + { + packageInfo: undefined, + hasModuleSideEffects: () => null, + hasPackageEntry: true, + packageBrowserField: false + } : + resolvedWithoutBuiltins; + if (!resolved) { + return null; + } + + const { packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = resolved; + let { location } = resolved; + if (packageBrowserField) { + if (Object.prototype.hasOwnProperty.call(packageBrowserField, location)) { + if (!packageBrowserField[location]) { + browserMapCache.set(location, packageBrowserField); + return { id: ES6_BROWSER_EMPTY }; + } + location = packageBrowserField[location]; + } + browserMapCache.set(location, packageBrowserField); + } + + if (hasPackageEntry && !preserveSymlinks) { + const exists = await fileExists(location); + if (exists) { + location = await realpath(location); + } + } + + idToPackageInfo.set(location, packageInfo); + + if (hasPackageEntry) { + if (importeeIsBuiltin && preferBuiltins) { + if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) { + context.warn( + `preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning` + ); + } + return false; + } else if (jail && location.indexOf(path.normalize(jail.trim(path.sep))) !== 0) { + return null; + } + } + + if (options.modulesOnly && (await fileExists(location))) { + const code = await readFile$1(location, 'utf-8'); + if (isModule(code)) { + return { + id: `${location}${importSuffix}`, + moduleSideEffects: hasModuleSideEffects(location) + }; + } + return null; + } + return { + id: `${location}${importSuffix}`, + moduleSideEffects: hasModuleSideEffects(location) + }; + }; + + return { + name: 'node-resolve', + + version, + + buildStart(buildOptions) { + validateVersion(this.meta.rollupVersion, peerDependencies.rollup); + rollupOptions = buildOptions; + + for (const warning of warnings) { + this.warn(warning); + } + + ({ preserveSymlinks } = buildOptions); + }, + + generateBundle() { + readCachedFile.clear(); + isFileCached.clear(); + isDirCached.clear(); + }, + + resolveId: { + order: 'post', + async handler(importee, importer, resolveOptions) { + if (importee === ES6_BROWSER_EMPTY) { + return importee; + } + // ignore IDs with null character, these belong to other plugins + if (/\0/.test(importee)) return null; + + const { custom = {} } = resolveOptions; + const { 'node-resolve': { resolved: alreadyResolved } = {} } = custom; + if (alreadyResolved) { + return alreadyResolved; + } + + if (/\0/.test(importer)) { + importer = undefined; + } + + const resolved = await resolveLikeNode(this, importee, importer, custom); + if (resolved) { + // This way, plugins may attach additional meta information to the + // resolved id or make it external. We do not skip node-resolve here + // because another plugin might again use `this.resolve` in its + // `resolveId` hook, in which case we want to add the correct + // `moduleSideEffects` information. + const resolvedResolved = await this.resolve(resolved.id, importer, { + ...resolveOptions, + custom: { ...custom, 'node-resolve': { ...custom['node-resolve'], resolved, importee } } + }); + if (resolvedResolved) { + // Handle plugins that manually make the result external + if (resolvedResolved.external) { + return false; + } + // Allow other plugins to take over resolution. Rollup core will not + // change the id if it corresponds to an existing file + if (resolvedResolved.id !== resolved.id) { + return resolvedResolved; + } + // Pass on meta information added by other plugins + return { ...resolved, meta: resolvedResolved.meta }; + } + } + return resolved; + } + }, + + load(importee) { + if (importee === ES6_BROWSER_EMPTY) { + return 'export default {};'; + } + return null; + }, + + getPackageInfoForId(id) { + return idToPackageInfo.get(id); + } + }; +} + +exports.DEFAULTS = DEFAULTS; +exports.default = nodeResolve; +exports.nodeResolve = nodeResolve; +module.exports = Object.assign(exports.default, exports); /* v7-9e82f109601f9f88 */ \ No newline at end of file diff --git a/node-jiti/cjs-index.js.f57bd5ab.js b/node-jiti/cjs-index.js.f57bd5ab.js new file mode 100644 index 0000000..aea20c1 --- /dev/null +++ b/node-jiti/cjs-index.js.f57bd5ab.js @@ -0,0 +1,2298 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var path = require('path'); +var pluginutils = require('@rollup/pluginutils'); +var fs = require('fs'); +var getCommonDir = require('commondir'); +var glob = require('glob'); +var estreeWalker = require('estree-walker'); +var MagicString = require('magic-string'); +var isReference = require('is-reference'); + +var version = "25.0.7"; +var peerDependencies = { + rollup: "^2.68.0||^3.0.0||^4.0.0" +}; + +function tryParse(parse, code, id) { + try { + return parse(code, { allowReturnOutsideFunction: true }); + } catch (err) { + err.message += ` in ${id}`; + throw err; + } +} + +const firstpassGlobal = /\b(?:require|module|exports|global)\b/; + +const firstpassNoGlobal = /\b(?:require|module|exports)\b/; + +function hasCjsKeywords(code, ignoreGlobal) { + const firstpass = ignoreGlobal ? firstpassNoGlobal : firstpassGlobal; + return firstpass.test(code); +} + +/* eslint-disable no-underscore-dangle */ + + +function analyzeTopLevelStatements(parse, code, id) { + const ast = tryParse(parse, code, id); + + let isEsModule = false; + let hasDefaultExport = false; + let hasNamedExports = false; + + for (const node of ast.body) { + switch (node.type) { + case 'ExportDefaultDeclaration': + isEsModule = true; + hasDefaultExport = true; + break; + case 'ExportNamedDeclaration': + isEsModule = true; + if (node.declaration) { + hasNamedExports = true; + } else { + for (const specifier of node.specifiers) { + if (specifier.exported.name === 'default') { + hasDefaultExport = true; + } else { + hasNamedExports = true; + } + } + } + break; + case 'ExportAllDeclaration': + isEsModule = true; + if (node.exported && node.exported.name === 'default') { + hasDefaultExport = true; + } else { + hasNamedExports = true; + } + break; + case 'ImportDeclaration': + isEsModule = true; + break; + } + } + + return { isEsModule, hasDefaultExport, hasNamedExports, ast }; +} + +/* eslint-disable import/prefer-default-export */ + + +function deconflict(scopes, globals, identifier) { + let i = 1; + let deconflicted = pluginutils.makeLegalIdentifier(identifier); + const hasConflicts = () => + scopes.some((scope) => scope.contains(deconflicted)) || globals.has(deconflicted); + + while (hasConflicts()) { + deconflicted = pluginutils.makeLegalIdentifier(`${identifier}_${i}`); + i += 1; + } + + for (const scope of scopes) { + scope.declarations[deconflicted] = true; + } + + return deconflicted; +} + +function getName(id) { + const name = pluginutils.makeLegalIdentifier(path.basename(id, path.extname(id))); + if (name !== 'index') { + return name; + } + return pluginutils.makeLegalIdentifier(path.basename(path.dirname(id))); +} + +function normalizePathSlashes(path) { + return path.replace(/\\/g, '/'); +} + +const getVirtualPathForDynamicRequirePath = (path$1, commonDir) => +`/${normalizePathSlashes(path.relative(commonDir, path$1))}`; + +function capitalize(name) { + return name[0].toUpperCase() + name.slice(1); +} + +function getStrictRequiresFilter({ strictRequires }) { + switch (strictRequires) { + case true: + return { strictRequiresFilter: () => true, detectCyclesAndConditional: false }; + // eslint-disable-next-line no-undefined + case undefined: + case 'auto': + case 'debug': + case null: + return { strictRequiresFilter: () => false, detectCyclesAndConditional: true }; + case false: + return { strictRequiresFilter: () => false, detectCyclesAndConditional: false }; + default: + if (typeof strictRequires === 'string' || Array.isArray(strictRequires)) { + return { + strictRequiresFilter: pluginutils.createFilter(strictRequires), + detectCyclesAndConditional: false + }; + } + throw new Error('Unexpected value for "strictRequires" option.'); + } +} + +function getPackageEntryPoint(dirPath) { + let entryPoint = 'index.js'; + + try { + if (fs.existsSync(path.join(dirPath, 'package.json'))) { + entryPoint = + JSON.parse(fs.readFileSync(path.join(dirPath, 'package.json'), { encoding: 'utf8' })).main || + entryPoint; + } + } catch (ignored) { + + // ignored + } + return entryPoint; +} + +function isDirectory(path) { + try { + if (fs.statSync(path).isDirectory()) return true; + } catch (ignored) { + + // Nothing to do here + }return false; +} + +function getDynamicRequireModules(patterns, dynamicRequireRoot) { + const dynamicRequireModules = new Map(); + const dirNames = new Set(); + for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) { + const isNegated = pattern.startsWith('!'); + const modifyMap = (targetPath, resolvedPath) => + isNegated ? + dynamicRequireModules.delete(targetPath) : + dynamicRequireModules.set(targetPath, resolvedPath); + for (const path$1 of glob.sync(isNegated ? pattern.substr(1) : pattern)) { + const resolvedPath = path.resolve(path$1); + const requirePath = normalizePathSlashes(resolvedPath); + if (isDirectory(resolvedPath)) { + dirNames.add(resolvedPath); + const modulePath = path.resolve(path.join(resolvedPath, getPackageEntryPoint(path$1))); + modifyMap(requirePath, modulePath); + modifyMap(normalizePathSlashes(modulePath), modulePath); + } else { + dirNames.add(path.dirname(resolvedPath)); + modifyMap(requirePath, resolvedPath); + } + } + } + return { + commonDir: dirNames.size ? getCommonDir([...dirNames, dynamicRequireRoot]) : null, + dynamicRequireModules + }; +} + +const FAILED_REQUIRE_ERROR = `throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');`; + +const COMMONJS_REQUIRE_EXPORT = 'commonjsRequire'; +const CREATE_COMMONJS_REQUIRE_EXPORT = 'createCommonjsRequire'; + +function getDynamicModuleRegistry( +isDynamicRequireModulesEnabled, +dynamicRequireModules, +commonDir, +ignoreDynamicRequires) +{ + if (!isDynamicRequireModulesEnabled) { + return `export function ${COMMONJS_REQUIRE_EXPORT}(path) { + ${FAILED_REQUIRE_ERROR} +}`; + } + const dynamicModuleImports = [...dynamicRequireModules.values()]. + map( + (id, index) => + `import ${ + id.endsWith('.json') ? `json${index}` : `{ __require as require${index} }` + } from ${JSON.stringify(id)};` + ). + join('\n'); + const dynamicModuleProps = [...dynamicRequireModules.keys()]. + map( + (id, index) => + `\t\t${JSON.stringify(getVirtualPathForDynamicRequirePath(id, commonDir))}: ${ + id.endsWith('.json') ? `function () { return json${index}; }` : `require${index}` + }` + ). + join(',\n'); + return `${dynamicModuleImports} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { +${dynamicModuleProps} + }); +} + +export function ${CREATE_COMMONJS_REQUIRE_EXPORT}(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + ${ignoreDynamicRequires ? 'return require(path);' : FAILED_REQUIRE_ERROR} + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + } + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +}`; +} + +const isWrappedId = (id, suffix) => id.endsWith(suffix); +const wrapId = (id, suffix) => `\0${id}${suffix}`; +const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length); + +const PROXY_SUFFIX = '?commonjs-proxy'; +const WRAPPED_SUFFIX = '?commonjs-wrapped'; +const EXTERNAL_SUFFIX = '?commonjs-external'; +const EXPORTS_SUFFIX = '?commonjs-exports'; +const MODULE_SUFFIX = '?commonjs-module'; +const ENTRY_SUFFIX = '?commonjs-entry'; +const ES_IMPORT_SUFFIX = '?commonjs-es-import'; + +const DYNAMIC_MODULES_ID = '\0commonjs-dynamic-modules'; +const HELPERS_ID = '\0commonjsHelpers.js'; + +const IS_WRAPPED_COMMONJS = 'withRequireFunction'; + +// `x['default']` is used instead of `x.default` for backward compatibility with ES3 browsers. +// Minifiers like uglify will usually transpile it back if compatibility with ES3 is not enabled. +// This could be improved by inspecting Rollup's "generatedCode" option + +const HELPERS = ` +export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +export function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +export function getDefaultExportFromNamespaceIfPresent (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n; +} + +export function getDefaultExportFromNamespaceIfNotNamed (n) { + return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; +} + +export function getAugmentedNamespace(n) { + if (n.__esModule) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + if (this instanceof a) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} +`; + +function getHelpersModule() { + return HELPERS; +} + +function getUnknownRequireProxy(id, requireReturnsDefault) { + if (requireReturnsDefault === true || id.endsWith('.json')) { + return `export { default } from ${JSON.stringify(id)};`; + } + const name = getName(id); + const exported = + requireReturnsDefault === 'auto' ? + `import { getDefaultExportFromNamespaceIfNotNamed } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(${name});` : + requireReturnsDefault === 'preferred' ? + `import { getDefaultExportFromNamespaceIfPresent } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(${name});` : + !requireReturnsDefault ? + `import { getAugmentedNamespace } from "${HELPERS_ID}"; export default /*@__PURE__*/getAugmentedNamespace(${name});` : + `export default ${name};`; + return `import * as ${name} from ${JSON.stringify(id)}; ${exported}`; +} + +async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) { + const name = getName(id); + const { + meta: { commonjs: commonjsMeta } + } = await loadModule({ id }); + if (!commonjsMeta) { + return getUnknownRequireProxy(id, requireReturnsDefault); + } + if (commonjsMeta.isCommonJS) { + return `export { __moduleExports as default } from ${JSON.stringify(id)};`; + } + if (!requireReturnsDefault) { + return `import { getAugmentedNamespace } from "${HELPERS_ID}"; import * as ${name} from ${JSON.stringify( + id + )}; export default /*@__PURE__*/getAugmentedNamespace(${name});`; + } + if ( + requireReturnsDefault !== true && ( + requireReturnsDefault === 'namespace' || + !commonjsMeta.hasDefaultExport || + requireReturnsDefault === 'auto' && commonjsMeta.hasNamedExports)) + { + return `import * as ${name} from ${JSON.stringify(id)}; export default ${name};`; + } + return `export { default } from ${JSON.stringify(id)};`; +} + +function getEntryProxy(id, defaultIsModuleExports, getModuleInfo, shebang) { + const { + meta: { commonjs: commonjsMeta }, + hasDefaultExport + } = getModuleInfo(id); + if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) { + const stringifiedId = JSON.stringify(id); + let code = `export * from ${stringifiedId};`; + if (hasDefaultExport) { + code += `export { default } from ${stringifiedId};`; + } + return shebang + code; + } + const result = getEsImportProxy(id, defaultIsModuleExports); + return { + ...result, + code: shebang + result.code + }; +} + +function getEsImportProxy(id, defaultIsModuleExports) { + const name = getName(id); + const exportsName = `${name}Exports`; + const requireModule = `require${capitalize(name)}`; + let code = + `import { getDefaultExportFromCjs } from "${HELPERS_ID}";\n` + + `import { __require as ${requireModule} } from ${JSON.stringify(id)};\n` + + `var ${exportsName} = ${requireModule}();\n` + + `export { ${exportsName} as __moduleExports };`; + if (defaultIsModuleExports === true) { + code += `\nexport { ${exportsName} as default };`; + } else { + code += `export default /*@__PURE__*/getDefaultExportFromCjs(${exportsName});`; + } + return { + code, + syntheticNamedExports: '__moduleExports' + }; +} + +/* eslint-disable no-param-reassign, no-undefined */ + + +function getCandidatesForExtension(resolved, extension) { + return [resolved + extension, `${resolved}${path.sep}index${extension}`]; +} + +function getCandidates(resolved, extensions) { + return extensions.reduce( + (paths, extension) => paths.concat(getCandidatesForExtension(resolved, extension)), + [resolved] + ); +} + +function resolveExtensions(importee, importer, extensions) { + // not our problem + if (importee[0] !== '.' || !importer) return undefined; + + const resolved = path.resolve(path.dirname(importer), importee); + const candidates = getCandidates(resolved, extensions); + + for (let i = 0; i < candidates.length; i += 1) { + try { + const stats = fs.statSync(candidates[i]); + if (stats.isFile()) return { id: candidates[i] }; + } catch (err) { + + /* noop */} + } + + return undefined; +} + +function getResolveId(extensions, isPossibleCjsId) { + const currentlyResolving = new Map(); + + return { + /** + * This is a Maps of importers to Sets of require sources being resolved at + * the moment by resolveRequireSourcesAndUpdateMeta + */ + currentlyResolving, + async resolveId(importee, importer, resolveOptions) { + const customOptions = resolveOptions.custom; + // All logic below is specific to ES imports. + // Also, if we do not skip this logic for requires that are resolved while + // transforming a commonjs file, it can easily lead to deadlocks. + if ( + customOptions && + customOptions['node-resolve'] && + customOptions['node-resolve'].isRequire) + { + return null; + } + const currentlyResolvingForParent = currentlyResolving.get(importer); + if (currentlyResolvingForParent && currentlyResolvingForParent.has(importee)) { + this.warn({ + code: 'THIS_RESOLVE_WITHOUT_OPTIONS', + message: + 'It appears a plugin has implemented a "resolveId" hook that uses "this.resolve" without forwarding the third "options" parameter of "resolveId". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.', + url: 'https://rollupjs.org/guide/en/#resolveid' + }); + return null; + } + + if (isWrappedId(importee, WRAPPED_SUFFIX)) { + return unwrapId(importee, WRAPPED_SUFFIX); + } + + if ( + importee.endsWith(ENTRY_SUFFIX) || + isWrappedId(importee, MODULE_SUFFIX) || + isWrappedId(importee, EXPORTS_SUFFIX) || + isWrappedId(importee, PROXY_SUFFIX) || + isWrappedId(importee, ES_IMPORT_SUFFIX) || + isWrappedId(importee, EXTERNAL_SUFFIX) || + importee.startsWith(HELPERS_ID) || + importee === DYNAMIC_MODULES_ID) + { + return importee; + } + + if (importer) { + if ( + importer === DYNAMIC_MODULES_ID || + // Proxies are only importing resolved ids, no need to resolve again + isWrappedId(importer, PROXY_SUFFIX) || + isWrappedId(importer, ES_IMPORT_SUFFIX) || + importer.endsWith(ENTRY_SUFFIX)) + { + return importee; + } + if (isWrappedId(importer, EXTERNAL_SUFFIX)) { + // We need to return null for unresolved imports so that the proper warning is shown + if ( + !(await this.resolve( + importee, + importer, + Object.assign({ skipSelf: true }, resolveOptions) + ))) + { + return null; + } + // For other external imports, we need to make sure they are handled as external + return { id: importee, external: true }; + } + } + + if (importee.startsWith('\0')) { + return null; + } + + // If this is an entry point or ESM import, we need to figure out if the importee is wrapped and + // if that is the case, we need to add a proxy. + const resolved = + (await this.resolve( + importee, + importer, + Object.assign({ skipSelf: true }, resolveOptions) + )) || resolveExtensions(importee, importer, extensions); + // Make sure that even if other plugins resolve again, we ignore our own proxies + if ( + !resolved || + resolved.external || + resolved.id.endsWith(ENTRY_SUFFIX) || + isWrappedId(resolved.id, ES_IMPORT_SUFFIX) || + !isPossibleCjsId(resolved.id)) + { + return resolved; + } + const moduleInfo = await this.load(resolved); + const { + meta: { commonjs: commonjsMeta } + } = moduleInfo; + if (commonjsMeta) { + const { isCommonJS } = commonjsMeta; + if (isCommonJS) { + if (resolveOptions.isEntry) { + moduleInfo.moduleSideEffects = true; + // We must not precede entry proxies with a `\0` as that will mess up relative external resolution + return resolved.id + ENTRY_SUFFIX; + } + if (isCommonJS === IS_WRAPPED_COMMONJS) { + return { id: wrapId(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } }; + } + } + } + return resolved; + } + }; +} + +function getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving) { + const knownCjsModuleTypes = Object.create(null); + const requiredIds = Object.create(null); + const unconditionallyRequiredIds = Object.create(null); + const dependencies = Object.create(null); + const getDependencies = (id) => dependencies[id] || (dependencies[id] = new Set()); + + const isCyclic = (id) => { + const dependenciesToCheck = new Set(getDependencies(id)); + for (const dependency of dependenciesToCheck) { + if (dependency === id) { + return true; + } + for (const childDependency of getDependencies(dependency)) { + dependenciesToCheck.add(childDependency); + } + } + return false; + }; + + // Once a module is listed here, its type (wrapped or not) is fixed and may + // not change for the rest of the current build, to not break already + // transformed modules. + const fullyAnalyzedModules = Object.create(null); + + const getTypeForFullyAnalyzedModule = (id) => { + const knownType = knownCjsModuleTypes[id]; + if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) { + return knownType; + } + if (isCyclic(id)) { + return knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS; + } + return knownType; + }; + + const setInitialParentType = (id, initialCommonJSType) => { + // Fully analyzed modules may never change type + if (fullyAnalyzedModules[id]) { + return; + } + knownCjsModuleTypes[id] = initialCommonJSType; + if ( + detectCyclesAndConditional && + knownCjsModuleTypes[id] === true && + requiredIds[id] && + !unconditionallyRequiredIds[id]) + { + knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS; + } + }; + + const analyzeRequiredModule = async (parentId, resolved, isConditional, loadModule) => { + const childId = resolved.id; + requiredIds[childId] = true; + if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) { + unconditionallyRequiredIds[childId] = true; + } + + getDependencies(parentId).add(childId); + if (!isCyclic(childId)) { + // This makes sure the current transform handler waits for all direct + // dependencies to be loaded and transformed and therefore for all + // transitive CommonJS dependencies to be loaded as well so that all + // cycles have been found and knownCjsModuleTypes is reliable. + await loadModule(resolved); + } + }; + + const getTypeForImportedModule = async (resolved, loadModule) => { + if (resolved.id in knownCjsModuleTypes) { + // This handles cyclic ES dependencies + return knownCjsModuleTypes[resolved.id]; + } + const { + meta: { commonjs } + } = await loadModule(resolved); + return commonjs && commonjs.isCommonJS || false; + }; + + return { + getWrappedIds: () => + Object.keys(knownCjsModuleTypes).filter( + (id) => knownCjsModuleTypes[id] === IS_WRAPPED_COMMONJS + ), + isRequiredId: (id) => requiredIds[id], + async shouldTransformCachedModule({ + id: parentId, + resolvedSources, + meta: { commonjs: parentMeta } + }) { + // We explicitly track ES modules to handle circular imports + if (!(parentMeta && parentMeta.isCommonJS)) knownCjsModuleTypes[parentId] = false; + if (isWrappedId(parentId, ES_IMPORT_SUFFIX)) return false; + const parentRequires = parentMeta && parentMeta.requires; + if (parentRequires) { + setInitialParentType(parentId, parentMeta.initialCommonJSType); + await Promise.all( + parentRequires.map(({ resolved, isConditional }) => + analyzeRequiredModule(parentId, resolved, isConditional, this.load) + ) + ); + if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) { + return true; + } + for (const { + resolved: { id } + } of parentRequires) { + if (getTypeForFullyAnalyzedModule(id) !== parentMeta.isRequiredCommonJS[id]) { + return true; + } + } + // Now that we decided to go with the cached copy, neither the parent + // module nor any of its children may change types anymore + fullyAnalyzedModules[parentId] = true; + for (const { + resolved: { id } + } of parentRequires) { + fullyAnalyzedModules[id] = true; + } + } + const parentRequireSet = new Set((parentRequires || []).map(({ resolved: { id } }) => id)); + return ( + await Promise.all( + Object.keys(resolvedSources). + map((source) => resolvedSources[source]). + filter(({ id, external }) => !(external || parentRequireSet.has(id))). + map(async (resolved) => { + if (isWrappedId(resolved.id, ES_IMPORT_SUFFIX)) { + return ( + (await getTypeForImportedModule( + ( + await this.load({ id: resolved.id })). + meta.commonjs.resolved, + this.load + )) !== IS_WRAPPED_COMMONJS); + + } + return (await getTypeForImportedModule(resolved, this.load)) === IS_WRAPPED_COMMONJS; + }) + )). + some((shouldTransform) => shouldTransform); + }, + /* eslint-disable no-param-reassign */ + resolveRequireSourcesAndUpdateMeta: + (rollupContext) => async (parentId, isParentCommonJS, parentMeta, sources) => { + parentMeta.initialCommonJSType = isParentCommonJS; + parentMeta.requires = []; + parentMeta.isRequiredCommonJS = Object.create(null); + setInitialParentType(parentId, isParentCommonJS); + const currentlyResolvingForParent = currentlyResolving.get(parentId) || new Set(); + currentlyResolving.set(parentId, currentlyResolvingForParent); + const requireTargets = await Promise.all( + sources.map(async ({ source, isConditional }) => { + // Never analyze or proxy internal modules + if (source.startsWith('\0')) { + return { id: source, allowProxy: false }; + } + currentlyResolvingForParent.add(source); + const resolved = + (await rollupContext.resolve(source, parentId, { + skipSelf: false, + custom: { 'node-resolve': { isRequire: true } } + })) || resolveExtensions(source, parentId, extensions); + currentlyResolvingForParent.delete(source); + if (!resolved) { + return { id: wrapId(source, EXTERNAL_SUFFIX), allowProxy: false }; + } + const childId = resolved.id; + if (resolved.external) { + return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false }; + } + parentMeta.requires.push({ resolved, isConditional }); + await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load); + return { id: childId, allowProxy: true }; + }) + ); + parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId); + fullyAnalyzedModules[parentId] = true; + return requireTargets.map(({ id: dependencyId, allowProxy }, index) => { + // eslint-disable-next-line no-multi-assign + const isCommonJS = parentMeta.isRequiredCommonJS[dependencyId] = + getTypeForFullyAnalyzedModule(dependencyId); + fullyAnalyzedModules[dependencyId] = true; + return { + source: sources[index].source, + id: allowProxy ? + isCommonJS === IS_WRAPPED_COMMONJS ? + wrapId(dependencyId, WRAPPED_SUFFIX) : + wrapId(dependencyId, PROXY_SUFFIX) : + dependencyId, + isCommonJS + }; + }); + }, + isCurrentlyResolving(source, parentId) { + const currentlyResolvingForParent = currentlyResolving.get(parentId); + return currentlyResolvingForParent && currentlyResolvingForParent.has(source); + } + }; +} + +function validateVersion(actualVersion, peerDependencyVersion, name) { + const versionRegexp = /\^(\d+\.\d+\.\d+)/g; + let minMajor = Infinity; + let minMinor = Infinity; + let minPatch = Infinity; + let foundVersion; + // eslint-disable-next-line no-cond-assign + while (foundVersion = versionRegexp.exec(peerDependencyVersion)) { + const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split('.').map(Number); + if (foundMajor < minMajor) { + minMajor = foundMajor; + minMinor = foundMinor; + minPatch = foundPatch; + } + } + if (!actualVersion) { + throw new Error( + `Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch}.` + ); + } + const [major, minor, patch] = actualVersion.split('.').map(Number); + if ( + major < minMajor || + major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) + { + throw new Error( + `Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch} but found ${name}@${actualVersion}.` + ); + } +} + +const operators = { + '==': (x) => equals(x.left, x.right, false), + + '!=': (x) => not(operators['=='](x)), + + '===': (x) => equals(x.left, x.right, true), + + '!==': (x) => not(operators['==='](x)), + + '!': (x) => isFalsy(x.argument), + + '&&': (x) => isTruthy(x.left) && isTruthy(x.right), + + '||': (x) => isTruthy(x.left) || isTruthy(x.right) +}; + +function not(value) { + return value === null ? value : !value; +} + +function equals(a, b, strict) { + if (a.type !== b.type) return null; + // eslint-disable-next-line eqeqeq + if (a.type === 'Literal') return strict ? a.value === b.value : a.value == b.value; + return null; +} + +function isTruthy(node) { + if (!node) return false; + if (node.type === 'Literal') return !!node.value; + if (node.type === 'ParenthesizedExpression') return isTruthy(node.expression); + if (node.operator in operators) return operators[node.operator](node); + return null; +} + +function isFalsy(node) { + return not(isTruthy(node)); +} + +function getKeypath(node) { + const parts = []; + + while (node.type === 'MemberExpression') { + if (node.computed) return null; + + parts.unshift(node.property.name); + // eslint-disable-next-line no-param-reassign + node = node.object; + } + + if (node.type !== 'Identifier') return null; + + const { name } = node; + parts.unshift(name); + + return { name, keypath: parts.join('.') }; +} + +const KEY_COMPILED_ESM = '__esModule'; + +function getDefineCompiledEsmType(node) { + const definedPropertyWithExports = getDefinePropertyCallName(node, 'exports'); + const definedProperty = + definedPropertyWithExports || getDefinePropertyCallName(node, 'module.exports'); + if (definedProperty && definedProperty.key === KEY_COMPILED_ESM) { + return isTruthy(definedProperty.value) ? + definedPropertyWithExports ? + 'exports' : + 'module' : + false; + } + return false; +} + +function getDefinePropertyCallName(node, targetName) { + const { + callee: { object, property } + } = node; + if (!object || object.type !== 'Identifier' || object.name !== 'Object') return; + if (!property || property.type !== 'Identifier' || property.name !== 'defineProperty') return; + if (node.arguments.length !== 3) return; + + const targetNames = targetName.split('.'); + const [target, key, value] = node.arguments; + if (targetNames.length === 1) { + if (target.type !== 'Identifier' || target.name !== targetNames[0]) { + return; + } + } + + if (targetNames.length === 2) { + if ( + target.type !== 'MemberExpression' || + target.object.name !== targetNames[0] || + target.property.name !== targetNames[1]) + { + return; + } + } + + if (value.type !== 'ObjectExpression' || !value.properties) return; + + const valueProperty = value.properties.find((p) => p.key && p.key.name === 'value'); + if (!valueProperty || !valueProperty.value) return; + + // eslint-disable-next-line consistent-return + return { key: key.value, value: valueProperty.value }; +} + +function isShorthandProperty(parent) { + return parent && parent.type === 'Property' && parent.shorthand; +} + +function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) { + const args = []; + const passedArgs = []; + if (uses.module) { + args.push('module'); + passedArgs.push(moduleName); + } + if (uses.exports) { + args.push('exports'); + passedArgs.push(uses.module ? `${moduleName}.exports` : exportsName); + } + magicString. + trim(). + indent('\t', { exclude: indentExclusionRanges }). + prepend(`(function (${args.join(', ')}) {\n`) + // For some reason, this line is only indented correctly when using a + // require-wrapper if we have this leading space + .append(` \n} (${passedArgs.join(', ')}));`); +} + +function rewriteExportsAndGetExportsBlock( +magicString, +moduleName, +exportsName, +exportedExportsName, +wrapped, +moduleExportsAssignments, +firstTopLevelModuleExportsAssignment, +exportsAssignmentsByName, +topLevelAssignments, +defineCompiledEsmExpressions, +deconflictedExportNames, +code, +HELPERS_NAME, +exportMode, +defaultIsModuleExports, +usesRequireWrapper, +requireName) +{ + const exports = []; + const exportDeclarations = []; + + if (usesRequireWrapper) { + getExportsWhenUsingRequireWrapper( + magicString, + wrapped, + exportMode, + exports, + moduleExportsAssignments, + exportsAssignmentsByName, + moduleName, + exportsName, + requireName, + defineCompiledEsmExpressions + ); + } else if (exportMode === 'replace') { + getExportsForReplacedModuleExports( + magicString, + exports, + exportDeclarations, + moduleExportsAssignments, + firstTopLevelModuleExportsAssignment, + exportsName, + defaultIsModuleExports, + HELPERS_NAME + ); + } else { + if (exportMode === 'module') { + exportDeclarations.push(`var ${exportedExportsName} = ${moduleName}.exports`); + exports.push(`${exportedExportsName} as __moduleExports`); + } else { + exports.push(`${exportsName} as __moduleExports`); + } + if (wrapped) { + exportDeclarations.push( + getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) + ); + } else { + getExports( + magicString, + exports, + exportDeclarations, + moduleExportsAssignments, + exportsAssignmentsByName, + deconflictedExportNames, + topLevelAssignments, + moduleName, + exportsName, + exportedExportsName, + defineCompiledEsmExpressions, + HELPERS_NAME, + defaultIsModuleExports, + exportMode + ); + } + } + if (exports.length) { + exportDeclarations.push(`export { ${exports.join(', ')} }`); + } + + return `\n\n${exportDeclarations.join(';\n')};`; +} + +function getExportsWhenUsingRequireWrapper( +magicString, +wrapped, +exportMode, +exports, +moduleExportsAssignments, +exportsAssignmentsByName, +moduleName, +exportsName, +requireName, +defineCompiledEsmExpressions) +{ + exports.push(`${requireName} as __require`); + if (wrapped) return; + if (exportMode === 'replace') { + rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName); + } else { + rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, `${moduleName}.exports`); + // Collect and rewrite named exports + for (const [exportName, { nodes }] of exportsAssignmentsByName) { + for (const { node, type } of nodes) { + magicString.overwrite( + node.start, + node.left.end, + `${ + exportMode === 'module' && type === 'module' ? `${moduleName}.exports` : exportsName + }.${exportName}` + ); + } + } + replaceDefineCompiledEsmExpressionsAndGetIfRestorable( + defineCompiledEsmExpressions, + magicString, + exportMode, + moduleName, + exportsName + ); + } +} + +function getExportsForReplacedModuleExports( +magicString, +exports, +exportDeclarations, +moduleExportsAssignments, +firstTopLevelModuleExportsAssignment, +exportsName, +defaultIsModuleExports, +HELPERS_NAME) +{ + for (const { left } of moduleExportsAssignments) { + magicString.overwrite(left.start, left.end, exportsName); + } + magicString.prependRight(firstTopLevelModuleExportsAssignment.left.start, 'var '); + exports.push(`${exportsName} as __moduleExports`); + exportDeclarations.push( + getDefaultExportDeclaration(exportsName, defaultIsModuleExports, HELPERS_NAME) + ); +} + +function getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) { + return `export default ${ + defaultIsModuleExports === true ? + exportedExportsName : + defaultIsModuleExports === false ? + `${exportedExportsName}.default` : + `/*@__PURE__*/${HELPERS_NAME}.getDefaultExportFromCjs(${exportedExportsName})` + }`; +} + +function getExports( +magicString, +exports, +exportDeclarations, +moduleExportsAssignments, +exportsAssignmentsByName, +deconflictedExportNames, +topLevelAssignments, +moduleName, +exportsName, +exportedExportsName, +defineCompiledEsmExpressions, +HELPERS_NAME, +defaultIsModuleExports, +exportMode) +{ + let deconflictedDefaultExportName; + // Collect and rewrite module.exports assignments + for (const { left } of moduleExportsAssignments) { + magicString.overwrite(left.start, left.end, `${moduleName}.exports`); + } + + // Collect and rewrite named exports + for (const [exportName, { nodes }] of exportsAssignmentsByName) { + const deconflicted = deconflictedExportNames[exportName]; + let needsDeclaration = true; + for (const { node, type } of nodes) { + let replacement = `${deconflicted} = ${ + exportMode === 'module' && type === 'module' ? `${moduleName}.exports` : exportsName + }.${exportName}`; + if (needsDeclaration && topLevelAssignments.has(node)) { + replacement = `var ${replacement}`; + needsDeclaration = false; + } + magicString.overwrite(node.start, node.left.end, replacement); + } + if (needsDeclaration) { + magicString.prepend(`var ${deconflicted};\n`); + } + + if (exportName === 'default') { + deconflictedDefaultExportName = deconflicted; + } else { + exports.push(exportName === deconflicted ? exportName : `${deconflicted} as ${exportName}`); + } + } + + const isRestorableCompiledEsm = replaceDefineCompiledEsmExpressionsAndGetIfRestorable( + defineCompiledEsmExpressions, + magicString, + exportMode, + moduleName, + exportsName + ); + + if ( + defaultIsModuleExports === false || + defaultIsModuleExports === 'auto' && + isRestorableCompiledEsm && + moduleExportsAssignments.length === 0) + { + // If there is no deconflictedDefaultExportName, then we use the namespace as + // fallback because there can be no "default" property on the namespace + exports.push(`${deconflictedDefaultExportName || exportedExportsName} as default`); + } else if ( + defaultIsModuleExports === true || + !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) + { + exports.push(`${exportedExportsName} as default`); + } else { + exportDeclarations.push( + getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) + ); + } +} + +function rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName) { + for (const { left } of moduleExportsAssignments) { + magicString.overwrite(left.start, left.end, exportsName); + } +} + +function replaceDefineCompiledEsmExpressionsAndGetIfRestorable( +defineCompiledEsmExpressions, +magicString, +exportMode, +moduleName, +exportsName) +{ + let isRestorableCompiledEsm = false; + for (const { node, type } of defineCompiledEsmExpressions) { + isRestorableCompiledEsm = true; + const moduleExportsExpression = + node.type === 'CallExpression' ? node.arguments[0] : node.left.object; + magicString.overwrite( + moduleExportsExpression.start, + moduleExportsExpression.end, + exportMode === 'module' && type === 'module' ? `${moduleName}.exports` : exportsName + ); + } + return isRestorableCompiledEsm; +} + +function isRequireExpression(node, scope) { + if (!node) return false; + if (node.type !== 'CallExpression') return false; + + // Weird case of `require()` or `module.require()` without arguments + if (node.arguments.length === 0) return false; + + return isRequire(node.callee, scope); +} + +function isRequire(node, scope) { + return ( + node.type === 'Identifier' && node.name === 'require' && !scope.contains('require') || + node.type === 'MemberExpression' && isModuleRequire(node, scope)); + +} + +function isModuleRequire({ object, property }, scope) { + return ( + object.type === 'Identifier' && + object.name === 'module' && + property.type === 'Identifier' && + property.name === 'require' && + !scope.contains('module')); + +} + +function hasDynamicArguments(node) { + return ( + node.arguments.length > 1 || + node.arguments[0].type !== 'Literal' && ( + node.arguments[0].type !== 'TemplateLiteral' || node.arguments[0].expressions.length > 0)); + +} + +const reservedMethod = { resolve: true, cache: true, main: true }; + +function isNodeRequirePropertyAccess(parent) { + return parent && parent.property && reservedMethod[parent.property.name]; +} + +function getRequireStringArg(node) { + return node.arguments[0].type === 'Literal' ? + node.arguments[0].value : + node.arguments[0].quasis[0].value.cooked; +} + +function getRequireHandlers() { + const requireExpressions = []; + + function addRequireExpression( + sourceId, + node, + scope, + usesReturnValue, + isInsideTryBlock, + isInsideConditional, + toBeRemoved) + { + requireExpressions.push({ + sourceId, + node, + scope, + usesReturnValue, + isInsideTryBlock, + isInsideConditional, + toBeRemoved + }); + } + + async function rewriteRequireExpressionsAndGetImportBlock( + magicString, + topLevelDeclarations, + reassignedNames, + helpersName, + dynamicRequireName, + moduleName, + exportsName, + id, + exportMode, + resolveRequireSourcesAndUpdateMeta, + needsRequireWrapper, + isEsModule, + isDynamicRequireModulesEnabled, + getIgnoreTryCatchRequireStatementMode, + commonjsMeta) + { + const imports = []; + imports.push(`import * as ${helpersName} from "${HELPERS_ID}"`); + if (dynamicRequireName) { + imports.push( + `import { ${ + isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT + } as ${dynamicRequireName} } from "${DYNAMIC_MODULES_ID}"` + ); + } + if (exportMode === 'module') { + imports.push( + `import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`, + `var ${exportsName} = ${moduleName}.exports` + ); + } else if (exportMode === 'exports') { + imports.push( + `import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}` + ); + } + const requiresBySource = collectSources(requireExpressions); + const requireTargets = await resolveRequireSourcesAndUpdateMeta( + id, + needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule, + commonjsMeta, + Object.keys(requiresBySource).map((source) => { + return { + source, + isConditional: requiresBySource[source].every((require) => require.isInsideConditional) + }; + }) + ); + processRequireExpressions( + imports, + requireTargets, + requiresBySource, + getIgnoreTryCatchRequireStatementMode, + magicString + ); + return imports.length ? `${imports.join(';\n')};\n\n` : ''; + } + + return { + addRequireExpression, + rewriteRequireExpressionsAndGetImportBlock + }; +} + +function collectSources(requireExpressions) { + const requiresBySource = Object.create(null); + for (const requireExpression of requireExpressions) { + const { sourceId } = requireExpression; + if (!requiresBySource[sourceId]) { + requiresBySource[sourceId] = []; + } + const requires = requiresBySource[sourceId]; + requires.push(requireExpression); + } + return requiresBySource; +} + +function processRequireExpressions( +imports, +requireTargets, +requiresBySource, +getIgnoreTryCatchRequireStatementMode, +magicString) +{ + const generateRequireName = getGenerateRequireName(); + for (const { source, id: resolvedId, isCommonJS } of requireTargets) { + const requires = requiresBySource[source]; + const name = generateRequireName(requires); + let usesRequired = false; + let needsImport = false; + for (const { node, usesReturnValue, toBeRemoved, isInsideTryBlock } of requires) { + const { canConvertRequire, shouldRemoveRequire } = + isInsideTryBlock && isWrappedId(resolvedId, EXTERNAL_SUFFIX) ? + getIgnoreTryCatchRequireStatementMode(source) : + { canConvertRequire: true, shouldRemoveRequire: false }; + if (shouldRemoveRequire) { + if (usesReturnValue) { + magicString.overwrite(node.start, node.end, 'undefined'); + } else { + magicString.remove(toBeRemoved.start, toBeRemoved.end); + } + } else if (canConvertRequire) { + needsImport = true; + if (isCommonJS === IS_WRAPPED_COMMONJS) { + magicString.overwrite(node.start, node.end, `${name}()`); + } else if (usesReturnValue) { + usesRequired = true; + magicString.overwrite(node.start, node.end, name); + } else { + magicString.remove(toBeRemoved.start, toBeRemoved.end); + } + } + } + if (needsImport) { + if (isCommonJS === IS_WRAPPED_COMMONJS) { + imports.push(`import { __require as ${name} } from ${JSON.stringify(resolvedId)}`); + } else { + imports.push(`import ${usesRequired ? `${name} from ` : ''}${JSON.stringify(resolvedId)}`); + } + } + } +} + +function getGenerateRequireName() { + let uid = 0; + return (requires) => { + let name; + const hasNameConflict = ({ scope }) => scope.contains(name); + do { + name = `require$$${uid}`; + uid += 1; + } while (requires.some(hasNameConflict)); + return name; + }; +} + +/* eslint-disable no-param-reassign, no-shadow, no-underscore-dangle, no-continue */ + + +const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/; + +const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/; + +// There are three different types of CommonJS modules, described by their +// "exportMode": +// - exports: Only assignments to (module.)exports properties +// - replace: A single assignment to module.exports itself +// - module: Anything else +// Special cases: +// - usesRequireWrapper +// - isWrapped +async function transformCommonjs( +parse, +code, +id, +isEsModule, +ignoreGlobal, +ignoreRequire, +ignoreDynamicRequires, +getIgnoreTryCatchRequireStatementMode, +sourceMap, +isDynamicRequireModulesEnabled, +dynamicRequireModules, +commonDir, +astCache, +defaultIsModuleExports, +needsRequireWrapper, +resolveRequireSourcesAndUpdateMeta, +isRequired, +checkDynamicRequire, +commonjsMeta) +{ + const ast = astCache || tryParse(parse, code, id); + const magicString = new MagicString(code); + const uses = { + module: false, + exports: false, + global: false, + require: false + }; + const virtualDynamicRequirePath = + isDynamicRequireModulesEnabled && getVirtualPathForDynamicRequirePath(path.dirname(id), commonDir); + let scope = pluginutils.attachScopes(ast, 'scope'); + let lexicalDepth = 0; + let programDepth = 0; + let classBodyDepth = 0; + let currentTryBlockEnd = null; + let shouldWrap = false; + + const globals = new Set(); + // A conditionalNode is a node for which execution is not guaranteed. If such a node is a require + // or contains nested requires, those should be handled as function calls unless there is an + // unconditional require elsewhere. + let currentConditionalNodeEnd = null; + const conditionalNodes = new Set(); + const { addRequireExpression, rewriteRequireExpressionsAndGetImportBlock } = getRequireHandlers(); + + // See which names are assigned to. This is necessary to prevent + // illegally replacing `var foo = require('foo')` with `import foo from 'foo'`, + // where `foo` is later reassigned. (This happens in the wild. CommonJS, sigh) + const reassignedNames = new Set(); + const topLevelDeclarations = []; + const skippedNodes = new Set(); + const moduleAccessScopes = new Set([scope]); + const exportsAccessScopes = new Set([scope]); + const moduleExportsAssignments = []; + let firstTopLevelModuleExportsAssignment = null; + const exportsAssignmentsByName = new Map(); + const topLevelAssignments = new Set(); + const topLevelDefineCompiledEsmExpressions = []; + const replacedGlobal = []; + const replacedDynamicRequires = []; + const importedVariables = new Set(); + const indentExclusionRanges = []; + + estreeWalker.walk(ast, { + enter(node, parent) { + if (skippedNodes.has(node)) { + this.skip(); + return; + } + + if (currentTryBlockEnd !== null && node.start > currentTryBlockEnd) { + currentTryBlockEnd = null; + } + if (currentConditionalNodeEnd !== null && node.start > currentConditionalNodeEnd) { + currentConditionalNodeEnd = null; + } + if (currentConditionalNodeEnd === null && conditionalNodes.has(node)) { + currentConditionalNodeEnd = node.end; + } + + programDepth += 1; + if (node.scope) ({ scope } = node); + if (functionType.test(node.type)) lexicalDepth += 1; + if (sourceMap) { + magicString.addSourcemapLocation(node.start); + magicString.addSourcemapLocation(node.end); + } + + // eslint-disable-next-line default-case + switch (node.type) { + case 'AssignmentExpression': + if (node.left.type === 'MemberExpression') { + const flattened = getKeypath(node.left); + if (!flattened || scope.contains(flattened.name)) return; + + const exportsPatternMatch = exportsPattern.exec(flattened.keypath); + if (!exportsPatternMatch || flattened.keypath === 'exports') return; + + const [, exportName] = exportsPatternMatch; + uses[flattened.name] = true; + + // we're dealing with `module.exports = ...` or `[module.]exports.foo = ...` – + if (flattened.keypath === 'module.exports') { + moduleExportsAssignments.push(node); + if (programDepth > 3) { + moduleAccessScopes.add(scope); + } else if (!firstTopLevelModuleExportsAssignment) { + firstTopLevelModuleExportsAssignment = node; + } + } else if (exportName === KEY_COMPILED_ESM) { + if (programDepth > 3) { + shouldWrap = true; + } else { + // The "type" is either "module" or "exports" to discern + // assignments to module.exports vs exports if needed + topLevelDefineCompiledEsmExpressions.push({ node, type: flattened.name }); + } + } else { + const exportsAssignments = exportsAssignmentsByName.get(exportName) || { + nodes: [], + scopes: new Set() + }; + exportsAssignments.nodes.push({ node, type: flattened.name }); + exportsAssignments.scopes.add(scope); + exportsAccessScopes.add(scope); + exportsAssignmentsByName.set(exportName, exportsAssignments); + if (programDepth <= 3) { + topLevelAssignments.add(node); + } + } + + skippedNodes.add(node.left); + } else { + for (const name of pluginutils.extractAssignedNames(node.left)) { + reassignedNames.add(name); + } + } + return; + case 'CallExpression':{ + const defineCompiledEsmType = getDefineCompiledEsmType(node); + if (defineCompiledEsmType) { + if (programDepth === 3 && parent.type === 'ExpressionStatement') { + // skip special handling for [module.]exports until we know we render this + skippedNodes.add(node.arguments[0]); + topLevelDefineCompiledEsmExpressions.push({ node, type: defineCompiledEsmType }); + } else { + shouldWrap = true; + } + return; + } + + // Transform require.resolve + if ( + isDynamicRequireModulesEnabled && + node.callee.object && + isRequire(node.callee.object, scope) && + node.callee.property.name === 'resolve') + { + checkDynamicRequire(node.start); + uses.require = true; + const requireNode = node.callee.object; + replacedDynamicRequires.push(requireNode); + skippedNodes.add(node.callee); + return; + } + + if (!isRequireExpression(node, scope)) { + const keypath = getKeypath(node.callee); + if (keypath && importedVariables.has(keypath.name)) { + // Heuristic to deoptimize requires after a required function has been called + currentConditionalNodeEnd = Infinity; + } + return; + } + + skippedNodes.add(node.callee); + uses.require = true; + + if (hasDynamicArguments(node)) { + if (isDynamicRequireModulesEnabled) { + checkDynamicRequire(node.start); + } + if (!ignoreDynamicRequires) { + replacedDynamicRequires.push(node.callee); + } + return; + } + + const requireStringArg = getRequireStringArg(node); + if (!ignoreRequire(requireStringArg)) { + const usesReturnValue = parent.type !== 'ExpressionStatement'; + const toBeRemoved = + parent.type === 'ExpressionStatement' && ( + !currentConditionalNodeEnd || + // We should completely remove requires directly in a try-catch + // so that Rollup can remove up the try-catch + currentTryBlockEnd !== null && currentTryBlockEnd < currentConditionalNodeEnd) ? + parent : + node; + addRequireExpression( + requireStringArg, + node, + scope, + usesReturnValue, + currentTryBlockEnd !== null, + currentConditionalNodeEnd !== null, + toBeRemoved + ); + if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') { + for (const name of pluginutils.extractAssignedNames(parent.id)) { + importedVariables.add(name); + } + } + } + return; + } + case 'ClassBody': + classBodyDepth += 1; + return; + case 'ConditionalExpression': + case 'IfStatement': + // skip dead branches + if (isFalsy(node.test)) { + skippedNodes.add(node.consequent); + } else if (isTruthy(node.test)) { + if (node.alternate) { + skippedNodes.add(node.alternate); + } + } else { + conditionalNodes.add(node.consequent); + if (node.alternate) { + conditionalNodes.add(node.alternate); + } + } + return; + case 'ArrowFunctionExpression': + case 'FunctionDeclaration': + case 'FunctionExpression': + // requires in functions should be conditional unless it is an IIFE + if ( + currentConditionalNodeEnd === null && + !(parent.type === 'CallExpression' && parent.callee === node)) + { + currentConditionalNodeEnd = node.end; + } + return; + case 'Identifier':{ + const { name } = node; + if (!isReference(node, parent) || scope.contains(name)) return; + switch (name) { + case 'require': + uses.require = true; + if (isNodeRequirePropertyAccess(parent)) { + return; + } + if (!ignoreDynamicRequires) { + if (isShorthandProperty(parent)) { + // as key and value are the same object, isReference regards + // both as references, so we need to skip now + skippedNodes.add(parent.value); + magicString.prependRight(node.start, 'require: '); + } + replacedDynamicRequires.push(node); + } + return; + case 'module': + case 'exports': + shouldWrap = true; + uses[name] = true; + return; + case 'global': + uses.global = true; + if (!ignoreGlobal) { + replacedGlobal.push(node); + } + return; + case 'define': + magicString.overwrite(node.start, node.end, 'undefined', { + storeName: true + }); + return; + default: + globals.add(name); + return; + } + } + case 'LogicalExpression': + // skip dead branches + if (node.operator === '&&') { + if (isFalsy(node.left)) { + skippedNodes.add(node.right); + } else if (!isTruthy(node.left)) { + conditionalNodes.add(node.right); + } + } else if (node.operator === '||') { + if (isTruthy(node.left)) { + skippedNodes.add(node.right); + } else if (!isFalsy(node.left)) { + conditionalNodes.add(node.right); + } + } + return; + case 'MemberExpression': + if (!isDynamicRequireModulesEnabled && isModuleRequire(node, scope)) { + uses.require = true; + replacedDynamicRequires.push(node); + skippedNodes.add(node.object); + skippedNodes.add(node.property); + } + return; + case 'ReturnStatement': + // if top-level return, we need to wrap it + if (lexicalDepth === 0) { + shouldWrap = true; + } + return; + case 'ThisExpression': + // rewrite top-level `this` as `commonjsHelpers.commonjsGlobal` + if (lexicalDepth === 0 && !classBodyDepth) { + uses.global = true; + if (!ignoreGlobal) { + replacedGlobal.push(node); + } + } + return; + case 'TryStatement': + if (currentTryBlockEnd === null) { + currentTryBlockEnd = node.block.end; + } + if (currentConditionalNodeEnd === null) { + currentConditionalNodeEnd = node.end; + } + return; + case 'UnaryExpression': + // rewrite `typeof module`, `typeof module.exports` and `typeof exports` (https://github.com/rollup/rollup-plugin-commonjs/issues/151) + if (node.operator === 'typeof') { + const flattened = getKeypath(node.argument); + if (!flattened) return; + + if (scope.contains(flattened.name)) return; + + if ( + !isEsModule && ( + flattened.keypath === 'module.exports' || + flattened.keypath === 'module' || + flattened.keypath === 'exports')) + { + magicString.overwrite(node.start, node.end, `'object'`, { + storeName: false + }); + } + } + return; + case 'VariableDeclaration': + if (!scope.parent) { + topLevelDeclarations.push(node); + } + return; + case 'TemplateElement': + if (node.value.raw.includes('\n')) { + indentExclusionRanges.push([node.start, node.end]); + } + } + }, + + leave(node) { + programDepth -= 1; + if (node.scope) scope = scope.parent; + if (functionType.test(node.type)) lexicalDepth -= 1; + if (node.type === 'ClassBody') classBodyDepth -= 1; + } + }); + + const nameBase = getName(id); + const exportsName = deconflict([...exportsAccessScopes], globals, nameBase); + const moduleName = deconflict([...moduleAccessScopes], globals, `${nameBase}Module`); + const requireName = deconflict([scope], globals, `require${capitalize(nameBase)}`); + const isRequiredName = deconflict([scope], globals, `hasRequired${capitalize(nameBase)}`); + const helpersName = deconflict([scope], globals, 'commonjsHelpers'); + const dynamicRequireName = + replacedDynamicRequires.length > 0 && + deconflict( + [scope], + globals, + isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT + ); + const deconflictedExportNames = Object.create(null); + for (const [exportName, { scopes }] of exportsAssignmentsByName) { + deconflictedExportNames[exportName] = deconflict([...scopes], globals, exportName); + } + + for (const node of replacedGlobal) { + magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, { + storeName: true + }); + } + for (const node of replacedDynamicRequires) { + magicString.overwrite( + node.start, + node.end, + isDynamicRequireModulesEnabled ? + `${dynamicRequireName}(${JSON.stringify(virtualDynamicRequirePath)})` : + dynamicRequireName, + { + contentOnly: true, + storeName: true + } + ); + } + + // We cannot wrap ES/mixed modules + shouldWrap = !isEsModule && (shouldWrap || uses.exports && moduleExportsAssignments.length > 0); + + if ( + !( + shouldWrap || + isRequired || + needsRequireWrapper || + uses.module || + uses.exports || + uses.require || + topLevelDefineCompiledEsmExpressions.length > 0) && ( + + ignoreGlobal || !uses.global)) + { + return { meta: { commonjs: { isCommonJS: false } } }; + } + + let leadingComment = ''; + if (code.startsWith('/*')) { + const commentEnd = code.indexOf('*/', 2) + 2; + leadingComment = `${code.slice(0, commentEnd)}\n`; + magicString.remove(0, commentEnd).trim(); + } + + let shebang = ''; + if (code.startsWith('#!')) { + const shebangEndPosition = code.indexOf('\n') + 1; + shebang = code.slice(0, shebangEndPosition); + magicString.remove(0, shebangEndPosition).trim(); + } + + const exportMode = isEsModule ? + 'none' : + shouldWrap ? + uses.module ? + 'module' : + 'exports' : + firstTopLevelModuleExportsAssignment ? + exportsAssignmentsByName.size === 0 && topLevelDefineCompiledEsmExpressions.length === 0 ? + 'replace' : + 'module' : + moduleExportsAssignments.length === 0 ? + 'exports' : + 'module'; + + const exportedExportsName = + exportMode === 'module' ? deconflict([], globals, `${nameBase}Exports`) : exportsName; + + const importBlock = await rewriteRequireExpressionsAndGetImportBlock( + magicString, + topLevelDeclarations, + reassignedNames, + helpersName, + dynamicRequireName, + moduleName, + exportsName, + id, + exportMode, + resolveRequireSourcesAndUpdateMeta, + needsRequireWrapper, + isEsModule, + isDynamicRequireModulesEnabled, + getIgnoreTryCatchRequireStatementMode, + commonjsMeta + ); + const usesRequireWrapper = commonjsMeta.isCommonJS === IS_WRAPPED_COMMONJS; + const exportBlock = isEsModule ? + '' : + rewriteExportsAndGetExportsBlock( + magicString, + moduleName, + exportsName, + exportedExportsName, + shouldWrap, + moduleExportsAssignments, + firstTopLevelModuleExportsAssignment, + exportsAssignmentsByName, + topLevelAssignments, + topLevelDefineCompiledEsmExpressions, + deconflictedExportNames, + code, + helpersName, + exportMode, + defaultIsModuleExports, + usesRequireWrapper, + requireName + ); + + if (shouldWrap) { + wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges); + } + + if (usesRequireWrapper) { + magicString.trim().indent('\t', { + exclude: indentExclusionRanges + }); + const exported = exportMode === 'module' ? `${moduleName}.exports` : exportsName; + magicString.prepend( + `var ${isRequiredName}; + +function ${requireName} () { +\tif (${isRequiredName}) return ${exported}; +\t${isRequiredName} = 1; +` + ).append(` +\treturn ${exported}; +}`); + if (exportMode === 'replace') { + magicString.prepend(`var ${exportsName};\n`); + } + } + + magicString. + trim(). + prepend(shebang + leadingComment + importBlock). + append(exportBlock); + + return { + code: magicString.toString(), + map: sourceMap ? magicString.generateMap() : null, + syntheticNamedExports: isEsModule || usesRequireWrapper ? false : '__moduleExports', + meta: { commonjs: { ...commonjsMeta, shebang } } + }; +} + +const PLUGIN_NAME = 'commonjs'; + +function commonjs(options = {}) { + const { + ignoreGlobal, + ignoreDynamicRequires, + requireReturnsDefault: requireReturnsDefaultOption, + defaultIsModuleExports: defaultIsModuleExportsOption, + esmExternals + } = options; + const extensions = options.extensions || ['.js']; + const filter = pluginutils.createFilter(options.include, options.exclude); + const isPossibleCjsId = (id) => { + const extName = path.extname(id); + return extName === '.cjs' || extensions.includes(extName) && filter(id); + }; + + const { strictRequiresFilter, detectCyclesAndConditional } = getStrictRequiresFilter(options); + + const getRequireReturnsDefault = + typeof requireReturnsDefaultOption === 'function' ? + requireReturnsDefaultOption : + () => requireReturnsDefaultOption; + + let esmExternalIds; + const isEsmExternal = + typeof esmExternals === 'function' ? + esmExternals : + Array.isArray(esmExternals) ? ( + esmExternalIds = new Set(esmExternals), (id) => esmExternalIds.has(id)) : + () => esmExternals; + + const getDefaultIsModuleExports = + typeof defaultIsModuleExportsOption === 'function' ? + defaultIsModuleExportsOption : + () => + typeof defaultIsModuleExportsOption === 'boolean' ? defaultIsModuleExportsOption : 'auto'; + + const dynamicRequireRoot = + typeof options.dynamicRequireRoot === 'string' ? + path.resolve(options.dynamicRequireRoot) : + process.cwd(); + const { commonDir, dynamicRequireModules } = getDynamicRequireModules( + options.dynamicRequireTargets, + dynamicRequireRoot + ); + const isDynamicRequireModulesEnabled = dynamicRequireModules.size > 0; + + const ignoreRequire = + typeof options.ignore === 'function' ? + options.ignore : + Array.isArray(options.ignore) ? + (id) => options.ignore.includes(id) : + () => false; + + const getIgnoreTryCatchRequireStatementMode = (id) => { + const mode = + typeof options.ignoreTryCatch === 'function' ? + options.ignoreTryCatch(id) : + Array.isArray(options.ignoreTryCatch) ? + options.ignoreTryCatch.includes(id) : + typeof options.ignoreTryCatch !== 'undefined' ? + options.ignoreTryCatch : + true; + + return { + canConvertRequire: mode !== 'remove' && mode !== true, + shouldRemoveRequire: mode === 'remove' + }; + }; + + const { currentlyResolving, resolveId } = getResolveId(extensions, isPossibleCjsId); + + const sourceMap = options.sourceMap !== false; + + // Initialized in buildStart + let requireResolver; + + function transformAndCheckExports(code, id) { + const normalizedId = normalizePathSlashes(id); + const { isEsModule, hasDefaultExport, hasNamedExports, ast } = analyzeTopLevelStatements( + this.parse, + code, + id + ); + + const commonjsMeta = this.getModuleInfo(id).meta.commonjs || {}; + if (hasDefaultExport) { + commonjsMeta.hasDefaultExport = true; + } + if (hasNamedExports) { + commonjsMeta.hasNamedExports = true; + } + + if ( + !dynamicRequireModules.has(normalizedId) && ( + !(hasCjsKeywords(code, ignoreGlobal) || requireResolver.isRequiredId(id)) || + isEsModule && !options.transformMixedEsModules)) + { + commonjsMeta.isCommonJS = false; + return { meta: { commonjs: commonjsMeta } }; + } + + const needsRequireWrapper = + !isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id)); + + const checkDynamicRequire = (position) => { + const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot); + + if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) { + this.error( + { + code: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT', + normalizedId, + normalizedDynamicRequireRoot, + message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${path.dirname( + normalizedId + )}" or one of its parent directories.` + }, + position + ); + } + }; + + return transformCommonjs( + this.parse, + code, + id, + isEsModule, + ignoreGlobal || isEsModule, + ignoreRequire, + ignoreDynamicRequires && !isDynamicRequireModulesEnabled, + getIgnoreTryCatchRequireStatementMode, + sourceMap, + isDynamicRequireModulesEnabled, + dynamicRequireModules, + commonDir, + ast, + getDefaultIsModuleExports(id), + needsRequireWrapper, + requireResolver.resolveRequireSourcesAndUpdateMeta(this), + requireResolver.isRequiredId(id), + checkDynamicRequire, + commonjsMeta + ); + } + + return { + name: PLUGIN_NAME, + + version, + + options(rawOptions) { + // We inject the resolver in the beginning so that "catch-all-resolver" like node-resolver + // do not prevent our plugin from resolving entry points ot proxies. + const plugins = Array.isArray(rawOptions.plugins) ? + [...rawOptions.plugins] : + rawOptions.plugins ? + [rawOptions.plugins] : + []; + plugins.unshift({ + name: 'commonjs--resolver', + resolveId + }); + return { ...rawOptions, plugins }; + }, + + buildStart({ plugins }) { + validateVersion(this.meta.rollupVersion, peerDependencies.rollup, 'rollup'); + const nodeResolve = plugins.find(({ name }) => name === 'node-resolve'); + if (nodeResolve) { + validateVersion(nodeResolve.version, '^13.0.6', '@rollup/plugin-node-resolve'); + } + if (options.namedExports != null) { + this.warn( + 'The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.' + ); + } + requireResolver = getRequireResolver( + extensions, + detectCyclesAndConditional, + currentlyResolving + ); + }, + + buildEnd() { + if (options.strictRequires === 'debug') { + const wrappedIds = requireResolver.getWrappedIds(); + if (wrappedIds.length) { + this.warn({ + code: 'WRAPPED_IDS', + ids: wrappedIds, + message: `The commonjs plugin automatically wrapped the following files:\n[\n${wrappedIds. + map((id) => `\t${JSON.stringify(path.relative(process.cwd(), id))}`). + join(',\n')}\n]` + }); + } else { + this.warn({ + code: 'WRAPPED_IDS', + ids: wrappedIds, + message: 'The commonjs plugin did not wrap any files.' + }); + } + } + }, + + load(id) { + if (id === HELPERS_ID) { + return getHelpersModule(); + } + + if (isWrappedId(id, MODULE_SUFFIX)) { + const name = getName(unwrapId(id, MODULE_SUFFIX)); + return { + code: `var ${name} = {exports: {}}; export {${name} as __module}`, + meta: { commonjs: { isCommonJS: false } } + }; + } + + if (isWrappedId(id, EXPORTS_SUFFIX)) { + const name = getName(unwrapId(id, EXPORTS_SUFFIX)); + return { + code: `var ${name} = {}; export {${name} as __exports}`, + meta: { commonjs: { isCommonJS: false } } + }; + } + + if (isWrappedId(id, EXTERNAL_SUFFIX)) { + const actualId = unwrapId(id, EXTERNAL_SUFFIX); + return getUnknownRequireProxy( + actualId, + isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true + ); + } + + // entry suffix is just appended to not mess up relative external resolution + if (id.endsWith(ENTRY_SUFFIX)) { + const acutalId = id.slice(0, -ENTRY_SUFFIX.length); + const { + meta: { commonjs: commonjsMeta } + } = this.getModuleInfo(acutalId); + const shebang = commonjsMeta?.shebang ?? ''; + return getEntryProxy( + acutalId, + getDefaultIsModuleExports(acutalId), + this.getModuleInfo, + shebang + ); + } + + if (isWrappedId(id, ES_IMPORT_SUFFIX)) { + const actualId = unwrapId(id, ES_IMPORT_SUFFIX); + return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId)); + } + + if (id === DYNAMIC_MODULES_ID) { + return getDynamicModuleRegistry( + isDynamicRequireModulesEnabled, + dynamicRequireModules, + commonDir, + ignoreDynamicRequires + ); + } + + if (isWrappedId(id, PROXY_SUFFIX)) { + const actualId = unwrapId(id, PROXY_SUFFIX); + return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load); + } + + return null; + }, + + shouldTransformCachedModule(...args) { + return requireResolver.shouldTransformCachedModule.call(this, ...args); + }, + + transform(code, id) { + if (!isPossibleCjsId(id)) return null; + + try { + return transformAndCheckExports.call(this, code, id); + } catch (err) { + return this.error(err, err.pos); + } + } + }; +} + +exports.default = commonjs; +module.exports = Object.assign(exports.default, exports); /* v7-5449fe50d020f449 */ \ No newline at end of file diff --git a/node-jiti/dist-index.mjs.a1526ac0.js b/node-jiti/dist-index.mjs.a1526ac0.js new file mode 100644 index 0000000..0a7f6ad --- /dev/null +++ b/node-jiti/dist-index.mjs.a1526ac0.js @@ -0,0 +1,1159 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.build = build;exports.defineBuildConfig = defineBuildConfig;exports.definePreset = definePreset;var _nodeModule = _interopRequireDefault(require("node:module")); +var _nodeFs = require("node:fs"); +var _pathe = require("pathe"); +var _chalk = _interopRequireDefault(require("chalk")); +var _consola = require("consola"); +var _defu = require("defu"); +var _hookable = require("hookable"); +var _prettyBytes = _interopRequireDefault(require("pretty-bytes")); +var _globby = require("globby"); +var _promises = _interopRequireWildcard(require("node:fs/promises")); +var _jiti = _interopRequireDefault(require("jiti")); +var _nodeUrl = require("node:url"); +var _rollup = require("rollup"); +var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs")); +var _pluginNodeResolve = require("@rollup/plugin-node-resolve"); +var _pluginAlias = _interopRequireDefault(require("@rollup/plugin-alias")); +var _rollupPluginDts = _interopRequireDefault(require("rollup-plugin-dts")); +var _pluginReplace = _interopRequireDefault(require("@rollup/plugin-replace")); +var _mlly = require("mlly"); +var _esbuild = require("esbuild"); +var _pluginutils = require("@rollup/pluginutils"); +var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json")); +var _magicString = _interopRequireDefault(require("magic-string")); +var _untyped = require("untyped"); +var _babelPlugin = _interopRequireDefault(require("untyped/babel-plugin")); +var _scule = require("scule"); +var _mkdist = require("mkdist");function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function (nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} + +function defineBuildConfig(config) { + return (Array.isArray(config) ? config : [config]).filter(Boolean); +} +function definePreset(preset) { + return preset; +} + +const autoPreset = definePreset(() => { + return { + hooks: { + "build:prepare"(ctx) { + if (!ctx.pkg || ctx.options.entries.length > 0) { + return; + } + const sourceFiles = listRecursively((0, _pathe.join)(ctx.options.rootDir, "src")); + const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir); + for (const message of res.warnings) { + warn(ctx, message); + } + ctx.options.entries.push(...res.entries); + if (res.cjs) { + ctx.options.rollup.emitCJS = true; + } + if (res.dts) { + ctx.options.declaration = res.dts; + } + _consola.consola.info( + "Automatically detected entries:", + _chalk.default.cyan( + ctx.options.entries.map( + (e) => _chalk.default.bold( + e.input.replace(ctx.options.rootDir + "/", "").replace(/\/$/, "/*") + ) + ).join(", ") + ), + _chalk.default.gray( + ["esm", res.cjs && "cjs", res.dts && "dts"].filter(Boolean).map((tag) => `[${tag}]`).join(" ") + ) + ); + } + } + }; +}); +function inferEntries(pkg, sourceFiles, rootDir) { + const warnings = []; + sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length); + const outputs = extractExportFilenames(pkg.exports); + if (pkg.bin) { + const binaries = typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin); + for (const file of binaries) { + outputs.push({ file }); + } + } + if (pkg.main) { + outputs.push({ file: pkg.main }); + } + if (pkg.module) { + outputs.push({ type: "esm", file: pkg.module }); + } + if (pkg.types || pkg.typings) { + outputs.push({ file: pkg.types || pkg.typings }); + } + const isESMPkg = pkg.type === "module"; + for (const output of outputs.filter((o) => !o.type)) { + const isJS = output.file.endsWith(".js"); + if (isESMPkg && isJS || output.file.endsWith(".mjs")) { + output.type = "esm"; + } else if (!isESMPkg && isJS || output.file.endsWith(".cjs")) { + output.type = "cjs"; + } + } + let cjs = false; + let dts = false; + const entries = []; + for (const output of outputs) { + const outputSlug = output.file.replace( + /(\*[^/\\]*|\.d\.(m|c)?ts|\.\w+)$/, + "" + ); + const isDir = outputSlug.endsWith("/"); + if (isDir && ["./", "/"].includes(outputSlug)) { + continue; + } + const possiblePaths = getEntrypointPaths(outputSlug); + const input = possiblePaths.reduce((source, d) => { + if (source) { + return source; + } + const SOURCE_RE = new RegExp(`(?<=/|$)${d}${isDir ? "" : "\\.\\w+"}$`); + return sourceFiles.find((i) => SOURCE_RE.test(i))?.replace(/(\.d\.(m|c)?ts|\.\w+)$/, ""); + }, void 0); + if (!input) { + if (!(0, _nodeFs.existsSync)((0, _pathe.resolve)(rootDir || ".", output.file))) { + warnings.push(`Could not find entrypoint for \`${output.file}\``); + } + continue; + } + if (output.type === "cjs") { + cjs = true; + } + const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1]; + if (/\.d\.(m|c)?ts$/.test(output.file)) { + dts = true; + } + if (isDir) { + entry.outDir = outputSlug; + entry.format = output.type; + } + } + return { entries, cjs, dts, warnings }; +} +const getEntrypointPaths = (path) => { + const segments = (0, _pathe.normalize)(path).split("/"); + return segments.map((_, index) => segments.slice(index).join("/")).filter(Boolean); +}; + +async function ensuredir(path) { + await _promises.default.mkdir((0, _pathe.dirname)(path), { recursive: true }); +} +function warn(ctx, message) { + if (ctx.warnings.has(message)) { + return; + } + _consola.consola.debug("[unbuild] [warn]", message); + ctx.warnings.add(message); +} +async function symlink(from, to, force = true) { + await ensuredir(to); + if (force) { + await _promises.default.unlink(to).catch(() => { + }); + } + await _promises.default.symlink(from, to, "junction"); +} +function dumpObject(obj) { + return "{ " + Object.keys(obj).map((key) => `${key}: ${JSON.stringify(obj[key])}`).join(", ") + " }"; +} +function getpkg(id = "") { + const s = id.split("/"); + return s[0][0] === "@" ? `${s[0]}/${s[1]}` : s[0]; +} +async function rmdir(dir) { + await _promises.default.unlink(dir).catch(() => { + }); + await _promises.default.rm(dir, { recursive: true, force: true }).catch(() => { + }); +} +function listRecursively(path) { + const filenames = /* @__PURE__ */new Set(); + const walk = (path2) => { + const files = (0, _nodeFs.readdirSync)(path2); + for (const file of files) { + const fullPath = (0, _pathe.resolve)(path2, file); + if ((0, _nodeFs.statSync)(fullPath).isDirectory()) { + filenames.add(fullPath + "/"); + walk(fullPath); + } else { + filenames.add(fullPath); + } + } + }; + walk(path); + return [...filenames]; +} +function tryRequire(id, rootDir = process.cwd()) { + const _require = (0, _jiti.default)(rootDir, { interopDefault: true, esmResolve: true }); + try { + return _require(id); + } catch (error) { + if (error.code !== "MODULE_NOT_FOUND") { + console.error(`Error trying import ${id} from ${rootDir}`, error); + } + return {}; + } +} +function tryResolve(id, rootDir = process.cwd()) { + const _require = (0, _jiti.default)(rootDir, { interopDefault: true, esmResolve: true }); + try { + return _require.resolve(id); + } catch (error) { + if (error.code !== "MODULE_NOT_FOUND") { + console.error(`Error trying import ${id} from ${rootDir}`, error); + } + return id; + } +} +function resolvePreset(preset, rootDir) { + if (preset === "auto") { + preset = autoPreset; + } else if (typeof preset === "string") { + preset = tryRequire(preset, rootDir) || {}; + } + if (typeof preset === "function") { + preset = preset(); + } + return preset; +} +function inferExportType(condition, previousConditions = [], filename = "") { + if (filename) { + if (filename.endsWith(".d.ts")) { + return "esm"; + } + if (filename.endsWith(".mjs")) { + return "esm"; + } + if (filename.endsWith(".cjs")) { + return "cjs"; + } + } + switch (condition) { + case "import":{ + return "esm"; + } + case "require":{ + return "cjs"; + } + default:{ + if (previousConditions.length === 0) { + return "esm"; + } + const [newCondition, ...rest] = previousConditions; + return inferExportType(newCondition, rest, filename); + } + } +} +function extractExportFilenames(exports, conditions = []) { + if (!exports) { + return []; + } + if (typeof exports === "string") { + return [{ file: exports, type: "esm" }]; + } + return Object.entries(exports).filter(([subpath]) => !subpath.endsWith(".json")).flatMap( + ([condition, exports2]) => typeof exports2 === "string" ? { + file: exports2, + type: inferExportType(condition, conditions, exports2) + } : extractExportFilenames(exports2, [...conditions, condition]) + ); +} +function arrayIncludes(arr, searchElement) { + return arr.some( + (entry) => entry instanceof RegExp ? entry.test(searchElement) : entry === searchElement + ); +} +function removeExtension(filename) { + return filename.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/, ""); +} + +function validateDependencies(ctx) { + const usedDependencies = /* @__PURE__ */new Set(); + const unusedDependencies = new Set( + Object.keys(ctx.pkg.dependencies || {}) + ); + const implicitDependencies = /* @__PURE__ */new Set(); + for (const id of ctx.usedImports) { + unusedDependencies.delete(id); + usedDependencies.add(id); + } + if (Array.isArray(ctx.options.dependencies)) { + for (const id of ctx.options.dependencies) { + unusedDependencies.delete(id); + } + } + for (const id of usedDependencies) { + if (!arrayIncludes(ctx.options.externals, id) && !id.startsWith("chunks/") && !ctx.options.dependencies.includes(getpkg(id)) && !ctx.options.peerDependencies.includes(getpkg(id))) { + implicitDependencies.add(id); + } + } + if (unusedDependencies.size > 0) { + warn( + ctx, + "Potential unused dependencies found: " + [...unusedDependencies].map((id) => _chalk.default.cyan(id)).join(", ") + ); + } + if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) { + warn( + ctx, + "Potential implicit dependencies found: " + [...implicitDependencies].map((id) => _chalk.default.cyan(id)).join(", ") + ); + } +} +function validatePackage(pkg, rootDir, ctx) { + if (!pkg) { + return; + } + const filenames = new Set( + [ + ...(typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {})), + pkg.main, + pkg.module, + pkg.types, + pkg.typings, + ...extractExportFilenames(pkg.exports).map((i) => i.file)]. + map((i) => i && (0, _pathe.resolve)(rootDir, i.replace(/\/[^/]*\*.*$/, ""))) + ); + const missingOutputs = []; + for (const filename of filenames) { + if (filename && !filename.includes("*") && !(0, _nodeFs.existsSync)(filename)) { + missingOutputs.push(filename.replace(rootDir + "/", "")); + } + } + if (missingOutputs.length > 0) { + warn( + ctx, + `Potential missing package.json files: ${missingOutputs.map((o) => _chalk.default.cyan(o)).join(", ")}` + ); + } +} + +const DefaultLoaders = { + ".js": "js", + ".mjs": "js", + ".cjs": "js", + ".ts": "ts", + ".mts": "ts", + ".cts": "ts", + ".tsx": "tsx", + ".jsx": "jsx" +}; +function esbuild(options) { + const { + include = /\.(ts|js|tsx|jsx)$/, + exclude = /node_modules/, + loaders: loaderOptions, + ...esbuildOptions + } = options; + const loaders = { ...DefaultLoaders }; + if (loaderOptions) { + for (const [key, value] of Object.entries(loaderOptions)) { + if (typeof value === "string") { + loaders[key] = value; + } else if (value === false) { + delete loaders[key]; + } + } + } + const getLoader = (id = "") => { + return loaders[(0, _pathe.extname)(id)]; + }; + const filter = (0, _pluginutils.createFilter)(include, exclude); + return { + name: "esbuild", + async transform(code, id) { + if (!filter(id)) { + return null; + } + const loader = getLoader(id); + if (!loader) { + return null; + } + const result = await (0, _esbuild.transform)(code, { + ...esbuildOptions, + loader, + sourcefile: id + }); + printWarnings(id, result, this); + return result.code && { + code: result.code, + map: result.map || null + }; + }, + async renderChunk(code, { fileName }) { + if (!options.minify) { + return null; + } + if (/\.d\.(c|m)?tsx?$/.test(fileName)) { + return null; + } + const loader = getLoader(fileName); + if (!loader) { + return null; + } + const result = await (0, _esbuild.transform)(code, { + ...esbuildOptions, + loader, + sourcefile: fileName, + minify: true + }); + if (result.code) { + return { + code: result.code, + map: result.map || null + }; + } + } + }; +} +function printWarnings(id, result, plugin) { + if (result.warnings) { + for (const warning of result.warnings) { + let message = "[esbuild]"; + if (warning.location) { + message += ` (${(0, _pathe.relative)(process.cwd(), id)}:${warning.location.line}:${warning.location.column})`; + } + message += ` ${warning.text}`; + plugin.warn(message); + } + } +} + +const EXPORT_DEFAULT = "export default "; +function JSONPlugin(options) { + const plugin = (0, _pluginJson.default)(options); + return { + ...plugin, + name: "unbuild-json", + transform(code, id) { + const res = plugin.transform.call(this, code, id); + if (res && typeof res !== "string" && "code" in res && res.code && res.code.startsWith(EXPORT_DEFAULT)) { + res.code = res.code.replace(EXPORT_DEFAULT, "module.exports = "); + } + return res; + } + }; +} + +const defaults = { + include: [/\.(md|txt|css|htm|html)$/], + exclude: [] +}; +function rawPlugin(opts = {}) { + opts = { ...opts, ...defaults }; + const filter = (0, _pluginutils.createFilter)(opts.include, opts.exclude); + return { + name: "unbuild-raw", + transform(code, id) { + if (filter(id)) { + return { + code: `export default ${JSON.stringify(code)}`, + map: null + }; + } + } + }; +} + +function cjsPlugin(_opts) { + return { + name: "unbuild-cjs", + renderChunk(code, _chunk, opts) { + if (opts.format === "es") { + return CJSToESM(code); + } + return null; + } + }; +} +const CJSyntaxRe = /__filename|__dirname|require\(|require\.resolve\(/; +const CJSShim = ` + +// -- Unbuild CommonJS Shims -- +import __cjs_url__ from 'url'; +import __cjs_path__ from 'path'; +import __cjs_mod__ from 'module'; +const __filename = __cjs_url__.fileURLToPath(import.meta.url); +const __dirname = __cjs_path__.dirname(__filename); +const require = __cjs_mod__.createRequire(import.meta.url); +`; +function CJSToESM(code) { + if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) { + return null; + } + const lastESMImport = (0, _mlly.findStaticImports)(code).pop(); + const indexToAppend = lastESMImport ? lastESMImport.end : 0; + const s = new _magicString.default(code); + s.appendRight(indexToAppend, CJSShim); + return { + code: s.toString(), + map: s.generateMap() + }; +} + +const SHEBANG_RE = /^#![^\n]*/; +function shebangPlugin(options = {}) { + const shebangs = /* @__PURE__ */new Map(); + return { + name: "unbuild-shebang", + // @ts-ignore temp workaround + _options: options, + transform(code, mod) { + let shebang; + code = code.replace(SHEBANG_RE, (match) => { + shebang = match; + return ""; + }); + if (!shebang) { + return null; + } + shebangs.set(mod, shebang); + return { code, map: null }; + }, + renderChunk(code, chunk, { sourcemap }) { + if (options.preserve === false) { + return null; + } + const shebang = shebangs.get(chunk.facadeModuleId); + if (!shebang) { + return null; + } + const s = new _magicString.default(code); + s.prepend(`${shebang} +`); + return { + code: s.toString(), + map: sourcemap ? s.generateMap({ hires: true }) : null + }; + }, + async writeBundle(options2, bundle) { + for (const [fileName, output] of Object.entries(bundle)) { + if (output.type !== "chunk") { + continue; + } + if (output.code?.match(SHEBANG_RE)) { + const outFile = (0, _pathe.resolve)(options2.dir, fileName); + await makeExecutable(outFile); + } + } + } + }; +} +async function makeExecutable(filePath) { + await _nodeFs.promises.chmod( + filePath, + 493 + /* rwx r-x r-x */ + ).catch(() => { + }); +} +function getShebang(code, append = "\n") { + const m = code.match(SHEBANG_RE); + return m ? m + append : ""; +} + +const DEFAULT_EXTENSIONS = [ +".ts", +".tsx", +".mjs", +".cjs", +".js", +".jsx", +".json"]; + +async function rollupBuild(ctx) { + if (ctx.options.stub) { + const jitiPath = await (0, _mlly.resolvePath)("jiti", { url: "file:///Users/xiatao/Documents/Outsourcing/haojing/erp-web/node_modules/.pnpm/unbuild@2.0.0_sass@1.75.0_typescript@5.4.5/node_modules/unbuild/dist/index.mjs" }); + const serializedJitiOptions = JSON.stringify( + { + ...ctx.options.stubOptions.jiti, + alias: { + ...resolveAliases(ctx), + ...ctx.options.stubOptions.jiti.alias + } + }, + null, + 2 + ); + for (const entry of ctx.options.entries.filter( + (entry2) => entry2.builder === "rollup" + )) { + const output = (0, _pathe.resolve)( + ctx.options.rootDir, + ctx.options.outDir, + entry.name + ); + const resolvedEntry = (0, _pathe.normalize)( + tryResolve(entry.input, ctx.options.rootDir) || entry.input + ); + const resolvedEntryWithoutExt = resolvedEntry.slice( + 0, + Math.max(0, resolvedEntry.length - (0, _pathe.extname)(resolvedEntry).length) + ); + const code = await _nodeFs.promises.readFile(resolvedEntry, "utf8"); + const shebang = getShebang(code); + await (0, _promises.mkdir)((0, _pathe.dirname)(output), { recursive: true }); + if (ctx.options.rollup.emitCJS) { + await (0, _promises.writeFile)( + output + ".cjs", + `${shebang}module.exports = require(${JSON.stringify( + jitiPath + )})(null, ${serializedJitiOptions})(${JSON.stringify( + resolvedEntry + )})` + ); + } + const namedExports = await (0, _mlly.resolveModuleExportNames)( + resolvedEntry, + { + extensions: DEFAULT_EXTENSIONS + } + ).catch((error) => { + warn(ctx, `Cannot analyze ${resolvedEntry} for exports:` + error); + return []; + }); + const hasDefaultExport = namedExports.includes("default") || namedExports.length === 0; + await (0, _promises.writeFile)( + output + ".mjs", + shebang + [ + `import jiti from ${JSON.stringify((0, _nodeUrl.pathToFileURL)(jitiPath).href)};`, + "", + `/** @type {import(${JSON.stringify(resolvedEntryWithoutExt)})} */`, + `const _module = jiti(null, ${serializedJitiOptions})(${JSON.stringify( + resolvedEntry + )});`, + hasDefaultExport ? "\nexport default _module;" : "", + ...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)]. + join("\n") + ); + await (0, _promises.writeFile)( + output + ".d.ts", + [ + `export * from ${JSON.stringify(resolvedEntryWithoutExt)};`, + hasDefaultExport ? `export { default } from ${JSON.stringify( + resolvedEntryWithoutExt + )};` : ""]. + join("\n") + ); + if (shebang) { + await makeExecutable(output + ".cjs"); + await makeExecutable(output + ".mjs"); + } + } + await ctx.hooks.callHook("rollup:done", ctx); + return; + } + const rollupOptions = getRollupOptions(ctx); + await ctx.hooks.callHook("rollup:options", ctx, rollupOptions); + if (Object.keys(rollupOptions.input).length === 0) { + return; + } + const buildResult = await (0, _rollup.rollup)(rollupOptions); + await ctx.hooks.callHook("rollup:build", ctx, buildResult); + const allOutputOptions = rollupOptions.output; + for (const outputOptions of allOutputOptions) { + const { output } = await buildResult.write(outputOptions); + const chunkFileNames = /* @__PURE__ */new Set(); + const outputChunks = output.filter( + (e) => e.type === "chunk" + ); + for (const entry of outputChunks) { + chunkFileNames.add(entry.fileName); + for (const id of entry.imports) { + ctx.usedImports.add(id); + } + if (entry.isEntry) { + ctx.buildEntries.push({ + chunks: entry.imports.filter( + (i) => outputChunks.find((c) => c.fileName === i) + ), + modules: Object.entries(entry.modules).map(([id, mod]) => ({ + id, + bytes: mod.renderedLength + })), + path: entry.fileName, + bytes: Buffer.byteLength(entry.code, "utf8"), + exports: entry.exports + }); + } + } + for (const chunkFileName of chunkFileNames) { + ctx.usedImports.delete(chunkFileName); + } + } + if (ctx.options.declaration) { + rollupOptions.plugins = rollupOptions.plugins || []; + const shebangPlugin2 = rollupOptions.plugins.find( + (p) => p && p.name === "unbuild-shebang" + ); + shebangPlugin2._options.preserve = false; + rollupOptions.plugins.push((0, _rollupPluginDts.default)(ctx.options.rollup.dts)); + await ctx.hooks.callHook("rollup:dts:options", ctx, rollupOptions); + const typesBuild = await (0, _rollup.rollup)(rollupOptions); + await ctx.hooks.callHook("rollup:dts:build", ctx, typesBuild); + if (ctx.options.rollup.emitCJS) { + await typesBuild.write({ + dir: (0, _pathe.resolve)(ctx.options.rootDir, ctx.options.outDir), + entryFileNames: "[name].d.cts", + chunkFileNames: (chunk) => getChunkFilename(ctx, chunk, "d.cts") + }); + } + await typesBuild.write({ + dir: (0, _pathe.resolve)(ctx.options.rootDir, ctx.options.outDir), + entryFileNames: "[name].d.mts", + chunkFileNames: (chunk) => getChunkFilename(ctx, chunk, "d.mts") + }); + if (ctx.options.declaration === true || ctx.options.declaration === "compatible") { + await typesBuild.write({ + dir: (0, _pathe.resolve)(ctx.options.rootDir, ctx.options.outDir), + entryFileNames: "[name].d.ts", + chunkFileNames: (chunk) => getChunkFilename(ctx, chunk, "d.ts") + }); + } + } + await ctx.hooks.callHook("rollup:done", ctx); +} +const getChunkFilename = (ctx, chunk, ext) => { + if (chunk.isDynamicEntry) { + return `chunks/[name].${ext}`; + } + return `shared/${ctx.options.name}.[hash].${ext}`; +}; +function getRollupOptions(ctx) { + return { + input: Object.fromEntries( + ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [ + entry.name, + (0, _pathe.resolve)(ctx.options.rootDir, entry.input)] + ) + ), + output: [ + ctx.options.rollup.emitCJS && { + dir: (0, _pathe.resolve)(ctx.options.rootDir, ctx.options.outDir), + entryFileNames: "[name].cjs", + chunkFileNames: (chunk) => getChunkFilename(ctx, chunk, "cjs"), + format: "cjs", + exports: "auto", + interop: "compat", + generatedCode: { constBindings: true }, + externalLiveBindings: false, + freeze: false, + sourcemap: ctx.options.sourcemap, + ...ctx.options.rollup.output + }, + { + dir: (0, _pathe.resolve)(ctx.options.rootDir, ctx.options.outDir), + entryFileNames: "[name].mjs", + chunkFileNames: (chunk) => getChunkFilename(ctx, chunk, "mjs"), + format: "esm", + exports: "auto", + generatedCode: { constBindings: true }, + externalLiveBindings: false, + freeze: false, + sourcemap: ctx.options.sourcemap, + ...ctx.options.rollup.output + }]. + filter(Boolean), + external(id) { + const pkg = getpkg(id); + const isExplicitExternal = arrayIncludes(ctx.options.externals, pkg) || arrayIncludes(ctx.options.externals, id); + if (isExplicitExternal) { + return true; + } + if (ctx.options.rollup.inlineDependencies || id[0] === "." || (0, _pathe.isAbsolute)(id) || /src[/\\]/.test(id) || id.startsWith(ctx.pkg.name)) { + return false; + } + if (!isExplicitExternal) { + warn(ctx, `Inlined implicit external ${id}`); + } + return isExplicitExternal; + }, + onwarn(warning, rollupWarn) { + if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) { + rollupWarn(warning); + } + }, + plugins: [ + ctx.options.rollup.replace && (0, _pluginReplace.default)({ + ...ctx.options.rollup.replace, + values: { + ...ctx.options.replace, + ...ctx.options.rollup.replace.values + } + }), + ctx.options.rollup.alias && (0, _pluginAlias.default)({ + ...ctx.options.rollup.alias, + entries: resolveAliases(ctx) + }), + ctx.options.rollup.resolve && (0, _pluginNodeResolve.nodeResolve)({ + extensions: DEFAULT_EXTENSIONS, + ...ctx.options.rollup.resolve + }), + ctx.options.rollup.json && JSONPlugin({ + ...ctx.options.rollup.json + }), + shebangPlugin(), + ctx.options.rollup.esbuild && esbuild({ + sourcemap: ctx.options.sourcemap, + ...ctx.options.rollup.esbuild + }), + ctx.options.rollup.commonjs && (0, _pluginCommonjs.default)({ + extensions: DEFAULT_EXTENSIONS, + ...ctx.options.rollup.commonjs + }), + // Preserve dynamic imports for CommonJS + { + renderDynamicImport() { + return { left: "import(", right: ")" }; + } + }, + ctx.options.rollup.cjsBridge && cjsPlugin(), + rawPlugin()]. + filter(Boolean) + }; +} +function resolveAliases(ctx) { + const aliases = { + [ctx.pkg.name]: ctx.options.rootDir, + ...ctx.options.alias + }; + if (ctx.options.rollup.alias) { + if (Array.isArray(ctx.options.rollup.alias.entries)) { + Object.assign( + aliases, + Object.fromEntries( + ctx.options.rollup.alias.entries.map((entry) => { + return [entry.find, entry.replacement]; + }) + ) + ); + } else { + Object.assign( + aliases, + ctx.options.rollup.alias.entries || ctx.options.rollup.alias + ); + } + } + return aliases; +} + +async function typesBuild(ctx) { + const entries = ctx.options.entries.filter( + (entry) => entry.builder === "untyped" + ); + await ctx.hooks.callHook("untyped:entries", ctx, entries); + for (const entry of entries) { + const options = { + jiti: { + esmResolve: true, + interopDefault: true, + transformOptions: { + babel: { + plugins: [_babelPlugin.default] + } + } + } + }; + await ctx.hooks.callHook("untyped:entry:options", ctx, entry, options); + const _require = (0, _jiti.default)(ctx.options.rootDir, options.jiti); + const distDir = entry.outDir; + const srcConfig = _require((0, _pathe.resolve)(ctx.options.rootDir, entry.input)); + const defaults = entry.defaults || {}; + const schema = await (0, _untyped.resolveSchema)(srcConfig, defaults); + await ctx.hooks.callHook("untyped:entry:schema", ctx, entry, schema); + const outputs = { + markdown: { + fileName: (0, _pathe.resolve)(distDir, `${entry.name}.md`), + contents: (0, _untyped.generateMarkdown)(schema) + }, + schema: { + fileName: `${entry.name}.schema.json`, + contents: JSON.stringify(schema, null, 2) + }, + defaults: { + fileName: `${entry.name}.defaults.json`, + contents: JSON.stringify(defaults, null, 2) + }, + declaration: entry.declaration ? { + fileName: `${entry.name}.d.ts`, + contents: (0, _untyped.generateTypes)(schema, { + interfaceName: (0, _scule.pascalCase)(entry.name + "-schema") + }) + } : void 0 + }; + await ctx.hooks.callHook("untyped:entry:outputs", ctx, entry, outputs); + for (const output of Object.values(outputs)) { + await (0, _promises.writeFile)( + (0, _pathe.resolve)(distDir, output.fileName), + output.contents, + "utf8" + ); + } + } + await ctx.hooks.callHook("untyped:done", ctx); +} + +async function mkdistBuild(ctx) { + const entries = ctx.options.entries.filter( + (e) => e.builder === "mkdist" + ); + await ctx.hooks.callHook("mkdist:entries", ctx, entries); + for (const entry of entries) { + const distDir = entry.outDir; + if (ctx.options.stub) { + await rmdir(distDir); + await symlink(entry.input, distDir); + } else { + const mkdistOptions = { + rootDir: ctx.options.rootDir, + srcDir: entry.input, + distDir, + cleanDist: false, + ...entry + }; + await ctx.hooks.callHook( + "mkdist:entry:options", + ctx, + entry, + mkdistOptions + ); + const output = await (0, _mkdist.mkdist)(mkdistOptions); + ctx.buildEntries.push({ + path: distDir, + chunks: output.writtenFiles.map((p) => (0, _pathe.relative)(ctx.options.outDir, p)) + }); + await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output); + } + } + await ctx.hooks.callHook("mkdist:done", ctx); +} + +async function build(rootDir, stub, inputConfig = {}) { + rootDir = (0, _pathe.resolve)(process.cwd(), rootDir || "."); + const _buildConfig = tryRequire("./build.config", rootDir) || {}; + const buildConfigs = (Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]).filter(Boolean); + const pkg = tryRequire("./package.json", rootDir) || {}; + const cleanedDirs = []; + for (const buildConfig of buildConfigs) { + await _build(rootDir, stub, inputConfig, buildConfig, pkg, cleanedDirs); + } +} +async function _build(rootDir, stub, inputConfig = {}, buildConfig, pkg, cleanedDirs) { + const preset = resolvePreset( + buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || inputConfig.preset || "auto", + rootDir + ); + const options = (0, _defu.defu)( + buildConfig, + pkg.unbuild || pkg.build, + inputConfig, + preset, + { + name: (pkg?.name || "").split("/").pop() || "default", + rootDir, + entries: [], + clean: true, + declaration: false, + outDir: "dist", + stub, + stubOptions: { + /** + * See https://github.com/unjs/jiti#options + */ + jiti: { + esmResolve: true, + interopDefault: true, + alias: {} + } + }, + externals: [ + ..._nodeModule.default.builtinModules, + ..._nodeModule.default.builtinModules.map((m) => "node:" + m)], + + dependencies: [], + devDependencies: [], + peerDependencies: [], + alias: {}, + replace: {}, + failOnWarn: true, + sourcemap: false, + rollup: { + emitCJS: false, + cjsBridge: false, + inlineDependencies: false, + // Plugins + replace: { + preventAssignment: true + }, + alias: {}, + resolve: { + preferBuiltins: true + }, + json: { + preferConst: true + }, + commonjs: { + ignoreTryCatch: true + }, + esbuild: { target: "es2020" }, + dts: { + // https://github.com/Swatinem/rollup-plugin-dts/issues/143 + compilerOptions: { preserveSymlinks: false }, + respectExternal: true + } + } + } + ); + options.outDir = (0, _pathe.resolve)(options.rootDir, options.outDir); + const ctx = { + options, + warnings: /* @__PURE__ */new Set(), + pkg, + buildEntries: [], + usedImports: /* @__PURE__ */new Set(), + hooks: (0, _hookable.createHooks)() + }; + if (preset.hooks) { + ctx.hooks.addHooks(preset.hooks); + } + if (inputConfig.hooks) { + ctx.hooks.addHooks(inputConfig.hooks); + } + if (buildConfig.hooks) { + ctx.hooks.addHooks(buildConfig.hooks); + } + await ctx.hooks.callHook("build:prepare", ctx); + options.entries = options.entries.map( + (entry) => typeof entry === "string" ? { input: entry } : entry + ); + for (const entry of options.entries) { + if (typeof entry.name !== "string") { + let relativeInput = (0, _pathe.isAbsolute)(entry.input) ? (0, _pathe.relative)(rootDir, entry.input) : (0, _pathe.normalize)(entry.input); + if (relativeInput.startsWith("./")) { + relativeInput = relativeInput.slice(2); + } + entry.name = removeExtension(relativeInput.replace(/^src\//, "")); + } + if (!entry.input) { + throw new Error("Missing entry input: " + dumpObject(entry)); + } + if (!entry.builder) { + entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup"; + } + if (options.declaration !== void 0 && entry.declaration === void 0) { + entry.declaration = options.declaration; + } + entry.input = (0, _pathe.resolve)(options.rootDir, entry.input); + entry.outDir = (0, _pathe.resolve)(options.rootDir, entry.outDir || options.outDir); + } + options.dependencies = Object.keys(pkg.dependencies || {}); + options.peerDependencies = Object.keys(pkg.peerDependencies || {}); + options.devDependencies = Object.keys(pkg.devDependencies || {}); + options.externals.push(...options.dependencies, ...options.peerDependencies); + await ctx.hooks.callHook("build:before", ctx); + _consola.consola.info( + _chalk.default.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`) + ); + if (process.env.DEBUG) { + _consola.consola.info(`${_chalk.default.bold("Root dir:")} ${options.rootDir} + ${_chalk.default.bold("Entries:")} + ${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")} +`); + } + if (options.clean) { + for (const dir of new Set( + options.entries.map((e) => e.outDir).filter(Boolean).sort() + )) { + if (cleanedDirs.some((c) => dir.startsWith(c))) { + continue; + } + cleanedDirs.push(dir); + _consola.consola.info( + `Cleaning dist directory: \`./${(0, _pathe.relative)(process.cwd(), dir)}\`` + ); + await rmdir(dir); + await _nodeFs.promises.mkdir(dir, { recursive: true }); + } + } + await typesBuild(ctx); + await mkdistBuild(ctx); + await rollupBuild(ctx); + if (options.stub) { + await ctx.hooks.callHook("build:done", ctx); + return; + } + _consola.consola.success(_chalk.default.green("Build succeeded for " + options.name)); + const outFiles = await (0, _globby.globby)("**", { cwd: options.outDir }); + for (const file of outFiles) { + let entry = ctx.buildEntries.find((e) => e.path === file); + if (!entry) { + entry = { + path: file, + chunk: true + }; + ctx.buildEntries.push(entry); + } + if (!entry.bytes) { + const stat = await _nodeFs.promises.stat((0, _pathe.resolve)(options.outDir, file)); + entry.bytes = stat.size; + } + } + const rPath = (p) => (0, _pathe.relative)(process.cwd(), (0, _pathe.resolve)(options.outDir, p)); + for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) { + let totalBytes = entry.bytes || 0; + for (const chunk of entry.chunks || []) { + totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0; + } + let line = ` ${_chalk.default.bold(rPath(entry.path))} (` + [ + totalBytes && `total size: ${_chalk.default.cyan((0, _prettyBytes.default)(totalBytes))}`, + entry.bytes && `chunk size: ${_chalk.default.cyan((0, _prettyBytes.default)(entry.bytes))}`, + entry.exports?.length && `exports: ${_chalk.default.gray(entry.exports.join(", "))}`]. + filter(Boolean).join(", ") + ")"; + if (entry.chunks?.length) { + line += "\n" + entry.chunks.map((p) => { + const chunk = ctx.buildEntries.find((e) => e.path === p) || {}; + return _chalk.default.gray( + " \u2514\u2500 " + rPath(p) + _chalk.default.bold( + chunk.bytes ? ` (${(0, _prettyBytes.default)(chunk?.bytes)})` : "" + ) + ); + }).join("\n"); + } + if (entry.modules?.length) { + line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => { + return _chalk.default.gray( + " \u{1F4E6} " + rPath(m.id) + _chalk.default.bold(m.bytes ? ` (${(0, _prettyBytes.default)(m.bytes)})` : "") + ); + }).join("\n"); + } + _consola.consola.log(entry.chunk ? _chalk.default.gray(line) : line); + } + console.log( + "\u03A3 Total dist size (byte size):", + _chalk.default.cyan( + (0, _prettyBytes.default)(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0)) + ) + ); + validateDependencies(ctx); + validatePackage(pkg, rootDir, ctx); + await ctx.hooks.callHook("build:done", ctx); + _consola.consola.log(""); + if (ctx.warnings.size > 0) { + _consola.consola.warn( + "Build is done with some warnings:\n\n" + [...ctx.warnings].map((msg) => "- " + msg).join("\n") + ); + if (ctx.options.failOnWarn) { + _consola.consola.error( + "Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ." + ); + process.exit(1); + } + } +} /* v7-3b6eca811e065baf */ \ No newline at end of file diff --git a/node-jiti/globby-ignore.js.9e7ed82c.js b/node-jiti/globby-ignore.js.9e7ed82c.js new file mode 100644 index 0000000..aeb38a4 --- /dev/null +++ b/node-jiti/globby-ignore.js.9e7ed82c.js @@ -0,0 +1,94 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.isIgnoredByIgnoreFilesSync = exports.isIgnoredByIgnoreFiles = exports.isGitIgnoredSync = exports.isGitIgnored = exports.GITIGNORE_FILES_PATTERN = void 0;var _nodeProcess = _interopRequireDefault(require("node:process")); +var _nodeFs = _interopRequireDefault(require("node:fs")); +var _nodePath = _interopRequireDefault(require("node:path")); +var _fastGlob = _interopRequireDefault(require("fast-glob")); +var _ignore = _interopRequireDefault(require("ignore")); +var _slash = _interopRequireDefault(require("slash")); +var _utilities = require("./utilities.js");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} + +const ignoreFilesGlobOptions = { + ignore: [ + '**/node_modules', + '**/flow-typed', + '**/coverage', + '**/.git'], + + absolute: true, + dot: true +}; + +const GITIGNORE_FILES_PATTERN = '**/.gitignore';exports.GITIGNORE_FILES_PATTERN = GITIGNORE_FILES_PATTERN; + +const applyBaseToPattern = (pattern, base) => (0, _utilities.isNegativePattern)(pattern) ? +'!' + _nodePath.default.posix.join(base, pattern.slice(1)) : +_nodePath.default.posix.join(base, pattern); + +const parseIgnoreFile = (file, cwd) => { + const base = (0, _slash.default)(_nodePath.default.relative(cwd, _nodePath.default.dirname(file.filePath))); + + return file.content. + split(/\r?\n/). + filter((line) => line && !line.startsWith('#')). + map((pattern) => applyBaseToPattern(pattern, base)); +}; + +const toRelativePath = (fileOrDirectory, cwd) => { + cwd = (0, _slash.default)(cwd); + if (_nodePath.default.isAbsolute(fileOrDirectory)) { + if ((0, _slash.default)(fileOrDirectory).startsWith(cwd)) { + return _nodePath.default.relative(cwd, fileOrDirectory); + } + + throw new Error(`Path ${fileOrDirectory} is not in cwd ${cwd}`); + } + + return fileOrDirectory; +}; + +const getIsIgnoredPredicate = (files, cwd) => { + const patterns = files.flatMap((file) => parseIgnoreFile(file, cwd)); + const ignores = (0, _ignore.default)().add(patterns); + + return (fileOrDirectory) => { + fileOrDirectory = (0, _utilities.toPath)(fileOrDirectory); + fileOrDirectory = toRelativePath(fileOrDirectory, cwd); + return fileOrDirectory ? ignores.ignores((0, _slash.default)(fileOrDirectory)) : false; + }; +}; + +const normalizeOptions = (options = {}) => ({ + cwd: (0, _utilities.toPath)(options.cwd) || _nodeProcess.default.cwd(), + suppressErrors: Boolean(options.suppressErrors), + deep: typeof options.deep === 'number' ? options.deep : Number.POSITIVE_INFINITY +}); + +const isIgnoredByIgnoreFiles = async (patterns, options) => { + const { cwd, suppressErrors, deep } = normalizeOptions(options); + + const paths = await (0, _fastGlob.default)(patterns, { cwd, suppressErrors, deep, ...ignoreFilesGlobOptions }); + + const files = await Promise.all( + paths.map(async (filePath) => ({ + filePath, + content: await _nodeFs.default.promises.readFile(filePath, 'utf8') + })) + ); + + return getIsIgnoredPredicate(files, cwd); +};exports.isIgnoredByIgnoreFiles = isIgnoredByIgnoreFiles; + +const isIgnoredByIgnoreFilesSync = (patterns, options) => { + const { cwd, suppressErrors, deep } = normalizeOptions(options); + + const paths = _fastGlob.default.sync(patterns, { cwd, suppressErrors, deep, ...ignoreFilesGlobOptions }); + + const files = paths.map((filePath) => ({ + filePath, + content: _nodeFs.default.readFileSync(filePath, 'utf8') + })); + + return getIsIgnoredPredicate(files, cwd); +};exports.isIgnoredByIgnoreFilesSync = isIgnoredByIgnoreFilesSync; + +const isGitIgnored = (options) => isIgnoredByIgnoreFiles(GITIGNORE_FILES_PATTERN, options);exports.isGitIgnored = isGitIgnored; +const isGitIgnoredSync = (options) => isIgnoredByIgnoreFilesSync(GITIGNORE_FILES_PATTERN, options);exports.isGitIgnoredSync = isGitIgnoredSync; /* v7-0eff28242bf3ace2 */ \ No newline at end of file diff --git a/node-jiti/globby-index.js.3099c3b4.js b/node-jiti/globby-index.js.3099c3b4.js new file mode 100644 index 0000000..5fee3c6 --- /dev/null +++ b/node-jiti/globby-index.js.3099c3b4.js @@ -0,0 +1,224 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.isDynamicPattern = exports.globbySync = exports.globbyStream = exports.globby = exports.generateGlobTasksSync = exports.generateGlobTasks = void 0;Object.defineProperty(exports, "isGitIgnored", { enumerable: true, get: function () {return _ignore.isGitIgnored;} });Object.defineProperty(exports, "isGitIgnoredSync", { enumerable: true, get: function () {return _ignore.isGitIgnoredSync;} });var _nodeFs = _interopRequireDefault(require("node:fs")); +var _nodePath = _interopRequireDefault(require("node:path")); +var _merge = _interopRequireDefault(require("merge2")); +var _fastGlob = _interopRequireDefault(require("fast-glob")); +var _dirGlob = _interopRequireDefault(require("dir-glob")); +var _ignore = require("./ignore.js"); + + + + +var _utilities = require("./utilities.js");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} + +const assertPatternsInput = (patterns) => { + if (patterns.some((pattern) => typeof pattern !== 'string')) { + throw new TypeError('Patterns must be a string or an array of strings'); + } +}; + +const toPatternsArray = (patterns) => { + patterns = [...new Set([patterns].flat())]; + assertPatternsInput(patterns); + return patterns; +}; + +const checkCwdOption = (options) => { + if (!options.cwd) { + return; + } + + let stat; + try { + stat = _nodeFs.default.statSync(options.cwd); + } catch { + return; + } + + if (!stat.isDirectory()) { + throw new Error('The `cwd` option must be a path to a directory'); + } +}; + +const normalizeOptions = (options = {}) => { + options = { + ...options, + ignore: options.ignore || [], + expandDirectories: options.expandDirectories === undefined ? + true : + options.expandDirectories, + cwd: (0, _utilities.toPath)(options.cwd) + }; + + checkCwdOption(options); + + return options; +}; + +const normalizeArguments = (fn) => async (patterns, options) => fn(toPatternsArray(patterns), normalizeOptions(options)); +const normalizeArgumentsSync = (fn) => (patterns, options) => fn(toPatternsArray(patterns), normalizeOptions(options)); + +const getIgnoreFilesPatterns = (options) => { + const { ignoreFiles, gitignore } = options; + + const patterns = ignoreFiles ? toPatternsArray(ignoreFiles) : []; + if (gitignore) { + patterns.push(_ignore.GITIGNORE_FILES_PATTERN); + } + + return patterns; +}; + +const getFilter = async (options) => { + const ignoreFilesPatterns = getIgnoreFilesPatterns(options); + return createFilterFunction( + ignoreFilesPatterns.length > 0 && (await (0, _ignore.isIgnoredByIgnoreFiles)(ignoreFilesPatterns, options)) + ); +}; + +const getFilterSync = (options) => { + const ignoreFilesPatterns = getIgnoreFilesPatterns(options); + return createFilterFunction( + ignoreFilesPatterns.length > 0 && (0, _ignore.isIgnoredByIgnoreFilesSync)(ignoreFilesPatterns, options) + ); +}; + +const createFilterFunction = (isIgnored) => { + const seen = new Set(); + + return (fastGlobResult) => { + const path = fastGlobResult.path || fastGlobResult; + const pathKey = _nodePath.default.normalize(path); + const seenOrIgnored = seen.has(pathKey) || isIgnored && isIgnored(path); + seen.add(pathKey); + return !seenOrIgnored; + }; +}; + +const unionFastGlobResults = (results, filter) => results.flat().filter((fastGlobResult) => filter(fastGlobResult)); +const unionFastGlobStreams = (streams, filter) => (0, _merge.default)(streams).pipe(new _utilities.FilterStream((fastGlobResult) => filter(fastGlobResult))); + +const convertNegativePatterns = (patterns, options) => { + const tasks = []; + + while (patterns.length > 0) { + const index = patterns.findIndex((pattern) => (0, _utilities.isNegativePattern)(pattern)); + + if (index === -1) { + tasks.push({ patterns, options }); + break; + } + + const ignorePattern = patterns[index].slice(1); + + for (const task of tasks) { + task.options.ignore.push(ignorePattern); + } + + if (index !== 0) { + tasks.push({ + patterns: patterns.slice(0, index), + options: { + ...options, + ignore: [ + ...options.ignore, + ignorePattern] + + } + }); + } + + patterns = patterns.slice(index + 1); + } + + return tasks; +}; + +const getDirGlobOptions = (options, cwd) => ({ + ...(cwd ? { cwd } : {}), + ...(Array.isArray(options) ? { files: options } : options) +}); + +const generateTasks = async (patterns, options) => { + const globTasks = convertNegativePatterns(patterns, options); + + const { cwd, expandDirectories } = options; + + if (!expandDirectories) { + return globTasks; + } + + const patternExpandOptions = getDirGlobOptions(expandDirectories, cwd); + const ignoreExpandOptions = cwd ? { cwd } : undefined; + + return Promise.all( + globTasks.map(async (task) => { + let { patterns, options } = task; + + [ + patterns, + options.ignore] = + await Promise.all([ + (0, _dirGlob.default)(patterns, patternExpandOptions), + (0, _dirGlob.default)(options.ignore, ignoreExpandOptions)] + ); + + return { patterns, options }; + }) + ); +}; + +const generateTasksSync = (patterns, options) => { + const globTasks = convertNegativePatterns(patterns, options); + + const { cwd, expandDirectories } = options; + + if (!expandDirectories) { + return globTasks; + } + + const patternExpandOptions = getDirGlobOptions(expandDirectories, cwd); + const ignoreExpandOptions = cwd ? { cwd } : undefined; + + return globTasks.map((task) => { + let { patterns, options } = task; + patterns = _dirGlob.default.sync(patterns, patternExpandOptions); + options.ignore = _dirGlob.default.sync(options.ignore, ignoreExpandOptions); + return { patterns, options }; + }); +}; + +const globby = normalizeArguments(async (patterns, options) => { + const [ + tasks, + filter] = + await Promise.all([ + generateTasks(patterns, options), + getFilter(options)] + ); + const results = await Promise.all(tasks.map((task) => (0, _fastGlob.default)(task.patterns, task.options))); + + return unionFastGlobResults(results, filter); +});exports.globby = globby; + +const globbySync = normalizeArgumentsSync((patterns, options) => { + const tasks = generateTasksSync(patterns, options); + const filter = getFilterSync(options); + const results = tasks.map((task) => _fastGlob.default.sync(task.patterns, task.options)); + + return unionFastGlobResults(results, filter); +});exports.globbySync = globbySync; + +const globbyStream = normalizeArgumentsSync((patterns, options) => { + const tasks = generateTasksSync(patterns, options); + const filter = getFilterSync(options); + const streams = tasks.map((task) => _fastGlob.default.stream(task.patterns, task.options)); + + return unionFastGlobStreams(streams, filter); +});exports.globbyStream = globbyStream; + +const isDynamicPattern = normalizeArgumentsSync( + (patterns, options) => patterns.some((pattern) => _fastGlob.default.isDynamicPattern(pattern, options)) +);exports.isDynamicPattern = isDynamicPattern; + +const generateGlobTasks = normalizeArguments(generateTasks);exports.generateGlobTasks = generateGlobTasks; +const generateGlobTasksSync = normalizeArgumentsSync(generateTasksSync);exports.generateGlobTasksSync = generateGlobTasksSync; /* v7-5fbae7b710226867 */ \ No newline at end of file diff --git a/node-jiti/globby-utilities.js.1301fda1.js b/node-jiti/globby-utilities.js.1301fda1.js new file mode 100644 index 0000000..af5fe2a --- /dev/null +++ b/node-jiti/globby-utilities.js.1301fda1.js @@ -0,0 +1,17 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.toPath = exports.isNegativePattern = exports.FilterStream = void 0;var _nodeUrl = require("node:url"); +var _nodeStream = require("node:stream"); + +const toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, _nodeUrl.fileURLToPath)(urlOrPath) : urlOrPath;exports.toPath = toPath; + +class FilterStream extends _nodeStream.Transform { + constructor(filter) { + super({ + objectMode: true, + transform(data, encoding, callback) { + callback(undefined, filter(data) ? data : undefined); + } + }); + } +}exports.FilterStream = FilterStream; + +const isNegativePattern = (pattern) => pattern[0] === '!';exports.isNegativePattern = isNegativePattern; /* v7-259a918aa3543465 */ \ No newline at end of file diff --git a/node-jiti/pretty-bytes-index.js.d5f02b85.js b/node-jiti/pretty-bytes-index.js.d5f02b85.js new file mode 100644 index 0000000..c13fae2 --- /dev/null +++ b/node-jiti/pretty-bytes-index.js.d5f02b85.js @@ -0,0 +1,122 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = prettyBytes;const BYTE_UNITS = [ +'B', +'kB', +'MB', +'GB', +'TB', +'PB', +'EB', +'ZB', +'YB']; + + +const BIBYTE_UNITS = [ +'B', +'KiB', +'MiB', +'GiB', +'TiB', +'PiB', +'EiB', +'ZiB', +'YiB']; + + +const BIT_UNITS = [ +'b', +'kbit', +'Mbit', +'Gbit', +'Tbit', +'Pbit', +'Ebit', +'Zbit', +'Ybit']; + + +const BIBIT_UNITS = [ +'b', +'kibit', +'Mibit', +'Gibit', +'Tibit', +'Pibit', +'Eibit', +'Zibit', +'Yibit']; + + +/* +Formats the given number using `Number#toLocaleString`. +- If locale is a string, the value is expected to be a locale-key (for example: `de`). +- If locale is true, the system default locale is used for translation. +- If no value for locale is specified, the number is returned unmodified. +*/ +const toLocaleString = (number, locale, options) => { + let result = number; + if (typeof locale === 'string' || Array.isArray(locale)) { + result = number.toLocaleString(locale, options); + } else if (locale === true || options !== undefined) { + result = number.toLocaleString(undefined, options); + } + + return result; +}; + +function prettyBytes(number, options) { + if (!Number.isFinite(number)) { + throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`); + } + + options = { + bits: false, + binary: false, + space: true, + ...options + }; + + const UNITS = options.bits ? + options.binary ? BIBIT_UNITS : BIT_UNITS : + options.binary ? BIBYTE_UNITS : BYTE_UNITS; + + const separator = options.space ? ' ' : ''; + + if (options.signed && number === 0) { + return ` 0${separator}${UNITS[0]}`; + } + + const isNegative = number < 0; + const prefix = isNegative ? '-' : options.signed ? '+' : ''; + + if (isNegative) { + number = -number; + } + + let localeOptions; + + if (options.minimumFractionDigits !== undefined) { + localeOptions = { minimumFractionDigits: options.minimumFractionDigits }; + } + + if (options.maximumFractionDigits !== undefined) { + localeOptions = { maximumFractionDigits: options.maximumFractionDigits, ...localeOptions }; + } + + if (number < 1) { + const numberString = toLocaleString(number, options.locale, localeOptions); + return prefix + numberString + separator + UNITS[0]; + } + + const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1); + number /= (options.binary ? 1024 : 1000) ** exponent; + + if (!localeOptions) { + number = number.toPrecision(3); + } + + const numberString = toLocaleString(Number(number), options.locale, localeOptions); + + const unit = UNITS[exponent]; + + return prefix + numberString + separator + unit; +} /* v7-a4da9a491bb897bd */ \ No newline at end of file diff --git a/node-jiti/slash-index.js.81d35a80.js b/node-jiti/slash-index.js.81d35a80.js new file mode 100644 index 0000000..ceb0bcd --- /dev/null +++ b/node-jiti/slash-index.js.81d35a80.js @@ -0,0 +1,10 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = slash;function slash(path) { + const isExtendedLengthPath = /^\\\\\?\\/.test(path); + const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex + + if (isExtendedLengthPath || hasNonAscii) { + return path; + } + + return path.replace(/\\/g, '/'); +} /* v7-56da1c6249207534 */ \ No newline at end of file diff --git a/node-jiti/source-index.js.6f194ce0.js b/node-jiti/source-index.js.6f194ce0.js new file mode 100644 index 0000000..64f5453 --- /dev/null +++ b/node-jiti/source-index.js.6f194ce0.js @@ -0,0 +1,225 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.Chalk = void 0;Object.defineProperty(exports, "backgroundColorNames", { enumerable: true, get: function () {return _index.backgroundColorNames;} });Object.defineProperty(exports, "backgroundColors", { enumerable: true, get: function () {return _index.backgroundColorNames;} });exports.chalkStderr = void 0;Object.defineProperty(exports, "colorNames", { enumerable: true, get: function () {return _index.colorNames;} });Object.defineProperty(exports, "colors", { enumerable: true, get: function () {return _index.colorNames;} });exports.default = void 0;Object.defineProperty(exports, "foregroundColorNames", { enumerable: true, get: function () {return _index.foregroundColorNames;} });Object.defineProperty(exports, "foregroundColors", { enumerable: true, get: function () {return _index.foregroundColorNames;} });Object.defineProperty(exports, "modifierNames", { enumerable: true, get: function () {return _index.modifierNames;} });Object.defineProperty(exports, "modifiers", { enumerable: true, get: function () {return _index.modifierNames;} });exports.supportsColorStderr = exports.supportsColor = void 0;var _ansiStyles = _interopRequireDefault(require("#ansi-styles")); +var _supportsColor = _interopRequireDefault(require("#supports-color")); +var _utilities = require("./utilities.js"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var _index = require("./vendor/ansi-styles/index.js");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}const { stdout: stdoutColor, stderr: stderrColor } = _supportsColor.default;exports.supportsColorStderr = stderrColor;exports.supportsColor = stdoutColor;const GENERATOR = Symbol('GENERATOR');const STYLER = Symbol('STYLER');const IS_EMPTY = Symbol('IS_EMPTY'); // `supportsColor.level` → `ansiStyles.color[name]` mapping +const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];const styles = Object.create(null);const applyOptions = (object, options = {}) => {if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {throw new Error('The `level` option should be an integer from 0 to 3');} // Detect level if not set manually + const colorLevel = stdoutColor ? stdoutColor.level : 0;object.level = options.level === undefined ? colorLevel : options.level;};class Chalk {constructor(options) {// eslint-disable-next-line no-constructor-return + return chalkFactory(options);}}exports.Chalk = Chalk;const chalkFactory = (options) => {const chalk = (...strings) => strings.join(' ');applyOptions(chalk, options);Object.setPrototypeOf(chalk, createChalk.prototype);return chalk;};function createChalk(options) {return chalkFactory(options);}Object.setPrototypeOf(createChalk.prototype, Function.prototype);for (const [styleName, style] of Object.entries(_ansiStyles.default)) {styles[styleName] = { get() {const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);Object.defineProperty(this, styleName, { value: builder });return builder;} };}styles.visible = { get() {const builder = createBuilder(this, this[STYLER], true);Object.defineProperty(this, 'visible', { value: builder });return builder;} };const getModelAnsi = (model, level, type, ...arguments_) => {if (model === 'rgb') {if (level === 'ansi16m') {return _ansiStyles.default[type].ansi16m(...arguments_);}if (level === 'ansi256') {return _ansiStyles.default[type].ansi256(_ansiStyles.default.rgbToAnsi256(...arguments_));}return _ansiStyles.default[type].ansi(_ansiStyles.default.rgbToAnsi(...arguments_));}if (model === 'hex') {return getModelAnsi('rgb', level, type, ..._ansiStyles.default.hexToRgb(...arguments_));}return _ansiStyles.default[type][model](...arguments_);};const usedModels = ['rgb', 'hex', 'ansi256'];for (const model of usedModels) {styles[model] = { get() {const { level } = this;return function (...arguments_) {const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), _ansiStyles.default.color.close, this[STYLER]);return createBuilder(this, styler, this[IS_EMPTY]);};} };const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);styles[bgModel] = { get() {const { level } = this;return function (...arguments_) {const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), _ansiStyles.default.bgColor.close, this[STYLER]);return createBuilder(this, styler, this[IS_EMPTY]);};} };}const proto = Object.defineProperties(() => {}, { ...styles, level: { enumerable: true, get() {return this[GENERATOR].level;}, set(level) {this[GENERATOR].level = level;} } });const createStyler = (open, close, parent) => {let openAll;let closeAll;if (parent === undefined) {openAll = open;closeAll = close;} else {openAll = parent.openAll + open;closeAll = close + parent.closeAll;}return { open, close, openAll, closeAll, parent };};const createBuilder = (self, _styler, _isEmpty) => {// Single argument is hot path, implicit coercion is faster than anything + // eslint-disable-next-line no-implicit-coercion + const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' ')); // We alter the prototype because we must return a function, but there is + // no way to create a function with a different prototype + Object.setPrototypeOf(builder, proto);builder[GENERATOR] = self;builder[STYLER] = _styler;builder[IS_EMPTY] = _isEmpty;return builder;};const applyStyle = (self, string) => {if (self.level <= 0 || !string) {return self[IS_EMPTY] ? '' : string;}let styler = self[STYLER];if (styler === undefined) {return string;}const { openAll, closeAll } = styler;if (string.includes('\u001B')) {while (styler !== undefined) {// Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + string = (0, _utilities.stringReplaceAll)(string, styler.close, styler.open);styler = styler.parent;}} // We can move both next actions out of loop, because remaining actions in loop won't have + // any/visible effect on parts we add here. Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 + const lfIndex = string.indexOf('\n');if (lfIndex !== -1) {string = (0, _utilities.stringEncaseCRLFWithFirstIndex)(string, closeAll, openAll, lfIndex);}return openAll + string + closeAll;};Object.defineProperties(createChalk.prototype, styles);const chalk = createChalk();const chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });exports.chalkStderr = chalkStderr;var _default = + + + + +chalk;exports.default = _default; /* v7-ee09f19624a0936b */ \ No newline at end of file diff --git a/node-jiti/source-utilities.js.1db818e4.js b/node-jiti/source-utilities.js.1db818e4.js new file mode 100644 index 0000000..8344e64 --- /dev/null +++ b/node-jiti/source-utilities.js.1db818e4.js @@ -0,0 +1,33 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.stringEncaseCRLFWithFirstIndex = stringEncaseCRLFWithFirstIndex;exports.stringReplaceAll = stringReplaceAll; // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`. +function stringReplaceAll(string, substring, replacer) { + let index = string.indexOf(substring); + if (index === -1) { + return string; + } + + const substringLength = substring.length; + let endIndex = 0; + let returnValue = ''; + do { + returnValue += string.slice(endIndex, index) + substring + replacer; + endIndex = index + substringLength; + index = string.indexOf(substring, endIndex); + } while (index !== -1); + + returnValue += string.slice(endIndex); + return returnValue; +} + +function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { + let endIndex = 0; + let returnValue = ''; + do { + const gotCR = string[index - 1] === '\r'; + returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? '\r\n' : '\n') + postfix; + endIndex = index + 1; + index = string.indexOf('\n', endIndex); + } while (index !== -1); + + returnValue += string.slice(endIndex); + return returnValue; +} /* v7-255e1aba69efb0ea */ \ No newline at end of file diff --git a/node-jiti/stylelint-config-build.config.ts.497ea15a.js b/node-jiti/stylelint-config-build.config.ts.497ea15a.js new file mode 100644 index 0000000..515d03e --- /dev/null +++ b/node-jiti/stylelint-config-build.config.ts.497ea15a.js @@ -0,0 +1,10 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _unbuild = require("unbuild");var _default = + +(0, _unbuild.defineBuildConfig)({ + clean: true, + entries: ['src/index'], + declaration: true, + rollup: { + emitCJS: true + } +});exports.default = _default; /* v7-e617738d05bbbbdb */ \ No newline at end of file diff --git a/node-jiti/supports-color-index.js.a4926036.js b/node-jiti/supports-color-index.js.a4926036.js new file mode 100644 index 0000000..87b63ea --- /dev/null +++ b/node-jiti/supports-color-index.js.a4926036.js @@ -0,0 +1,182 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.createSupportsColor = createSupportsColor;exports.default = void 0;var _nodeProcess = _interopRequireDefault(require("node:process")); +var _nodeOs = _interopRequireDefault(require("node:os")); +var _nodeTty = _interopRequireDefault(require("node:tty"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} + +// From: https://github.com/sindresorhus/has-flag/blob/main/index.js +/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) { +function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : _nodeProcess.default.argv) { + const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--'; + const position = argv.indexOf(prefix + flag); + const terminatorPosition = argv.indexOf('--'); + return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); +} + +const { env } = _nodeProcess.default; + +let flagForceColor; +if ( +hasFlag('no-color') || +hasFlag('no-colors') || +hasFlag('color=false') || +hasFlag('color=never')) +{ + flagForceColor = 0; +} else if ( +hasFlag('color') || +hasFlag('colors') || +hasFlag('color=true') || +hasFlag('color=always')) +{ + flagForceColor = 1; +} + +function envForceColor() { + if ('FORCE_COLOR' in env) { + if (env.FORCE_COLOR === 'true') { + return 1; + } + + if (env.FORCE_COLOR === 'false') { + return 0; + } + + return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); + } +} + +function translateLevel(level) { + if (level === 0) { + return false; + } + + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; +} + +function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { + const noFlagForceColor = envForceColor(); + if (noFlagForceColor !== undefined) { + flagForceColor = noFlagForceColor; + } + + const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; + + if (forceColor === 0) { + return 0; + } + + if (sniffFlags) { + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } + + if (hasFlag('color=256')) { + return 2; + } + } + + // Check for Azure DevOps pipelines. + // Has to be above the `!streamIsTTY` check. + if ('TF_BUILD' in env && 'AGENT_NAME' in env) { + return 1; + } + + if (haveStream && !streamIsTTY && forceColor === undefined) { + return 0; + } + + const min = forceColor || 0; + + if (env.TERM === 'dumb') { + return min; + } + + if (_nodeProcess.default.platform === 'win32') { + // Windows 10 build 10586 is the first Windows release that supports 256 colors. + // Windows 10 build 14931 is the first release that supports 16m/TrueColor. + const osRelease = _nodeOs.default.release().split('.'); + if ( + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10_586) + { + return Number(osRelease[2]) >= 14_931 ? 3 : 2; + } + + return 1; + } + + if ('CI' in env) { + if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) { + return 3; + } + + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some((sign) => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } + + return min; + } + + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } + + if (env.COLORTERM === 'truecolor') { + return 3; + } + + if (env.TERM === 'xterm-kitty') { + return 3; + } + + if ('TERM_PROGRAM' in env) { + const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + + switch (env.TERM_PROGRAM) { + case 'iTerm.app':{ + return version >= 3 ? 3 : 2; + } + + case 'Apple_Terminal':{ + return 2; + } + // No default + } + } + + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + + if ('COLORTERM' in env) { + return 1; + } + + return min; +} + +function createSupportsColor(stream, options = {}) { + const level = _supportsColor(stream, { + streamIsTTY: stream && stream.isTTY, + ...options + }); + + return translateLevel(level); +} + +const supportsColor = { + stdout: createSupportsColor({ isTTY: _nodeTty.default.isatty(1) }), + stderr: createSupportsColor({ isTTY: _nodeTty.default.isatty(2) }) +};var _default = + +supportsColor;exports.default = _default; /* v7-75cc7f0b87ad9e85 */ \ No newline at end of file diff --git a/node-jiti/vite-config-build.config.ts.9779baa8.js b/node-jiti/vite-config-build.config.ts.9779baa8.js new file mode 100644 index 0000000..515d03e --- /dev/null +++ b/node-jiti/vite-config-build.config.ts.9779baa8.js @@ -0,0 +1,10 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _unbuild = require("unbuild");var _default = + +(0, _unbuild.defineBuildConfig)({ + clean: true, + entries: ['src/index'], + declaration: true, + rollup: { + emitCJS: true + } +});exports.default = _default; /* v7-e617738d05bbbbdb */ \ No newline at end of file diff --git a/packages/types/package-lock.json b/packages/types/package-lock.json new file mode 100644 index 0000000..6c79084 --- /dev/null +++ b/packages/types/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "@vben/types", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@vben/types", + "version": "1.0.0", + "license": "MIT" + } + } +} diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/public/.DS_Store differ diff --git a/public/favicon.ico b/public/favicon.ico index c04e95e..53c3904 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/resource/img/.DS_Store b/public/resource/img/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/public/resource/img/.DS_Store differ diff --git a/public/resource/img/logo.png b/public/resource/img/logo.png index c04e95e..92d7699 100644 Binary files a/public/resource/img/logo.png and b/public/resource/img/logo.png differ diff --git a/src/assets/images/logo.png b/src/assets/images/logo.png index c04e95e..f59ce9d 100644 Binary files a/src/assets/images/logo.png and b/src/assets/images/logo.png differ diff --git a/src/assets/images/logo1.png b/src/assets/images/logo1.png new file mode 100644 index 0000000..c04e95e Binary files /dev/null and b/src/assets/images/logo1.png differ diff --git a/src/layouts/default/header/index.less b/src/layouts/default/header/index.less index bfa2e90..53b7392 100644 --- a/src/layouts/default/header/index.less +++ b/src/layouts/default/header/index.less @@ -53,7 +53,7 @@ font-size: 14px; img { - width: @logo-width; + // width: @logo-width; height: @logo-width; margin-right: 2px; } diff --git a/src/layouts/default/menu/index.vue b/src/layouts/default/menu/index.vue index 35f8fcf..782b3da 100644 --- a/src/layouts/default/menu/index.vue +++ b/src/layouts/default/menu/index.vue @@ -179,9 +179,11 @@ &-logo { height: @header-height; padding: 10px 4px 10px 10px; + // add + justify-content: center; img { - width: @logo-width; + // width: @logo-width; height: @logo-width; } } diff --git a/src/layouts/default/sider/MixSider.vue b/src/layouts/default/sider/MixSider.vue index da05e97..0e95842 100644 --- a/src/layouts/default/sider/MixSider.vue +++ b/src/layouts/default/sider/MixSider.vue @@ -53,7 +53,7 @@ }, ]" > - {{ title }} + {{ title }} A仓库 采购了100个零件 H3C`, - }, - { - avatar: 'dynamic-avatar-2|svg', - name: '艾文', - date: '1个小时前', - desc: `关注了 小李 `, - }, - { - avatar: 'dynamic-avatar-3|svg', - name: '克里斯', - date: '1天前', - desc: `发布了 本月采购物料表 `, - }, - { - avatar: 'dynamic-avatar-4|svg', - name: '赵伟', - date: '2天前', - desc: `发表文章 企业如何集成GPT微调模型配合ERP使用 `, - }, - { - avatar: 'dynamic-avatar-5|svg', - name: '皮特', - date: '3天前', - desc: `回复了 赵伟 的问题 如何让用户能直接微调模型?`, - }, - { - avatar: 'dynamic-avatar-6|svg', - name: '杰克', - date: '1周前', - desc: `添加了会员 检测公司的会员 `, - }, + { + avatar: 'dynamic-avatar-1|svg', + name: '小李', + date: '刚刚', + desc: `在 A仓库 采购了100个零件 H3C`, + }, + { + avatar: 'dynamic-avatar-2|svg', + name: '艾文', + date: '1个小时前', + desc: `关注了 小李 `, + }, + { + avatar: 'dynamic-avatar-3|svg', + name: '克里斯', + date: '1天前', + desc: `发布了 本月采购物料表 `, + }, + { + avatar: 'dynamic-avatar-4|svg', + name: '赵伟', + date: '2天前', + desc: `发表文章 企业如何集成GPT微调模型配合ERP使用 `, + }, + { + avatar: 'dynamic-avatar-5|svg', + name: '皮特', + date: '3天前', + desc: `回复了 赵伟 的问题 如何让用户能直接微调模型?`, + }, + { + avatar: 'dynamic-avatar-6|svg', + name: '杰克', + date: '1周前', + desc: `添加了会员 检测公司的会员 `, + }, ]; export const groupItems: GroupItem[] = [ - { - title: 'WanSen ERP Core', - icon: 'carbon:logo-github', - color: '', - desc: 'ERP系统的API', - group: '万森智能开源组', - date: '2023-09-28', - }, - { - title: 'WanSen ERP', - icon: 'ion:logo-vue', - color: '#3fb27f', - desc: '该项目使用了Vue3+Vite+Ant-Design', - group: '前端开发小组', - date: '2023-09-28', - }, - { - title: 'Html 5', - icon: 'ion:logo-html5', - color: '#e18525', - desc: '该项目也使用了HTML5', - group: '前端开发小组', - date: '2023-10-01', - }, - { - title: 'Angular', - icon: 'ion:logo-angular', - color: '#bf0c2c', - desc: '设计新的页面交互', - group: 'UI组', - date: '2023-10-01', - }, - { - title: 'React', - icon: 'bx:bxl-react', - color: '#00d8ff', - desc: '下一步计划支持React重构', - group: '前端开发小组', - date: '2023-10-02', - }, - { - title: 'JavaScript', - icon: 'ion:logo-javascript', - color: '#EBD94E', - desc: '我们也可使用javascript进行重写', - group: '前端开发小组', - date: '2023-10-03', - }, + { + title: 'WanSen ERP Core', + icon: 'carbon:logo-github', + color: '', + desc: 'ERP系统的API', + group: '万森智能开源组', + date: '2023-09-28', + }, + { + title: 'WanSen ERP', + icon: 'ion:logo-vue', + color: '#3fb27f', + desc: '该项目使用了Vue3+Vite+Ant-Design', + group: '前端开发小组', + date: '2023-09-28', + }, + { + title: 'Html 5', + icon: 'ion:logo-html5', + color: '#e18525', + desc: '该项目也使用了HTML5', + group: '前端开发小组', + date: '2023-10-01', + }, + { + title: 'Angular', + icon: 'ion:logo-angular', + color: '#bf0c2c', + desc: '设计新的页面交互', + group: 'UI组', + date: '2023-10-01', + }, + { + title: 'React', + icon: 'bx:bxl-react', + color: '#00d8ff', + desc: '下一步计划支持React重构', + group: '前端开发小组', + date: '2023-10-02', + }, + { + title: 'JavaScript', + icon: 'ion:logo-javascript', + color: '#EBD94E', + desc: '我们也可使用javascript进行重写', + group: '前端开发小组', + date: '2023-10-03', + }, ]; diff --git a/src/views/dashboard/workbench/index.vue b/src/views/dashboard/workbench/index.vue index 5ee292e..0bb5283 100644 --- a/src/views/dashboard/workbench/index.vue +++ b/src/views/dashboard/workbench/index.vue @@ -1,9 +1,9 @@ \ No newline at end of file + diff --git a/vite.config.ts b/vite.config.ts index 37c3c3f..681dd2e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,31 +1,33 @@ import { defineApplicationConfig } from '@vben/vite-config'; export default defineApplicationConfig({ - overrides: { - optimizeDeps: { - include: [ - 'echarts/core', - 'echarts/charts', - 'echarts/components', - 'echarts/renderers', - 'qrcode', - '@iconify/iconify', - 'ant-design-vue/es/locale/zh_CN', - 'ant-design-vue/es/locale/en_US', - ], - }, - server: { - port: 3000, - proxy: { - '/erp-api': { - target: 'http://localhost:8088', - changeOrigin: true, - ws: true, - // rewrite: (path) => path.replace(/^\/api/, ''), - // only https + overrides: { + optimizeDeps: { + include: [ + 'echarts/core', + 'echarts/charts', + 'echarts/components', + 'echarts/renderers', + 'qrcode', + '@iconify/iconify', + 'ant-design-vue/es/locale/zh_CN', + 'ant-design-vue/es/locale/en_US', + ], + }, + server: { + port: 3000, + proxy: { + '/erp-api': { + target: 'http://58.49.150.163:8088', + // target: 'https://eairp.cn', - } - }, + changeOrigin: true, + ws: true, + // rewrite: (path) => path.replace(/^\/api/, ''), + // only https + + } + }, + }, }, - }, });