Update package dependencies and remove unused files from node_modules
This commit is contained in:
249
node_modules/.package-lock.json
generated
vendored
249
node_modules/.package-lock.json
generated
vendored
@@ -32,9 +32,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.25.4",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.4.tgz",
|
||||
"integrity": "sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==",
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
|
||||
"integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -45,7 +45,7 @@
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/cliui": {
|
||||
@@ -211,43 +211,44 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@sveltejs/vite-plugin-svelte": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.0.3.tgz",
|
||||
"integrity": "sha512-MCFS6CrQDu1yGwspm4qtli0e63vaPCehf6V7pIMP15AsWgMKrqDGCPFF/0kn4SP0ii4aySu4Pa62+fIRGFMjgw==",
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-3.1.2.tgz",
|
||||
"integrity": "sha512-Txsm1tJvtiYeLUVRNqxZGKR/mI+CzuIQuc2gn+YCs9rMTowpNZ2Nqt53JdL8KF9bLhAf2ruR/dr9eZCwdTriRA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sveltejs/vite-plugin-svelte-inspector": "^4.0.1",
|
||||
"debug": "^4.4.0",
|
||||
"@sveltejs/vite-plugin-svelte-inspector": "^2.1.0",
|
||||
"debug": "^4.3.4",
|
||||
"deepmerge": "^4.3.1",
|
||||
"kleur": "^4.1.5",
|
||||
"magic-string": "^0.30.15",
|
||||
"vitefu": "^1.0.4"
|
||||
"magic-string": "^0.30.10",
|
||||
"svelte-hmr": "^0.16.0",
|
||||
"vitefu": "^0.2.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22"
|
||||
"node": "^18.0.0 || >=20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0",
|
||||
"vite": "^6.0.0"
|
||||
"svelte": "^4.0.0 || ^5.0.0-next.0",
|
||||
"vite": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sveltejs/vite-plugin-svelte/node_modules/@sveltejs/vite-plugin-svelte-inspector": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-4.0.1.tgz",
|
||||
"integrity": "sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==",
|
||||
"node_modules/@sveltejs/vite-plugin-svelte-inspector": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-2.1.0.tgz",
|
||||
"integrity": "sha512-9QX28IymvBlSCqsCll5t0kQVxipsfhFFL+L2t3nTWfXnddYwxBuAEtTtlaVQpRz9c37BhJjltSeY4AJSC03SSg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.7"
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22"
|
||||
"node": "^18.0.0 || >=20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
||||
"svelte": "^5.0.0",
|
||||
"vite": "^6.0.0"
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||
"svelte": "^4.0.0 || ^5.0.0-next.0",
|
||||
"vite": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tsconfig/svelte": {
|
||||
@@ -725,9 +726,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.25.4",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.4.tgz",
|
||||
"integrity": "sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==",
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
|
||||
"integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
@@ -735,34 +736,32 @@
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.4",
|
||||
"@esbuild/android-arm": "0.25.4",
|
||||
"@esbuild/android-arm64": "0.25.4",
|
||||
"@esbuild/android-x64": "0.25.4",
|
||||
"@esbuild/darwin-arm64": "0.25.4",
|
||||
"@esbuild/darwin-x64": "0.25.4",
|
||||
"@esbuild/freebsd-arm64": "0.25.4",
|
||||
"@esbuild/freebsd-x64": "0.25.4",
|
||||
"@esbuild/linux-arm": "0.25.4",
|
||||
"@esbuild/linux-arm64": "0.25.4",
|
||||
"@esbuild/linux-ia32": "0.25.4",
|
||||
"@esbuild/linux-loong64": "0.25.4",
|
||||
"@esbuild/linux-mips64el": "0.25.4",
|
||||
"@esbuild/linux-ppc64": "0.25.4",
|
||||
"@esbuild/linux-riscv64": "0.25.4",
|
||||
"@esbuild/linux-s390x": "0.25.4",
|
||||
"@esbuild/linux-x64": "0.25.4",
|
||||
"@esbuild/netbsd-arm64": "0.25.4",
|
||||
"@esbuild/netbsd-x64": "0.25.4",
|
||||
"@esbuild/openbsd-arm64": "0.25.4",
|
||||
"@esbuild/openbsd-x64": "0.25.4",
|
||||
"@esbuild/sunos-x64": "0.25.4",
|
||||
"@esbuild/win32-arm64": "0.25.4",
|
||||
"@esbuild/win32-ia32": "0.25.4",
|
||||
"@esbuild/win32-x64": "0.25.4"
|
||||
"@esbuild/aix-ppc64": "0.21.5",
|
||||
"@esbuild/android-arm": "0.21.5",
|
||||
"@esbuild/android-arm64": "0.21.5",
|
||||
"@esbuild/android-x64": "0.21.5",
|
||||
"@esbuild/darwin-arm64": "0.21.5",
|
||||
"@esbuild/darwin-x64": "0.21.5",
|
||||
"@esbuild/freebsd-arm64": "0.21.5",
|
||||
"@esbuild/freebsd-x64": "0.21.5",
|
||||
"@esbuild/linux-arm": "0.21.5",
|
||||
"@esbuild/linux-arm64": "0.21.5",
|
||||
"@esbuild/linux-ia32": "0.21.5",
|
||||
"@esbuild/linux-loong64": "0.21.5",
|
||||
"@esbuild/linux-mips64el": "0.21.5",
|
||||
"@esbuild/linux-ppc64": "0.21.5",
|
||||
"@esbuild/linux-riscv64": "0.21.5",
|
||||
"@esbuild/linux-s390x": "0.21.5",
|
||||
"@esbuild/linux-x64": "0.21.5",
|
||||
"@esbuild/netbsd-x64": "0.21.5",
|
||||
"@esbuild/openbsd-x64": "0.21.5",
|
||||
"@esbuild/sunos-x64": "0.21.5",
|
||||
"@esbuild/win32-arm64": "0.21.5",
|
||||
"@esbuild/win32-ia32": "0.21.5",
|
||||
"@esbuild/win32-x64": "0.21.5"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
@@ -863,6 +862,21 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
@@ -2099,6 +2113,19 @@
|
||||
"svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0"
|
||||
}
|
||||
},
|
||||
"node_modules/svelte-hmr": {
|
||||
"version": "0.16.0",
|
||||
"resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.16.0.tgz",
|
||||
"integrity": "sha512-Gyc7cOS3VJzLlfj7wKS0ZnzDVdv3Pn2IuVeJPk9m2skfhcu5bq3wtIZyQGggr7/Iim5rH5cncyQft/kRLupcnA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "^12.20 || ^14.13.1 || >= 16"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^3.19.0 || ^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/svelte-preprocess": {
|
||||
"version": "5.1.4",
|
||||
"resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.1.4.tgz",
|
||||
@@ -2236,51 +2263,6 @@
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.13",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.13.tgz",
|
||||
"integrity": "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby/node_modules/fdir": {
|
||||
"version": "6.4.4",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz",
|
||||
"integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"picomatch": "^3 || ^4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"picomatch": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
@@ -2361,24 +2343,21 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
|
||||
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
|
||||
"version": "5.4.19",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
|
||||
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup": "^4.34.9",
|
||||
"tinyglobby": "^0.2.13"
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
"rollup": "^4.20.0"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/vitejs/vite?sponsor=1"
|
||||
@@ -2387,25 +2366,19 @@
|
||||
"fsevents": "~2.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"@types/node": "^18.0.0 || >=20.0.0",
|
||||
"less": "*",
|
||||
"lightningcss": "^1.21.0",
|
||||
"sass": "*",
|
||||
"sass-embedded": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.16.0",
|
||||
"tsx": "^4.8.1",
|
||||
"yaml": "^2.4.2"
|
||||
"terser": "^5.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"jiti": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
@@ -2426,55 +2399,17 @@
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
},
|
||||
"tsx": {
|
||||
"optional": true
|
||||
},
|
||||
"yaml": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite/node_modules/fdir": {
|
||||
"version": "6.4.4",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz",
|
||||
"integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"picomatch": "^3 || ^4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"picomatch": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/vitefu": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.6.tgz",
|
||||
"integrity": "sha512-+Rex1GlappUyNN6UfwbVZne/9cYC4+R2XDk9xkNXBKMw6HQagdX9PgZ8V2v1WUSK1wfBLp7qbI1+XSNIlB1xmA==",
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz",
|
||||
"integrity": "sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"tests/deps/*",
|
||||
"tests/projects/*"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
|
||||
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vite": {
|
||||
|
1
node_modules/.vite/_svelte_metadata.json
generated
vendored
1
node_modules/.vite/_svelte_metadata.json
generated
vendored
@@ -1 +0,0 @@
|
||||
{"compilerOptions":{"css":"injected","dev":true,"hmr":true,"enableSourcemap":true},"configFile":"/Users/richard/Website Development/tiber365/svelte.config.js","extensions":[".svelte"]}
|
7420
node_modules/.vite/deps/@lottiefiles_lottie-player.js
generated
vendored
7420
node_modules/.vite/deps/@lottiefiles_lottie-player.js
generated
vendored
File diff suppressed because it is too large
Load Diff
7
node_modules/.vite/deps/@lottiefiles_lottie-player.js.map
generated
vendored
7
node_modules/.vite/deps/@lottiefiles_lottie-player.js.map
generated
vendored
File diff suppressed because one or more lines are too long
79
node_modules/.vite/deps/_metadata.json
generated
vendored
79
node_modules/.vite/deps/_metadata.json
generated
vendored
@@ -1,79 +0,0 @@
|
||||
{
|
||||
"hash": "d431f731",
|
||||
"configHash": "479474dc",
|
||||
"lockfileHash": "78ec1263",
|
||||
"browserHash": "10a876de",
|
||||
"optimized": {
|
||||
"svelte": {
|
||||
"src": "../../svelte/src/runtime/index.js",
|
||||
"file": "svelte.js",
|
||||
"fileHash": "d8eaf085",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/animate": {
|
||||
"src": "../../svelte/src/runtime/animate/index.js",
|
||||
"file": "svelte_animate.js",
|
||||
"fileHash": "ef20bd25",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/easing": {
|
||||
"src": "../../svelte/src/runtime/easing/index.js",
|
||||
"file": "svelte_easing.js",
|
||||
"fileHash": "68d453f1",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/internal": {
|
||||
"src": "../../svelte/src/runtime/internal/index.js",
|
||||
"file": "svelte_internal.js",
|
||||
"fileHash": "c9ecc153",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/motion": {
|
||||
"src": "../../svelte/src/runtime/motion/index.js",
|
||||
"file": "svelte_motion.js",
|
||||
"fileHash": "ad0881c8",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/store": {
|
||||
"src": "../../svelte/src/runtime/store/index.js",
|
||||
"file": "svelte_store.js",
|
||||
"fileHash": "c963774a",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/internal/disclose-version": {
|
||||
"src": "../../svelte/src/runtime/internal/disclose-version/index.js",
|
||||
"file": "svelte_internal_disclose-version.js",
|
||||
"fileHash": "5a96e526",
|
||||
"needsInterop": false
|
||||
},
|
||||
"svelte/transition": {
|
||||
"src": "../../svelte/src/runtime/transition/index.js",
|
||||
"file": "svelte_transition.js",
|
||||
"fileHash": "7e755de8",
|
||||
"needsInterop": false
|
||||
},
|
||||
"@lottiefiles/lottie-player": {
|
||||
"src": "../../@lottiefiles/lottie-player/dist/lottie-player.esm.js",
|
||||
"file": "@lottiefiles_lottie-player.js",
|
||||
"fileHash": "5894125f",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
"chunks": {
|
||||
"chunk-76MXQKTF": {
|
||||
"file": "chunk-76MXQKTF.js"
|
||||
},
|
||||
"chunk-ETWSND26": {
|
||||
"file": "chunk-ETWSND26.js"
|
||||
},
|
||||
"chunk-TB4K45JM": {
|
||||
"file": "chunk-TB4K45JM.js"
|
||||
},
|
||||
"chunk-2GBBIY5G": {
|
||||
"file": "chunk-2GBBIY5G.js"
|
||||
},
|
||||
"chunk-V6TY7KAL": {
|
||||
"file": "chunk-V6TY7KAL.js"
|
||||
}
|
||||
}
|
||||
}
|
9
node_modules/.vite/deps/chunk-2GBBIY5G.js
generated
vendored
9
node_modules/.vite/deps/chunk-2GBBIY5G.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
// node_modules/svelte/src/shared/version.js
|
||||
var VERSION = "4.2.19";
|
||||
var PUBLIC_VERSION = "4";
|
||||
|
||||
export {
|
||||
VERSION,
|
||||
PUBLIC_VERSION
|
||||
};
|
||||
//# sourceMappingURL=chunk-2GBBIY5G.js.map
|
7
node_modules/.vite/deps/chunk-2GBBIY5G.js.map
generated
vendored
7
node_modules/.vite/deps/chunk-2GBBIY5G.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../svelte/src/shared/version.js"],
|
||||
"sourcesContent": ["// generated during release, do not modify\n\n/**\n * The current version, as set in package.json.\n *\n * https://svelte.dev/docs/svelte-compiler#svelte-version\n * @type {string}\n */\nexport const VERSION = '4.2.19';\nexport const PUBLIC_VERSION = '4';\n"],
|
||||
"mappings": ";AAQO,IAAM,UAAU;AAChB,IAAM,iBAAiB;",
|
||||
"names": []
|
||||
}
|
117
node_modules/.vite/deps/chunk-76MXQKTF.js
generated
vendored
117
node_modules/.vite/deps/chunk-76MXQKTF.js
generated
vendored
@@ -1,117 +0,0 @@
|
||||
import {
|
||||
is_function,
|
||||
noop,
|
||||
run_all,
|
||||
safe_not_equal,
|
||||
subscribe
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
|
||||
// node_modules/svelte/src/runtime/store/index.js
|
||||
var subscriber_queue = [];
|
||||
function readable(value, start) {
|
||||
return {
|
||||
subscribe: writable(value, start).subscribe
|
||||
};
|
||||
}
|
||||
function writable(value, start = noop) {
|
||||
let stop;
|
||||
const subscribers = /* @__PURE__ */ new Set();
|
||||
function set(new_value) {
|
||||
if (safe_not_equal(value, new_value)) {
|
||||
value = new_value;
|
||||
if (stop) {
|
||||
const run_queue = !subscriber_queue.length;
|
||||
for (const subscriber of subscribers) {
|
||||
subscriber[1]();
|
||||
subscriber_queue.push(subscriber, value);
|
||||
}
|
||||
if (run_queue) {
|
||||
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
||||
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
||||
}
|
||||
subscriber_queue.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function update(fn) {
|
||||
set(fn(value));
|
||||
}
|
||||
function subscribe2(run, invalidate = noop) {
|
||||
const subscriber = [run, invalidate];
|
||||
subscribers.add(subscriber);
|
||||
if (subscribers.size === 1) {
|
||||
stop = start(set, update) || noop;
|
||||
}
|
||||
run(value);
|
||||
return () => {
|
||||
subscribers.delete(subscriber);
|
||||
if (subscribers.size === 0 && stop) {
|
||||
stop();
|
||||
stop = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return { set, update, subscribe: subscribe2 };
|
||||
}
|
||||
function derived(stores, fn, initial_value) {
|
||||
const single = !Array.isArray(stores);
|
||||
const stores_array = single ? [stores] : stores;
|
||||
if (!stores_array.every(Boolean)) {
|
||||
throw new Error("derived() expects stores as input, got a falsy value");
|
||||
}
|
||||
const auto = fn.length < 2;
|
||||
return readable(initial_value, (set, update) => {
|
||||
let started = false;
|
||||
const values = [];
|
||||
let pending = 0;
|
||||
let cleanup = noop;
|
||||
const sync = () => {
|
||||
if (pending) {
|
||||
return;
|
||||
}
|
||||
cleanup();
|
||||
const result = fn(single ? values[0] : values, set, update);
|
||||
if (auto) {
|
||||
set(result);
|
||||
} else {
|
||||
cleanup = is_function(result) ? result : noop;
|
||||
}
|
||||
};
|
||||
const unsubscribers = stores_array.map(
|
||||
(store, i) => subscribe(
|
||||
store,
|
||||
(value) => {
|
||||
values[i] = value;
|
||||
pending &= ~(1 << i);
|
||||
if (started) {
|
||||
sync();
|
||||
}
|
||||
},
|
||||
() => {
|
||||
pending |= 1 << i;
|
||||
}
|
||||
)
|
||||
);
|
||||
started = true;
|
||||
sync();
|
||||
return function stop() {
|
||||
run_all(unsubscribers);
|
||||
cleanup();
|
||||
started = false;
|
||||
};
|
||||
});
|
||||
}
|
||||
function readonly(store) {
|
||||
return {
|
||||
subscribe: store.subscribe.bind(store)
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
readable,
|
||||
writable,
|
||||
derived,
|
||||
readonly
|
||||
};
|
||||
//# sourceMappingURL=chunk-76MXQKTF.js.map
|
7
node_modules/.vite/deps/chunk-76MXQKTF.js.map
generated
vendored
7
node_modules/.vite/deps/chunk-76MXQKTF.js.map
generated
vendored
File diff suppressed because one or more lines are too long
144
node_modules/.vite/deps/chunk-ETWSND26.js
generated
vendored
144
node_modules/.vite/deps/chunk-ETWSND26.js
generated
vendored
@@ -1,144 +0,0 @@
|
||||
// node_modules/svelte/src/runtime/easing/index.js
|
||||
function backInOut(t) {
|
||||
const s = 1.70158 * 1.525;
|
||||
if ((t *= 2) < 1) return 0.5 * (t * t * ((s + 1) * t - s));
|
||||
return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2);
|
||||
}
|
||||
function backIn(t) {
|
||||
const s = 1.70158;
|
||||
return t * t * ((s + 1) * t - s);
|
||||
}
|
||||
function backOut(t) {
|
||||
const s = 1.70158;
|
||||
return --t * t * ((s + 1) * t + s) + 1;
|
||||
}
|
||||
function bounceOut(t) {
|
||||
const a = 4 / 11;
|
||||
const b = 8 / 11;
|
||||
const c = 9 / 10;
|
||||
const ca = 4356 / 361;
|
||||
const cb = 35442 / 1805;
|
||||
const cc = 16061 / 1805;
|
||||
const t2 = t * t;
|
||||
return t < a ? 7.5625 * t2 : t < b ? 9.075 * t2 - 9.9 * t + 3.4 : t < c ? ca * t2 - cb * t + cc : 10.8 * t * t - 20.52 * t + 10.72;
|
||||
}
|
||||
function bounceInOut(t) {
|
||||
return t < 0.5 ? 0.5 * (1 - bounceOut(1 - t * 2)) : 0.5 * bounceOut(t * 2 - 1) + 0.5;
|
||||
}
|
||||
function bounceIn(t) {
|
||||
return 1 - bounceOut(1 - t);
|
||||
}
|
||||
function circInOut(t) {
|
||||
if ((t *= 2) < 1) return -0.5 * (Math.sqrt(1 - t * t) - 1);
|
||||
return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
||||
}
|
||||
function circIn(t) {
|
||||
return 1 - Math.sqrt(1 - t * t);
|
||||
}
|
||||
function circOut(t) {
|
||||
return Math.sqrt(1 - --t * t);
|
||||
}
|
||||
function cubicInOut(t) {
|
||||
return t < 0.5 ? 4 * t * t * t : 0.5 * Math.pow(2 * t - 2, 3) + 1;
|
||||
}
|
||||
function cubicIn(t) {
|
||||
return t * t * t;
|
||||
}
|
||||
function cubicOut(t) {
|
||||
const f = t - 1;
|
||||
return f * f * f + 1;
|
||||
}
|
||||
function elasticInOut(t) {
|
||||
return t < 0.5 ? 0.5 * Math.sin(13 * Math.PI / 2 * 2 * t) * Math.pow(2, 10 * (2 * t - 1)) : 0.5 * Math.sin(-13 * Math.PI / 2 * (2 * t - 1 + 1)) * Math.pow(2, -10 * (2 * t - 1)) + 1;
|
||||
}
|
||||
function elasticIn(t) {
|
||||
return Math.sin(13 * t * Math.PI / 2) * Math.pow(2, 10 * (t - 1));
|
||||
}
|
||||
function elasticOut(t) {
|
||||
return Math.sin(-13 * (t + 1) * Math.PI / 2) * Math.pow(2, -10 * t) + 1;
|
||||
}
|
||||
function expoInOut(t) {
|
||||
return t === 0 || t === 1 ? t : t < 0.5 ? 0.5 * Math.pow(2, 20 * t - 10) : -0.5 * Math.pow(2, 10 - t * 20) + 1;
|
||||
}
|
||||
function expoIn(t) {
|
||||
return t === 0 ? t : Math.pow(2, 10 * (t - 1));
|
||||
}
|
||||
function expoOut(t) {
|
||||
return t === 1 ? t : 1 - Math.pow(2, -10 * t);
|
||||
}
|
||||
function quadInOut(t) {
|
||||
t /= 0.5;
|
||||
if (t < 1) return 0.5 * t * t;
|
||||
t--;
|
||||
return -0.5 * (t * (t - 2) - 1);
|
||||
}
|
||||
function quadIn(t) {
|
||||
return t * t;
|
||||
}
|
||||
function quadOut(t) {
|
||||
return -t * (t - 2);
|
||||
}
|
||||
function quartInOut(t) {
|
||||
return t < 0.5 ? 8 * Math.pow(t, 4) : -8 * Math.pow(t - 1, 4) + 1;
|
||||
}
|
||||
function quartIn(t) {
|
||||
return Math.pow(t, 4);
|
||||
}
|
||||
function quartOut(t) {
|
||||
return Math.pow(t - 1, 3) * (1 - t) + 1;
|
||||
}
|
||||
function quintInOut(t) {
|
||||
if ((t *= 2) < 1) return 0.5 * t * t * t * t * t;
|
||||
return 0.5 * ((t -= 2) * t * t * t * t + 2);
|
||||
}
|
||||
function quintIn(t) {
|
||||
return t * t * t * t * t;
|
||||
}
|
||||
function quintOut(t) {
|
||||
return --t * t * t * t * t + 1;
|
||||
}
|
||||
function sineInOut(t) {
|
||||
return -0.5 * (Math.cos(Math.PI * t) - 1);
|
||||
}
|
||||
function sineIn(t) {
|
||||
const v = Math.cos(t * Math.PI * 0.5);
|
||||
if (Math.abs(v) < 1e-14) return 1;
|
||||
else return 1 - v;
|
||||
}
|
||||
function sineOut(t) {
|
||||
return Math.sin(t * Math.PI / 2);
|
||||
}
|
||||
|
||||
export {
|
||||
backInOut,
|
||||
backIn,
|
||||
backOut,
|
||||
bounceOut,
|
||||
bounceInOut,
|
||||
bounceIn,
|
||||
circInOut,
|
||||
circIn,
|
||||
circOut,
|
||||
cubicInOut,
|
||||
cubicIn,
|
||||
cubicOut,
|
||||
elasticInOut,
|
||||
elasticIn,
|
||||
elasticOut,
|
||||
expoInOut,
|
||||
expoIn,
|
||||
expoOut,
|
||||
quadInOut,
|
||||
quadIn,
|
||||
quadOut,
|
||||
quartInOut,
|
||||
quartIn,
|
||||
quartOut,
|
||||
quintInOut,
|
||||
quintIn,
|
||||
quintOut,
|
||||
sineInOut,
|
||||
sineIn,
|
||||
sineOut
|
||||
};
|
||||
//# sourceMappingURL=chunk-ETWSND26.js.map
|
7
node_modules/.vite/deps/chunk-ETWSND26.js.map
generated
vendored
7
node_modules/.vite/deps/chunk-ETWSND26.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2848
node_modules/.vite/deps/chunk-TB4K45JM.js
generated
vendored
2848
node_modules/.vite/deps/chunk-TB4K45JM.js
generated
vendored
File diff suppressed because it is too large
Load Diff
7
node_modules/.vite/deps/chunk-TB4K45JM.js.map
generated
vendored
7
node_modules/.vite/deps/chunk-TB4K45JM.js.map
generated
vendored
File diff suppressed because one or more lines are too long
7
node_modules/.vite/deps/chunk-V6TY7KAL.js
generated
vendored
7
node_modules/.vite/deps/chunk-V6TY7KAL.js
generated
vendored
@@ -1,7 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
|
||||
export {
|
||||
__publicField
|
||||
};
|
7
node_modules/.vite/deps/chunk-V6TY7KAL.js.map
generated
vendored
7
node_modules/.vite/deps/chunk-V6TY7KAL.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
3
node_modules/.vite/deps/package.json
generated
vendored
3
node_modules/.vite/deps/package.json
generated
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
30
node_modules/.vite/deps/svelte.js
generated
vendored
30
node_modules/.vite/deps/svelte.js
generated
vendored
@@ -1,30 +0,0 @@
|
||||
import {
|
||||
SvelteComponentDev,
|
||||
SvelteComponentTyped,
|
||||
afterUpdate,
|
||||
beforeUpdate,
|
||||
createEventDispatcher,
|
||||
getAllContexts,
|
||||
getContext,
|
||||
hasContext,
|
||||
onDestroy,
|
||||
onMount,
|
||||
setContext,
|
||||
tick
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
export {
|
||||
SvelteComponentDev as SvelteComponent,
|
||||
SvelteComponentTyped,
|
||||
afterUpdate,
|
||||
beforeUpdate,
|
||||
createEventDispatcher,
|
||||
getAllContexts,
|
||||
getContext,
|
||||
hasContext,
|
||||
onDestroy,
|
||||
onMount,
|
||||
setContext,
|
||||
tick
|
||||
};
|
7
node_modules/.vite/deps/svelte.js.map
generated
vendored
7
node_modules/.vite/deps/svelte.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
34
node_modules/.vite/deps/svelte_animate.js
generated
vendored
34
node_modules/.vite/deps/svelte_animate.js
generated
vendored
@@ -1,34 +0,0 @@
|
||||
import {
|
||||
cubicOut
|
||||
} from "./chunk-ETWSND26.js";
|
||||
import {
|
||||
is_function
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
|
||||
// node_modules/svelte/src/runtime/animate/index.js
|
||||
function flip(node, { from, to }, params = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const transform = style.transform === "none" ? "" : style.transform;
|
||||
const [ox, oy] = style.transformOrigin.split(" ").map(parseFloat);
|
||||
const dx = from.left + from.width * ox / to.width - (to.left + ox);
|
||||
const dy = from.top + from.height * oy / to.height - (to.top + oy);
|
||||
const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;
|
||||
return {
|
||||
delay,
|
||||
duration: is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration,
|
||||
easing,
|
||||
css: (t, u) => {
|
||||
const x = u * dx;
|
||||
const y = u * dy;
|
||||
const sx = t + u * from.width / to.width;
|
||||
const sy = t + u * from.height / to.height;
|
||||
return `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`;
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
flip
|
||||
};
|
||||
//# sourceMappingURL=svelte_animate.js.map
|
7
node_modules/.vite/deps/svelte_animate.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_animate.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../svelte/src/runtime/animate/index.js"],
|
||||
"sourcesContent": ["import { cubicOut } from '../easing/index.js';\nimport { is_function } from '../internal/index.js';\n\n/**\n * The flip function calculates the start and end position of an element and animates between them, translating the x and y values.\n * `flip` stands for [First, Last, Invert, Play](https://aerotwist.com/blog/flip-your-animations/).\n *\n * https://svelte.dev/docs/svelte-animate#flip\n * @param {Element} node\n * @param {{ from: DOMRect; to: DOMRect }} fromTo\n * @param {import('./public.js').FlipParams} params\n * @returns {import('./public.js').AnimationConfig}\n */\nexport function flip(node, { from, to }, params = {}) {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === 'none' ? '' : style.transform;\n\tconst [ox, oy] = style.transformOrigin.split(' ').map(parseFloat);\n\tconst dx = from.left + (from.width * ox) / to.width - (to.left + ox);\n\tconst dy = from.top + (from.height * oy) / to.height - (to.top + oy);\n\tconst { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;\n\treturn {\n\t\tdelay,\n\t\tduration: is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration,\n\t\teasing,\n\t\tcss: (t, u) => {\n\t\t\tconst x = u * dx;\n\t\t\tconst y = u * dy;\n\t\t\tconst sx = t + (u * from.width) / to.width;\n\t\t\tconst sy = t + (u * from.height) / to.height;\n\t\t\treturn `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`;\n\t\t}\n\t};\n}\n"],
|
||||
"mappings": ";;;;;;;;;;AAaO,SAAS,KAAK,MAAM,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG;AACrD,QAAM,QAAQ,iBAAiB,IAAI;AACnC,QAAM,YAAY,MAAM,cAAc,SAAS,KAAK,MAAM;AAC1D,QAAM,CAAC,IAAI,EAAE,IAAI,MAAM,gBAAgB,MAAM,GAAG,EAAE,IAAI,UAAU;AAChE,QAAM,KAAK,KAAK,OAAQ,KAAK,QAAQ,KAAM,GAAG,SAAS,GAAG,OAAO;AACjE,QAAM,KAAK,KAAK,MAAO,KAAK,SAAS,KAAM,GAAG,UAAU,GAAG,MAAM;AACjE,QAAM,EAAE,QAAQ,GAAG,WAAW,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,KAAK,SAAS,SAAS,IAAI;AAC/E,SAAO;AAAA,IACN;AAAA,IACA,UAAU,YAAY,QAAQ,IAAI,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE,CAAC,IAAI;AAAA,IAC3E;AAAA,IACA,KAAK,CAAC,GAAG,MAAM;AACd,YAAM,IAAI,IAAI;AACd,YAAM,IAAI,IAAI;AACd,YAAM,KAAK,IAAK,IAAI,KAAK,QAAS,GAAG;AACrC,YAAM,KAAK,IAAK,IAAI,KAAK,SAAU,GAAG;AACtC,aAAO,cAAc,SAAS,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE;AAAA,IAC5E;AAAA,EACD;AACD;",
|
||||
"names": []
|
||||
}
|
70
node_modules/.vite/deps/svelte_easing.js
generated
vendored
70
node_modules/.vite/deps/svelte_easing.js
generated
vendored
@@ -1,70 +0,0 @@
|
||||
import {
|
||||
backIn,
|
||||
backInOut,
|
||||
backOut,
|
||||
bounceIn,
|
||||
bounceInOut,
|
||||
bounceOut,
|
||||
circIn,
|
||||
circInOut,
|
||||
circOut,
|
||||
cubicIn,
|
||||
cubicInOut,
|
||||
cubicOut,
|
||||
elasticIn,
|
||||
elasticInOut,
|
||||
elasticOut,
|
||||
expoIn,
|
||||
expoInOut,
|
||||
expoOut,
|
||||
quadIn,
|
||||
quadInOut,
|
||||
quadOut,
|
||||
quartIn,
|
||||
quartInOut,
|
||||
quartOut,
|
||||
quintIn,
|
||||
quintInOut,
|
||||
quintOut,
|
||||
sineIn,
|
||||
sineInOut,
|
||||
sineOut
|
||||
} from "./chunk-ETWSND26.js";
|
||||
import {
|
||||
identity
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
export {
|
||||
backIn,
|
||||
backInOut,
|
||||
backOut,
|
||||
bounceIn,
|
||||
bounceInOut,
|
||||
bounceOut,
|
||||
circIn,
|
||||
circInOut,
|
||||
circOut,
|
||||
cubicIn,
|
||||
cubicInOut,
|
||||
cubicOut,
|
||||
elasticIn,
|
||||
elasticInOut,
|
||||
elasticOut,
|
||||
expoIn,
|
||||
expoInOut,
|
||||
expoOut,
|
||||
identity as linear,
|
||||
quadIn,
|
||||
quadInOut,
|
||||
quadOut,
|
||||
quartIn,
|
||||
quartInOut,
|
||||
quartOut,
|
||||
quintIn,
|
||||
quintInOut,
|
||||
quintOut,
|
||||
sineIn,
|
||||
sineInOut,
|
||||
sineOut
|
||||
};
|
7
node_modules/.vite/deps/svelte_easing.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_easing.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
412
node_modules/.vite/deps/svelte_internal.js
generated
vendored
412
node_modules/.vite/deps/svelte_internal.js
generated
vendored
@@ -1,412 +0,0 @@
|
||||
import {
|
||||
HtmlTag,
|
||||
HtmlTagHydration,
|
||||
ResizeObserverSingleton,
|
||||
SvelteComponent,
|
||||
SvelteComponentDev,
|
||||
SvelteComponentTyped,
|
||||
SvelteElement,
|
||||
action_destroyer,
|
||||
add_attribute,
|
||||
add_classes,
|
||||
add_flush_callback,
|
||||
add_iframe_resize_listener,
|
||||
add_location,
|
||||
add_render_callback,
|
||||
add_styles,
|
||||
add_transform,
|
||||
afterUpdate,
|
||||
append,
|
||||
append_dev,
|
||||
append_empty_stylesheet,
|
||||
append_hydration,
|
||||
append_hydration_dev,
|
||||
append_styles,
|
||||
assign,
|
||||
attr,
|
||||
attr_dev,
|
||||
attribute_to_object,
|
||||
beforeUpdate,
|
||||
bind,
|
||||
binding_callbacks,
|
||||
blank_object,
|
||||
bubble,
|
||||
check_outros,
|
||||
children,
|
||||
claim_comment,
|
||||
claim_component,
|
||||
claim_element,
|
||||
claim_html_tag,
|
||||
claim_space,
|
||||
claim_svg_element,
|
||||
claim_text,
|
||||
clear_loops,
|
||||
comment,
|
||||
component_subscribe,
|
||||
compute_rest_props,
|
||||
compute_slots,
|
||||
construct_svelte_component,
|
||||
construct_svelte_component_dev,
|
||||
contenteditable_truthy_values,
|
||||
createEventDispatcher,
|
||||
create_animation,
|
||||
create_bidirectional_transition,
|
||||
create_component,
|
||||
create_custom_element,
|
||||
create_in_transition,
|
||||
create_out_transition,
|
||||
create_slot,
|
||||
create_ssr_component,
|
||||
current_component,
|
||||
custom_event,
|
||||
dataset_dev,
|
||||
debug,
|
||||
destroy_block,
|
||||
destroy_component,
|
||||
destroy_each,
|
||||
detach,
|
||||
detach_after_dev,
|
||||
detach_before_dev,
|
||||
detach_between_dev,
|
||||
detach_dev,
|
||||
dirty_components,
|
||||
dispatch_dev,
|
||||
each,
|
||||
element,
|
||||
element_is,
|
||||
empty,
|
||||
end_hydrating,
|
||||
ensure_array_like,
|
||||
ensure_array_like_dev,
|
||||
escape,
|
||||
escape_attribute_value,
|
||||
escape_object,
|
||||
exclude_internal_props,
|
||||
fix_and_destroy_block,
|
||||
fix_and_outro_and_destroy_block,
|
||||
fix_position,
|
||||
flush,
|
||||
flush_render_callbacks,
|
||||
getAllContexts,
|
||||
getContext,
|
||||
get_all_dirty_from_scope,
|
||||
get_binding_group_value,
|
||||
get_current_component,
|
||||
get_custom_elements_slots,
|
||||
get_root_for_style,
|
||||
get_slot_changes,
|
||||
get_spread_object,
|
||||
get_spread_update,
|
||||
get_store_value,
|
||||
get_svelte_dataset,
|
||||
globals,
|
||||
group_outros,
|
||||
handle_promise,
|
||||
hasContext,
|
||||
has_prop,
|
||||
head_selector,
|
||||
identity,
|
||||
init,
|
||||
init_binding_group,
|
||||
init_binding_group_dynamic,
|
||||
insert,
|
||||
insert_dev,
|
||||
insert_hydration,
|
||||
insert_hydration_dev,
|
||||
intros,
|
||||
invalid_attribute_name_character,
|
||||
is_client,
|
||||
is_crossorigin,
|
||||
is_empty,
|
||||
is_function,
|
||||
is_promise,
|
||||
is_void,
|
||||
listen,
|
||||
listen_dev,
|
||||
loop,
|
||||
loop_guard,
|
||||
merge_ssr_styles,
|
||||
missing_component,
|
||||
mount_component,
|
||||
noop,
|
||||
not_equal,
|
||||
now,
|
||||
null_to_empty,
|
||||
object_without_properties,
|
||||
onDestroy,
|
||||
onMount,
|
||||
once,
|
||||
outro_and_destroy_block,
|
||||
prevent_default,
|
||||
prop_dev,
|
||||
query_selector_all,
|
||||
raf,
|
||||
resize_observer_border_box,
|
||||
resize_observer_content_box,
|
||||
resize_observer_device_pixel_content_box,
|
||||
run,
|
||||
run_all,
|
||||
safe_not_equal,
|
||||
schedule_update,
|
||||
select_multiple_value,
|
||||
select_option,
|
||||
select_options,
|
||||
select_value,
|
||||
self,
|
||||
setContext,
|
||||
set_attributes,
|
||||
set_current_component,
|
||||
set_custom_element_data,
|
||||
set_custom_element_data_map,
|
||||
set_data,
|
||||
set_data_contenteditable,
|
||||
set_data_contenteditable_dev,
|
||||
set_data_dev,
|
||||
set_data_maybe_contenteditable,
|
||||
set_data_maybe_contenteditable_dev,
|
||||
set_dynamic_element_data,
|
||||
set_input_type,
|
||||
set_input_value,
|
||||
set_now,
|
||||
set_raf,
|
||||
set_store_value,
|
||||
set_style,
|
||||
set_svg_attributes,
|
||||
space,
|
||||
split_css_unit,
|
||||
spread,
|
||||
src_url_equal,
|
||||
srcset_url_equal,
|
||||
start_hydrating,
|
||||
stop_immediate_propagation,
|
||||
stop_propagation,
|
||||
stringify_spread,
|
||||
subscribe,
|
||||
svg_element,
|
||||
text,
|
||||
tick,
|
||||
time_ranges_to_array,
|
||||
to_number,
|
||||
toggle_class,
|
||||
transition_in,
|
||||
transition_out,
|
||||
trusted,
|
||||
update_await_block_branch,
|
||||
update_keyed_each,
|
||||
update_slot,
|
||||
update_slot_base,
|
||||
validate_component,
|
||||
validate_dynamic_element,
|
||||
validate_each_keys,
|
||||
validate_slots,
|
||||
validate_store,
|
||||
validate_void_dynamic_element,
|
||||
xlink_attr
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
export {
|
||||
HtmlTag,
|
||||
HtmlTagHydration,
|
||||
ResizeObserverSingleton,
|
||||
SvelteComponent,
|
||||
SvelteComponentDev,
|
||||
SvelteComponentTyped,
|
||||
SvelteElement,
|
||||
action_destroyer,
|
||||
add_attribute,
|
||||
add_classes,
|
||||
add_flush_callback,
|
||||
add_iframe_resize_listener,
|
||||
add_location,
|
||||
add_render_callback,
|
||||
add_styles,
|
||||
add_transform,
|
||||
afterUpdate,
|
||||
append,
|
||||
append_dev,
|
||||
append_empty_stylesheet,
|
||||
append_hydration,
|
||||
append_hydration_dev,
|
||||
append_styles,
|
||||
assign,
|
||||
attr,
|
||||
attr_dev,
|
||||
attribute_to_object,
|
||||
beforeUpdate,
|
||||
bind,
|
||||
binding_callbacks,
|
||||
blank_object,
|
||||
bubble,
|
||||
check_outros,
|
||||
children,
|
||||
claim_comment,
|
||||
claim_component,
|
||||
claim_element,
|
||||
claim_html_tag,
|
||||
claim_space,
|
||||
claim_svg_element,
|
||||
claim_text,
|
||||
clear_loops,
|
||||
comment,
|
||||
component_subscribe,
|
||||
compute_rest_props,
|
||||
compute_slots,
|
||||
construct_svelte_component,
|
||||
construct_svelte_component_dev,
|
||||
contenteditable_truthy_values,
|
||||
createEventDispatcher,
|
||||
create_animation,
|
||||
create_bidirectional_transition,
|
||||
create_component,
|
||||
create_custom_element,
|
||||
create_in_transition,
|
||||
create_out_transition,
|
||||
create_slot,
|
||||
create_ssr_component,
|
||||
current_component,
|
||||
custom_event,
|
||||
dataset_dev,
|
||||
debug,
|
||||
destroy_block,
|
||||
destroy_component,
|
||||
destroy_each,
|
||||
detach,
|
||||
detach_after_dev,
|
||||
detach_before_dev,
|
||||
detach_between_dev,
|
||||
detach_dev,
|
||||
dirty_components,
|
||||
dispatch_dev,
|
||||
each,
|
||||
element,
|
||||
element_is,
|
||||
empty,
|
||||
end_hydrating,
|
||||
ensure_array_like,
|
||||
ensure_array_like_dev,
|
||||
escape,
|
||||
escape_attribute_value,
|
||||
escape_object,
|
||||
exclude_internal_props,
|
||||
fix_and_destroy_block,
|
||||
fix_and_outro_and_destroy_block,
|
||||
fix_position,
|
||||
flush,
|
||||
flush_render_callbacks,
|
||||
getAllContexts,
|
||||
getContext,
|
||||
get_all_dirty_from_scope,
|
||||
get_binding_group_value,
|
||||
get_current_component,
|
||||
get_custom_elements_slots,
|
||||
get_root_for_style,
|
||||
get_slot_changes,
|
||||
get_spread_object,
|
||||
get_spread_update,
|
||||
get_store_value,
|
||||
get_svelte_dataset,
|
||||
globals,
|
||||
group_outros,
|
||||
handle_promise,
|
||||
hasContext,
|
||||
has_prop,
|
||||
head_selector,
|
||||
identity,
|
||||
init,
|
||||
init_binding_group,
|
||||
init_binding_group_dynamic,
|
||||
insert,
|
||||
insert_dev,
|
||||
insert_hydration,
|
||||
insert_hydration_dev,
|
||||
intros,
|
||||
invalid_attribute_name_character,
|
||||
is_client,
|
||||
is_crossorigin,
|
||||
is_empty,
|
||||
is_function,
|
||||
is_promise,
|
||||
is_void,
|
||||
listen,
|
||||
listen_dev,
|
||||
loop,
|
||||
loop_guard,
|
||||
merge_ssr_styles,
|
||||
missing_component,
|
||||
mount_component,
|
||||
noop,
|
||||
not_equal,
|
||||
now,
|
||||
null_to_empty,
|
||||
object_without_properties,
|
||||
onDestroy,
|
||||
onMount,
|
||||
once,
|
||||
outro_and_destroy_block,
|
||||
prevent_default,
|
||||
prop_dev,
|
||||
query_selector_all,
|
||||
raf,
|
||||
resize_observer_border_box,
|
||||
resize_observer_content_box,
|
||||
resize_observer_device_pixel_content_box,
|
||||
run,
|
||||
run_all,
|
||||
safe_not_equal,
|
||||
schedule_update,
|
||||
select_multiple_value,
|
||||
select_option,
|
||||
select_options,
|
||||
select_value,
|
||||
self,
|
||||
setContext,
|
||||
set_attributes,
|
||||
set_current_component,
|
||||
set_custom_element_data,
|
||||
set_custom_element_data_map,
|
||||
set_data,
|
||||
set_data_contenteditable,
|
||||
set_data_contenteditable_dev,
|
||||
set_data_dev,
|
||||
set_data_maybe_contenteditable,
|
||||
set_data_maybe_contenteditable_dev,
|
||||
set_dynamic_element_data,
|
||||
set_input_type,
|
||||
set_input_value,
|
||||
set_now,
|
||||
set_raf,
|
||||
set_store_value,
|
||||
set_style,
|
||||
set_svg_attributes,
|
||||
space,
|
||||
split_css_unit,
|
||||
spread,
|
||||
src_url_equal,
|
||||
srcset_url_equal,
|
||||
start_hydrating,
|
||||
stop_immediate_propagation,
|
||||
stop_propagation,
|
||||
stringify_spread,
|
||||
subscribe,
|
||||
svg_element,
|
||||
text,
|
||||
tick,
|
||||
time_ranges_to_array,
|
||||
to_number,
|
||||
toggle_class,
|
||||
transition_in,
|
||||
transition_out,
|
||||
trusted,
|
||||
update_await_block_branch,
|
||||
update_keyed_each,
|
||||
update_slot,
|
||||
update_slot_base,
|
||||
validate_component,
|
||||
validate_dynamic_element,
|
||||
validate_each_keys,
|
||||
validate_slots,
|
||||
validate_store,
|
||||
validate_void_dynamic_element,
|
||||
xlink_attr
|
||||
};
|
7
node_modules/.vite/deps/svelte_internal.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_internal.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
9
node_modules/.vite/deps/svelte_internal_disclose-version.js
generated
vendored
9
node_modules/.vite/deps/svelte_internal_disclose-version.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
import {
|
||||
PUBLIC_VERSION
|
||||
} from "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
|
||||
// node_modules/svelte/src/runtime/internal/disclose-version/index.js
|
||||
if (typeof window !== "undefined")
|
||||
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
|
||||
//# sourceMappingURL=svelte_internal_disclose-version.js.map
|
7
node_modules/.vite/deps/svelte_internal_disclose-version.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_internal_disclose-version.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../svelte/src/runtime/internal/disclose-version/index.js"],
|
||||
"sourcesContent": ["import { PUBLIC_VERSION } from '../../../shared/version.js';\n\nif (typeof window !== 'undefined')\n\t// @ts-ignore\n\t(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);\n"],
|
||||
"mappings": ";;;;;;AAEA,IAAI,OAAO,WAAW;AAErB,GAAC,OAAO,aAAa,OAAO,WAAW,EAAE,GAAG,oBAAI,IAAI,EAAE,IAAI,EAAE,IAAI,cAAc;",
|
||||
"names": []
|
||||
}
|
216
node_modules/.vite/deps/svelte_motion.js
generated
vendored
216
node_modules/.vite/deps/svelte_motion.js
generated
vendored
@@ -1,216 +0,0 @@
|
||||
import {
|
||||
writable
|
||||
} from "./chunk-76MXQKTF.js";
|
||||
import "./chunk-ETWSND26.js";
|
||||
import {
|
||||
assign,
|
||||
identity,
|
||||
loop,
|
||||
now
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
|
||||
// node_modules/svelte/src/runtime/motion/utils.js
|
||||
function is_date(obj) {
|
||||
return Object.prototype.toString.call(obj) === "[object Date]";
|
||||
}
|
||||
|
||||
// node_modules/svelte/src/runtime/motion/spring.js
|
||||
function tick_spring(ctx, last_value, current_value, target_value) {
|
||||
if (typeof current_value === "number" || is_date(current_value)) {
|
||||
const delta = target_value - current_value;
|
||||
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60);
|
||||
const spring2 = ctx.opts.stiffness * delta;
|
||||
const damper = ctx.opts.damping * velocity;
|
||||
const acceleration = (spring2 - damper) * ctx.inv_mass;
|
||||
const d = (velocity + acceleration) * ctx.dt;
|
||||
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
||||
return target_value;
|
||||
} else {
|
||||
ctx.settled = false;
|
||||
return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
|
||||
}
|
||||
} else if (Array.isArray(current_value)) {
|
||||
return current_value.map(
|
||||
(_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i])
|
||||
);
|
||||
} else if (typeof current_value === "object") {
|
||||
const next_value = {};
|
||||
for (const k in current_value) {
|
||||
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
||||
}
|
||||
return next_value;
|
||||
} else {
|
||||
throw new Error(`Cannot spring ${typeof current_value} values`);
|
||||
}
|
||||
}
|
||||
function spring(value, opts = {}) {
|
||||
const store = writable(value);
|
||||
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
||||
let last_time;
|
||||
let task;
|
||||
let current_token;
|
||||
let last_value = value;
|
||||
let target_value = value;
|
||||
let inv_mass = 1;
|
||||
let inv_mass_recovery_rate = 0;
|
||||
let cancel_task = false;
|
||||
function set(new_value, opts2 = {}) {
|
||||
target_value = new_value;
|
||||
const token = current_token = {};
|
||||
if (value == null || opts2.hard || spring2.stiffness >= 1 && spring2.damping >= 1) {
|
||||
cancel_task = true;
|
||||
last_time = now();
|
||||
last_value = new_value;
|
||||
store.set(value = target_value);
|
||||
return Promise.resolve();
|
||||
} else if (opts2.soft) {
|
||||
const rate = opts2.soft === true ? 0.5 : +opts2.soft;
|
||||
inv_mass_recovery_rate = 1 / (rate * 60);
|
||||
inv_mass = 0;
|
||||
}
|
||||
if (!task) {
|
||||
last_time = now();
|
||||
cancel_task = false;
|
||||
task = loop((now2) => {
|
||||
if (cancel_task) {
|
||||
cancel_task = false;
|
||||
task = null;
|
||||
return false;
|
||||
}
|
||||
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
||||
const ctx = {
|
||||
inv_mass,
|
||||
opts: spring2,
|
||||
settled: true,
|
||||
dt: (now2 - last_time) * 60 / 1e3
|
||||
};
|
||||
const next_value = tick_spring(ctx, last_value, value, target_value);
|
||||
last_time = now2;
|
||||
last_value = value;
|
||||
store.set(value = next_value);
|
||||
if (ctx.settled) {
|
||||
task = null;
|
||||
}
|
||||
return !ctx.settled;
|
||||
});
|
||||
}
|
||||
return new Promise((fulfil) => {
|
||||
task.promise.then(() => {
|
||||
if (token === current_token) fulfil();
|
||||
});
|
||||
});
|
||||
}
|
||||
const spring2 = {
|
||||
set,
|
||||
update: (fn, opts2) => set(fn(target_value, value), opts2),
|
||||
subscribe: store.subscribe,
|
||||
stiffness,
|
||||
damping,
|
||||
precision
|
||||
};
|
||||
return spring2;
|
||||
}
|
||||
|
||||
// node_modules/svelte/src/runtime/motion/tweened.js
|
||||
function get_interpolator(a, b) {
|
||||
if (a === b || a !== a) return () => a;
|
||||
const type = typeof a;
|
||||
if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
|
||||
throw new Error("Cannot interpolate values of different type");
|
||||
}
|
||||
if (Array.isArray(a)) {
|
||||
const arr = b.map((bi, i) => {
|
||||
return get_interpolator(a[i], bi);
|
||||
});
|
||||
return (t) => arr.map((fn) => fn(t));
|
||||
}
|
||||
if (type === "object") {
|
||||
if (!a || !b) throw new Error("Object cannot be null");
|
||||
if (is_date(a) && is_date(b)) {
|
||||
a = a.getTime();
|
||||
b = b.getTime();
|
||||
const delta = b - a;
|
||||
return (t) => new Date(a + t * delta);
|
||||
}
|
||||
const keys = Object.keys(b);
|
||||
const interpolators = {};
|
||||
keys.forEach((key) => {
|
||||
interpolators[key] = get_interpolator(a[key], b[key]);
|
||||
});
|
||||
return (t) => {
|
||||
const result = {};
|
||||
keys.forEach((key) => {
|
||||
result[key] = interpolators[key](t);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (type === "number") {
|
||||
const delta = b - a;
|
||||
return (t) => a + t * delta;
|
||||
}
|
||||
throw new Error(`Cannot interpolate ${type} values`);
|
||||
}
|
||||
function tweened(value, defaults = {}) {
|
||||
const store = writable(value);
|
||||
let task;
|
||||
let target_value = value;
|
||||
function set(new_value, opts) {
|
||||
if (value == null) {
|
||||
store.set(value = new_value);
|
||||
return Promise.resolve();
|
||||
}
|
||||
target_value = new_value;
|
||||
let previous_task = task;
|
||||
let started = false;
|
||||
let {
|
||||
delay = 0,
|
||||
duration = 400,
|
||||
easing = identity,
|
||||
interpolate = get_interpolator
|
||||
} = assign(assign({}, defaults), opts);
|
||||
if (duration === 0) {
|
||||
if (previous_task) {
|
||||
previous_task.abort();
|
||||
previous_task = null;
|
||||
}
|
||||
store.set(value = target_value);
|
||||
return Promise.resolve();
|
||||
}
|
||||
const start = now() + delay;
|
||||
let fn;
|
||||
task = loop((now2) => {
|
||||
if (now2 < start) return true;
|
||||
if (!started) {
|
||||
fn = interpolate(value, new_value);
|
||||
if (typeof duration === "function") duration = duration(value, new_value);
|
||||
started = true;
|
||||
}
|
||||
if (previous_task) {
|
||||
previous_task.abort();
|
||||
previous_task = null;
|
||||
}
|
||||
const elapsed = now2 - start;
|
||||
if (elapsed > /** @type {number} */
|
||||
duration) {
|
||||
store.set(value = new_value);
|
||||
return false;
|
||||
}
|
||||
store.set(value = fn(easing(elapsed / duration)));
|
||||
return true;
|
||||
});
|
||||
return task.promise;
|
||||
}
|
||||
return {
|
||||
set,
|
||||
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||
subscribe: store.subscribe
|
||||
};
|
||||
}
|
||||
export {
|
||||
spring,
|
||||
tweened
|
||||
};
|
||||
//# sourceMappingURL=svelte_motion.js.map
|
7
node_modules/.vite/deps/svelte_motion.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_motion.js.map
generated
vendored
File diff suppressed because one or more lines are too long
18
node_modules/.vite/deps/svelte_store.js
generated
vendored
18
node_modules/.vite/deps/svelte_store.js
generated
vendored
@@ -1,18 +0,0 @@
|
||||
import {
|
||||
derived,
|
||||
readable,
|
||||
readonly,
|
||||
writable
|
||||
} from "./chunk-76MXQKTF.js";
|
||||
import {
|
||||
get_store_value
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
export {
|
||||
derived,
|
||||
get_store_value as get,
|
||||
readable,
|
||||
readonly,
|
||||
writable
|
||||
};
|
7
node_modules/.vite/deps/svelte_store.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_store.js.map
generated
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
175
node_modules/.vite/deps/svelte_transition.js
generated
vendored
175
node_modules/.vite/deps/svelte_transition.js
generated
vendored
@@ -1,175 +0,0 @@
|
||||
import {
|
||||
cubicInOut,
|
||||
cubicOut
|
||||
} from "./chunk-ETWSND26.js";
|
||||
import {
|
||||
assign,
|
||||
identity,
|
||||
is_function,
|
||||
split_css_unit
|
||||
} from "./chunk-TB4K45JM.js";
|
||||
import "./chunk-2GBBIY5G.js";
|
||||
import "./chunk-V6TY7KAL.js";
|
||||
|
||||
// node_modules/svelte/src/runtime/transition/index.js
|
||||
function blur(node, { delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const f = style.filter === "none" ? "" : style.filter;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
const [value, unit] = split_css_unit(amount);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * value}${unit});`
|
||||
};
|
||||
}
|
||||
function fade(node, { delay = 0, duration = 400, easing = identity } = {}) {
|
||||
const o = +getComputedStyle(node).opacity;
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t) => `opacity: ${t * o}`
|
||||
};
|
||||
}
|
||||
function fly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const transform = style.transform === "none" ? "" : style.transform;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
const [xValue, xUnit] = split_css_unit(x);
|
||||
const [yValue, yUnit] = split_css_unit(y);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t, u) => `
|
||||
transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});
|
||||
opacity: ${target_opacity - od * u}`
|
||||
};
|
||||
}
|
||||
function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis = "y" } = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const opacity = +style.opacity;
|
||||
const primary_property = axis === "y" ? "height" : "width";
|
||||
const primary_property_value = parseFloat(style[primary_property]);
|
||||
const secondary_properties = axis === "y" ? ["top", "bottom"] : ["left", "right"];
|
||||
const capitalized_secondary_properties = secondary_properties.map(
|
||||
(e) => `${e[0].toUpperCase()}${e.slice(1)}`
|
||||
);
|
||||
const padding_start_value = parseFloat(style[`padding${capitalized_secondary_properties[0]}`]);
|
||||
const padding_end_value = parseFloat(style[`padding${capitalized_secondary_properties[1]}`]);
|
||||
const margin_start_value = parseFloat(style[`margin${capitalized_secondary_properties[0]}`]);
|
||||
const margin_end_value = parseFloat(style[`margin${capitalized_secondary_properties[1]}`]);
|
||||
const border_width_start_value = parseFloat(
|
||||
style[`border${capitalized_secondary_properties[0]}Width`]
|
||||
);
|
||||
const border_width_end_value = parseFloat(
|
||||
style[`border${capitalized_secondary_properties[1]}Width`]
|
||||
);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t) => `overflow: hidden;opacity: ${Math.min(t * 20, 1) * opacity};${primary_property}: ${t * primary_property_value}px;padding-${secondary_properties[0]}: ${t * padding_start_value}px;padding-${secondary_properties[1]}: ${t * padding_end_value}px;margin-${secondary_properties[0]}: ${t * margin_start_value}px;margin-${secondary_properties[1]}: ${t * margin_end_value}px;border-${secondary_properties[0]}-width: ${t * border_width_start_value}px;border-${secondary_properties[1]}-width: ${t * border_width_end_value}px;`
|
||||
};
|
||||
}
|
||||
function scale(node, { delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const transform = style.transform === "none" ? "" : style.transform;
|
||||
const sd = 1 - start;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_t, u) => `
|
||||
transform: ${transform} scale(${1 - sd * u});
|
||||
opacity: ${target_opacity - od * u}
|
||||
`
|
||||
};
|
||||
}
|
||||
function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) {
|
||||
let len = node.getTotalLength();
|
||||
const style = getComputedStyle(node);
|
||||
if (style.strokeLinecap !== "butt") {
|
||||
len += parseInt(style.strokeWidth);
|
||||
}
|
||||
if (duration === void 0) {
|
||||
if (speed === void 0) {
|
||||
duration = 800;
|
||||
} else {
|
||||
duration = len / speed;
|
||||
}
|
||||
} else if (typeof duration === "function") {
|
||||
duration = duration(len);
|
||||
}
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_, u) => `
|
||||
stroke-dasharray: ${len};
|
||||
stroke-dashoffset: ${u * len};
|
||||
`
|
||||
};
|
||||
}
|
||||
function crossfade({ fallback, ...defaults }) {
|
||||
const to_receive = /* @__PURE__ */ new Map();
|
||||
const to_send = /* @__PURE__ */ new Map();
|
||||
function crossfade2(from_node, node, params) {
|
||||
const {
|
||||
delay = 0,
|
||||
duration = (d2) => Math.sqrt(d2) * 30,
|
||||
easing = cubicOut
|
||||
} = assign(assign({}, defaults), params);
|
||||
const from = from_node.getBoundingClientRect();
|
||||
const to = node.getBoundingClientRect();
|
||||
const dx = from.left - to.left;
|
||||
const dy = from.top - to.top;
|
||||
const dw = from.width / to.width;
|
||||
const dh = from.height / to.height;
|
||||
const d = Math.sqrt(dx * dx + dy * dy);
|
||||
const style = getComputedStyle(node);
|
||||
const transform = style.transform === "none" ? "" : style.transform;
|
||||
const opacity = +style.opacity;
|
||||
return {
|
||||
delay,
|
||||
duration: is_function(duration) ? duration(d) : duration,
|
||||
easing,
|
||||
css: (t, u) => `
|
||||
opacity: ${t * opacity};
|
||||
transform-origin: top left;
|
||||
transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${t + (1 - t) * dh});
|
||||
`
|
||||
};
|
||||
}
|
||||
function transition(items, counterparts, intro) {
|
||||
return (node, params) => {
|
||||
items.set(params.key, node);
|
||||
return () => {
|
||||
if (counterparts.has(params.key)) {
|
||||
const other_node = counterparts.get(params.key);
|
||||
counterparts.delete(params.key);
|
||||
return crossfade2(other_node, node, params);
|
||||
}
|
||||
items.delete(params.key);
|
||||
return fallback && fallback(node, params, intro);
|
||||
};
|
||||
};
|
||||
}
|
||||
return [transition(to_send, to_receive, false), transition(to_receive, to_send, true)];
|
||||
}
|
||||
export {
|
||||
blur,
|
||||
crossfade,
|
||||
draw,
|
||||
fade,
|
||||
fly,
|
||||
scale,
|
||||
slide
|
||||
};
|
||||
//# sourceMappingURL=svelte_transition.js.map
|
7
node_modules/.vite/deps/svelte_transition.js.map
generated
vendored
7
node_modules/.vite/deps/svelte_transition.js.map
generated
vendored
File diff suppressed because one or more lines are too long
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
Binary file not shown.
4
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
4
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.25.4",
|
||||
"version": "0.21.5",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -9,7 +9,7 @@
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sveltejs/vite-plugin-svelte-inspector",
|
||||
"version": "4.0.1",
|
||||
"version": "2.1.0",
|
||||
"license": "MIT",
|
||||
"author": "dominikg",
|
||||
"files": [
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22"
|
||||
"node": "^18.0.0 || >=20"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -36,17 +36,17 @@
|
||||
},
|
||||
"homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.7"
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
||||
"svelte": "^5.0.0",
|
||||
"vite": "^6.0.0"
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||
"svelte": "^4.0.0 || ^5.0.0-next.0",
|
||||
"vite": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.12",
|
||||
"svelte": "^5.2.7",
|
||||
"vite": "^6.0.0"
|
||||
"svelte": "^4.2.12",
|
||||
"vite": "^5.2.8"
|
||||
},
|
||||
"scripts": {
|
||||
"check:publint": "publint --strict",
|
@@ -35,6 +35,7 @@ export function svelteInspector(options) {
|
||||
|
||||
configResolved(config) {
|
||||
viteConfig = config;
|
||||
|
||||
const environmentOptions = parseEnvironmentOptions(config);
|
||||
if (environmentOptions === false) {
|
||||
debug('environment options set to false, inspector disabled');
|
@@ -1,10 +1,9 @@
|
||||
import process from 'node:process';
|
||||
import { loadEnv } from 'vite';
|
||||
import { debug } from './debug.js';
|
||||
|
||||
/** @type {import('./public.d.ts').Options} */
|
||||
export const defaultInspectorOptions = {
|
||||
toggleKeyCombo: 'alt-x',
|
||||
toggleKeyCombo: process.platform === 'darwin' ? 'meta-shift' : 'control-shift',
|
||||
navKeys: { parent: 'ArrowUp', child: 'ArrowDown', next: 'ArrowRight', prev: 'ArrowLeft' },
|
||||
escapeKeys: ['Backspace', 'Escape'],
|
||||
openKey: 'Enter',
|
@@ -74,5 +74,5 @@ export interface Options {
|
||||
base: string;
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line n/no-missing-import
|
||||
|
||||
export * from './index.js';
|
@@ -1,17 +1,13 @@
|
||||
<svelte:options runes={true} />
|
||||
|
||||
<script>
|
||||
// do not use TS here so that this component works in non-ts projects too
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import options from 'virtual:svelte-inspector-options';
|
||||
const toggle_combo = options.toggleKeyCombo?.toLowerCase().split('-');
|
||||
const escape_keys = options.escapeKeys?.map((k) => k.toLowerCase());
|
||||
const nav_keys = Object.values(options.navKeys).map((k) => k?.toLowerCase());
|
||||
const open_key = options.openKey?.toLowerCase();
|
||||
|
||||
let enabled = $state(false);
|
||||
let has_opened = $state(false);
|
||||
const escape_keys = options.escapeKeys?.map((key) => key?.toLowerCase());
|
||||
const nav_keys = Object.values(options.navKeys).map((k) => k.toLowerCase());
|
||||
let enabled = false;
|
||||
let has_opened = false;
|
||||
|
||||
const icon = `data:image/svg+xml;base64,${btoa(
|
||||
`
|
||||
@@ -26,23 +22,20 @@
|
||||
)}`;
|
||||
|
||||
// location of code in file
|
||||
let file_loc = $state();
|
||||
let file_loc;
|
||||
// cursor pos and width for file_loc overlay positioning
|
||||
let x = $state(),
|
||||
y = $state(),
|
||||
w = $state();
|
||||
let x, y, w;
|
||||
|
||||
let active_el = $state();
|
||||
let active_el;
|
||||
|
||||
let hold_start_ts = $state();
|
||||
let hold_start_ts;
|
||||
|
||||
let show_toggle = $derived(
|
||||
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled)
|
||||
);
|
||||
$: show_toggle =
|
||||
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled);
|
||||
|
||||
function mousemove(e) {
|
||||
x = e.x;
|
||||
y = e.y;
|
||||
function mousemove(event) {
|
||||
x = event.x;
|
||||
y = event.y;
|
||||
}
|
||||
|
||||
function find_selectable_parent(el, include_self = false) {
|
||||
@@ -129,9 +122,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function open_editor(e) {
|
||||
function open_editor(event) {
|
||||
if (file_loc) {
|
||||
stop(e);
|
||||
stop(event);
|
||||
fetch(`${options.__internal.base}/__open-in-editor?file=${encodeURIComponent(file_loc)}`);
|
||||
has_opened = true;
|
||||
if (options.holdMode && is_holding()) {
|
||||
@@ -140,67 +133,67 @@
|
||||
}
|
||||
}
|
||||
|
||||
function is_active(key, e) {
|
||||
function is_key_active(key, event) {
|
||||
switch (key) {
|
||||
case 'shift':
|
||||
case 'control':
|
||||
case 'alt':
|
||||
case 'meta':
|
||||
return e.getModifierState(key.charAt(0).toUpperCase() + key.slice(1));
|
||||
return event.getModifierState(key.charAt(0).toUpperCase() + key.slice(1));
|
||||
default:
|
||||
return key === e.code.replace(/^Key/, '').toLowerCase() || key === e.key.toLowerCase();
|
||||
return key === event.key.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
function is_combo(e) {
|
||||
return toggle_combo?.every((k) => is_active(k, e));
|
||||
function is_combo(event) {
|
||||
return is_toggle(event) && toggle_combo?.every((key) => is_key_active(key, event));
|
||||
}
|
||||
|
||||
function is_escape(e) {
|
||||
return escape_keys?.some((k) => is_active(k, e));
|
||||
function is_escape(event) {
|
||||
return escape_keys?.includes(event.key.toLowerCase());
|
||||
}
|
||||
|
||||
function is_toggle(e) {
|
||||
return toggle_combo?.some((k) => is_active(k, e));
|
||||
function is_toggle(event) {
|
||||
return toggle_combo?.includes(event.key.toLowerCase());
|
||||
}
|
||||
|
||||
function is_nav(e) {
|
||||
return nav_keys?.some((k) => is_active(k, e));
|
||||
function is_nav(event) {
|
||||
return nav_keys?.some((key) => is_key_active(key, event));
|
||||
}
|
||||
|
||||
function is_open(e) {
|
||||
return open_key && is_active(open_key, e);
|
||||
function is_open(event) {
|
||||
return options.openKey && options.openKey.toLowerCase() === event.key.toLowerCase();
|
||||
}
|
||||
|
||||
function is_holding() {
|
||||
return hold_start_ts && Date.now() - hold_start_ts > 250;
|
||||
}
|
||||
|
||||
function stop(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
function stop(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
function keydown(e) {
|
||||
if (e.repeat || e.key == null || (!enabled && !is_toggle(e))) {
|
||||
function keydown(event) {
|
||||
if (event.repeat || event.key == null || (!enabled && !is_toggle(event))) {
|
||||
return;
|
||||
}
|
||||
if (is_combo(e)) {
|
||||
if (is_combo(event)) {
|
||||
toggle();
|
||||
if (options.holdMode && enabled) {
|
||||
hold_start_ts = Date.now();
|
||||
}
|
||||
} else if (enabled) {
|
||||
if (is_nav(e)) {
|
||||
const el = find_selectable_for_nav(e.key);
|
||||
if (is_nav(event)) {
|
||||
const el = find_selectable_for_nav(event.key);
|
||||
if (el) {
|
||||
activate(el);
|
||||
stop(e);
|
||||
stop(event);
|
||||
}
|
||||
} else if (is_open(e)) {
|
||||
open_editor(e);
|
||||
} else if (is_holding() || is_escape(e)) {
|
||||
} else if (is_open(event)) {
|
||||
open_editor(event);
|
||||
} else if (is_holding() || is_escape(event)) {
|
||||
// is_holding() checks for unhandled additional key pressed
|
||||
// while holding the toggle keys, which is possibly another
|
||||
// shortcut (e.g. 'meta-shift-x'), so disable again.
|
||||
@@ -210,11 +203,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
function keyup(e) {
|
||||
if (e.repeat || e.key == null || !enabled) {
|
||||
function keyup(event) {
|
||||
if (event.repeat || event.key == null || !enabled) {
|
||||
return;
|
||||
}
|
||||
if (is_toggle(e)) {
|
||||
if (is_toggle(event)) {
|
||||
if (is_holding()) {
|
||||
disable();
|
||||
} else {
|
||||
@@ -224,11 +217,7 @@
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
if (enabled) {
|
||||
disable();
|
||||
} else {
|
||||
enable();
|
||||
}
|
||||
enabled ? disable() : enable();
|
||||
}
|
||||
|
||||
function listeners(body, enabled) {
|
||||
@@ -340,9 +329,9 @@
|
||||
.split('-')
|
||||
.map((p) => `${p}: 8px;`)
|
||||
.join('')}`}
|
||||
onclick={() => toggle()}
|
||||
on:click={() => toggle()}
|
||||
aria-label={`${enabled ? 'disable' : 'enable'} svelte-inspector`}
|
||||
></button>
|
||||
/>
|
||||
{/if}
|
||||
{#if enabled && active_el && file_loc}
|
||||
{@const loc = active_el.__svelte_meta.loc}
|
@@ -1,6 +1,7 @@
|
||||
// @ts-expect-error missing
|
||||
// eslint-disable-next-line n/no-missing-import
|
||||
import Inspector from 'virtual:svelte-inspector-path:Inspector.svelte';
|
||||
import { mount } from 'svelte';
|
||||
|
||||
function create_inspector_host() {
|
||||
const id = 'svelte-inspector-host';
|
||||
if (document.getElementById(id) != null) {
|
||||
@@ -11,4 +12,5 @@ function create_inspector_host() {
|
||||
document.documentElement.appendChild(el);
|
||||
return el;
|
||||
}
|
||||
mount(Inspector, { target: create_inspector_host() });
|
||||
|
||||
new Inspector({ target: create_inspector_host() });
|
@@ -74,9 +74,7 @@ declare module '@sveltejs/vite-plugin-svelte-inspector' {
|
||||
base: string;
|
||||
};
|
||||
}
|
||||
export function svelteInspector(options?: Partial<Options>): import("vite").Plugin;
|
||||
|
||||
export {};
|
||||
export function svelteInspector(options?: Partial<Options> | undefined): import('vite').Plugin;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.d.ts.map
|
25
node_modules/@sveltejs/vite-plugin-svelte/package.json
generated
vendored
25
node_modules/@sveltejs/vite-plugin-svelte/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sveltejs/vite-plugin-svelte",
|
||||
"version": "5.0.3",
|
||||
"version": "3.1.2",
|
||||
"license": "MIT",
|
||||
"author": "dominikg",
|
||||
"files": [
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22"
|
||||
"node": "^18.0.0 || >=20"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -36,23 +36,24 @@
|
||||
},
|
||||
"homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
|
||||
"dependencies": {
|
||||
"@sveltejs/vite-plugin-svelte-inspector": "^4.0.1",
|
||||
"debug": "^4.4.0",
|
||||
"@sveltejs/vite-plugin-svelte-inspector": "^2.1.0",
|
||||
"debug": "^4.3.4",
|
||||
"deepmerge": "^4.3.1",
|
||||
"kleur": "^4.1.5",
|
||||
"magic-string": "^0.30.15",
|
||||
"vitefu": "^1.0.4"
|
||||
"magic-string": "^0.30.10",
|
||||
"svelte-hmr": "^0.16.0",
|
||||
"vitefu": "^0.2.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0",
|
||||
"vite": "^6.0.0"
|
||||
"svelte": "^4.0.0 || ^5.0.0-next.0",
|
||||
"vite": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.12",
|
||||
"esbuild": "^0.24.0",
|
||||
"sass": "^1.83.0",
|
||||
"svelte": "^5.12.0",
|
||||
"vite": "^6.0.3"
|
||||
"esbuild": "^0.20.2",
|
||||
"sass": "^1.75.0",
|
||||
"svelte": "^4.2.15",
|
||||
"vite": "^5.2.9"
|
||||
},
|
||||
"scripts": {
|
||||
"check:publint": "publint --strict",
|
||||
|
8
node_modules/@sveltejs/vite-plugin-svelte/src/handle-hot-update.js
generated
vendored
8
node_modules/@sveltejs/vite-plugin-svelte/src/handle-hot-update.js
generated
vendored
@@ -81,8 +81,8 @@ export async function handleHotUpdate(compileSvelte, ctx, svelteRequest, cache,
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./types/compile.d.ts').Code | null} [prev]
|
||||
* @param {import('./types/compile.d.ts').Code | null} [next]
|
||||
* @param {import('./types/compile.d.ts').Code} [prev]
|
||||
* @param {import('./types/compile.d.ts').Code} [next]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function cssChanged(prev, next) {
|
||||
@@ -90,8 +90,8 @@ function cssChanged(prev, next) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./types/compile.d.ts').Code | null} [prev]
|
||||
* @param {import('./types/compile.d.ts').Code | null} [next]
|
||||
* @param {import('./types/compile.d.ts').Code} [prev]
|
||||
* @param {import('./types/compile.d.ts').Code} [next]
|
||||
* @param {string} [filename]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
54
node_modules/@sveltejs/vite-plugin-svelte/src/index.js
generated
vendored
54
node_modules/@sveltejs/vite-plugin-svelte/src/index.js
generated
vendored
@@ -1,8 +1,9 @@
|
||||
import fs from 'node:fs';
|
||||
import process from 'node:process';
|
||||
|
||||
import { svelteInspector } from '@sveltejs/vite-plugin-svelte-inspector';
|
||||
|
||||
import { handleHotUpdate } from './handle-hot-update.js';
|
||||
import { log, logCompilerWarnings } from './utils/log.js';
|
||||
import { log, logCompilerWarnings, logSvelte5Warning } from './utils/log.js';
|
||||
import { createCompileSvelte } from './utils/compile.js';
|
||||
import { buildIdParser, buildModuleIdParser } from './utils/id.js';
|
||||
import {
|
||||
@@ -10,15 +11,15 @@ import {
|
||||
validateInlineOptions,
|
||||
resolveOptions,
|
||||
patchResolvedViteConfig,
|
||||
preResolveOptions,
|
||||
ensureConfigEnvironmentMainFields,
|
||||
ensureConfigEnvironmentConditions
|
||||
preResolveOptions
|
||||
} from './utils/options.js';
|
||||
|
||||
import { ensureWatchedFile, setupWatchers } from './utils/watch.js';
|
||||
import { toRollupError } from './utils/error.js';
|
||||
import { saveSvelteMetadata } from './utils/optimizer.js';
|
||||
import { VitePluginSvelteCache } from './utils/vite-plugin-svelte-cache.js';
|
||||
import { loadRaw } from './utils/load-raw.js';
|
||||
import { isSvelte5 } from './utils/svelte-version.js';
|
||||
import * as svelteCompiler from 'svelte/compiler';
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,7 @@ export function svelte(inlineOptions) {
|
||||
let viteConfig;
|
||||
/** @type {import('./types/compile.d.ts').CompileSvelte} */
|
||||
let compileSvelte;
|
||||
/* eslint-enable no-unused-vars */
|
||||
/** @type {import('./types/plugin-api.d.ts').PluginAPI} */
|
||||
const api = {};
|
||||
/** @type {import('vite').Plugin[]} */
|
||||
@@ -66,21 +68,11 @@ export function svelte(inlineOptions) {
|
||||
return extraViteConfig;
|
||||
},
|
||||
|
||||
configEnvironment(name, config, opts) {
|
||||
ensureConfigEnvironmentMainFields(name, config, opts);
|
||||
// @ts-expect-error the function above should make `resolve.mainFields` non-nullable
|
||||
config.resolve.mainFields.unshift('svelte');
|
||||
|
||||
ensureConfigEnvironmentConditions(name, config, opts);
|
||||
// @ts-expect-error the function above should make `resolve.conditions` non-nullable
|
||||
config.resolve.conditions.push('svelte');
|
||||
},
|
||||
|
||||
async configResolved(config) {
|
||||
options = resolveOptions(options, config, cache);
|
||||
patchResolvedViteConfig(config, options);
|
||||
requestParser = buildIdParser(options);
|
||||
compileSvelte = createCompileSvelte();
|
||||
compileSvelte = createCompileSvelte(options);
|
||||
viteConfig = config;
|
||||
// TODO deep clone to avoid mutability from outside?
|
||||
api.options = options;
|
||||
@@ -136,11 +128,7 @@ export function svelte(inlineOptions) {
|
||||
const ssr = !!opts?.ssr;
|
||||
const svelteRequest = requestParser(importee, ssr);
|
||||
if (svelteRequest?.query.svelte) {
|
||||
if (
|
||||
svelteRequest.query.type === 'style' &&
|
||||
!svelteRequest.raw &&
|
||||
!svelteRequest.query.inline
|
||||
) {
|
||||
if (svelteRequest.query.type === 'style' && !svelteRequest.raw) {
|
||||
// return cssId with root prefix so postcss pipeline of vite finds the directory correctly
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/14
|
||||
log.debug(
|
||||
@@ -190,7 +178,8 @@ export function svelte(inlineOptions) {
|
||||
},
|
||||
|
||||
handleHotUpdate(ctx) {
|
||||
if (!options.compilerOptions.hmr || !options.emitCss) {
|
||||
// @ts-expect-error svelte4 does not have hmr option
|
||||
if ((!options.hot && !options.compilerOptions.hmr) || !options.emitCss) {
|
||||
return;
|
||||
}
|
||||
const svelteRequest = requestParser(ctx.file, false, ctx.timestamp);
|
||||
@@ -201,8 +190,12 @@ export function svelte(inlineOptions) {
|
||||
async buildEnd() {
|
||||
await options.stats?.finishAll();
|
||||
}
|
||||
},
|
||||
{
|
||||
}
|
||||
];
|
||||
if (isSvelte5) {
|
||||
logSvelte5Warning();
|
||||
// TODO move to separate file
|
||||
plugins.push({
|
||||
name: 'vite-plugin-svelte-module',
|
||||
enforce: 'post',
|
||||
async configResolved() {
|
||||
@@ -215,8 +208,8 @@ export function svelte(inlineOptions) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const compileResult = svelteCompiler.compileModule(code, {
|
||||
dev: !viteConfig.isProduction,
|
||||
// @ts-expect-error compileModule does not exist in svelte4
|
||||
const compileResult = await svelteCompiler.compileModule(code, {
|
||||
generate: ssr ? 'server' : 'client',
|
||||
filename: moduleRequest.filename
|
||||
});
|
||||
@@ -226,9 +219,12 @@ export function svelte(inlineOptions) {
|
||||
throw toRollupError(e, options);
|
||||
}
|
||||
}
|
||||
},
|
||||
svelteInspector()
|
||||
];
|
||||
});
|
||||
}
|
||||
if (!isSvelte5) {
|
||||
// TODO reenable once svelte5 has support and update utils/log.js#logSvelte5Warning
|
||||
plugins.push(svelteInspector());
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
14
node_modules/@sveltejs/vite-plugin-svelte/src/preprocess.js
generated
vendored
14
node_modules/@sveltejs/vite-plugin-svelte/src/preprocess.js
generated
vendored
@@ -1,4 +1,3 @@
|
||||
import process from 'node:process';
|
||||
import { isCSSRequest, preprocessCSS, resolveConfig, transformWithEsbuild } from 'vite';
|
||||
import { mapToRelative, removeLangSuffix } from './utils/sourcemaps.js';
|
||||
|
||||
@@ -17,7 +16,7 @@ export const lang_sep = '.vite-preprocess';
|
||||
export function vitePreprocess(opts) {
|
||||
/** @type {import('svelte/compiler').PreprocessorGroup} */
|
||||
const preprocessor = { name: 'vite-preprocess' };
|
||||
if (opts?.script === true) {
|
||||
if (opts?.script !== false) {
|
||||
preprocessor.script = viteScript().script;
|
||||
}
|
||||
if (opts?.style !== false) {
|
||||
@@ -99,16 +98,15 @@ async function createCssTransform(style, config) {
|
||||
let resolvedConfig;
|
||||
// @ts-expect-error special prop added if running in v-p-s
|
||||
if (style.__resolvedConfig) {
|
||||
// @ts-expect-error not typed
|
||||
// @ts-expect-error
|
||||
resolvedConfig = style.__resolvedConfig;
|
||||
} else if (isResolvedConfig(config)) {
|
||||
resolvedConfig = config;
|
||||
} else {
|
||||
// default to "build" if no NODE_ENV is set to avoid running in dev mode for svelte-check etc.
|
||||
const useBuild = !process.env.NODE_ENV || process.env.NODE_ENV === 'production';
|
||||
const command = useBuild ? 'build' : 'serve';
|
||||
const defaultMode = useBuild ? 'production' : 'development';
|
||||
resolvedConfig = await resolveConfig(config, command, defaultMode, defaultMode, false);
|
||||
resolvedConfig = await resolveConfig(
|
||||
config,
|
||||
process.env.NODE_ENV === 'production' ? 'build' : 'serve'
|
||||
);
|
||||
}
|
||||
return async (code, filename) => {
|
||||
return preprocessCSS(code, filename, resolvedConfig);
|
||||
|
70
node_modules/@sveltejs/vite-plugin-svelte/src/public.d.ts
generated
vendored
70
node_modules/@sveltejs/vite-plugin-svelte/src/public.d.ts
generated
vendored
@@ -1,5 +1,7 @@
|
||||
import type { InlineConfig, ResolvedConfig } from 'vite';
|
||||
import type { CompileOptions, Warning, PreprocessorGroup } from 'svelte/compiler';
|
||||
import type { CompileOptions } from 'svelte/compiler';
|
||||
import type { Warning } from 'svelte/types/compiler/interfaces';
|
||||
import type { PreprocessorGroup } from 'svelte/compiler';
|
||||
import type { Options as InspectorOptions } from '@sveltejs/vite-plugin-svelte-inspector';
|
||||
|
||||
export type Options = Omit<SvelteConfig, 'vitePlugin'> & PluginOptionsInline;
|
||||
@@ -15,7 +17,7 @@ interface PluginOptionsInline extends PluginOptions {
|
||||
configFile?: string | false;
|
||||
}
|
||||
|
||||
export interface PluginOptions {
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* A `picomatch` pattern, or array of patterns, which specifies the files the plugin should
|
||||
* operate on. By default, all svelte files are included.
|
||||
@@ -38,13 +40,27 @@ export interface PluginOptions {
|
||||
emitCss?: boolean;
|
||||
/**
|
||||
* Enable or disable Hot Module Replacement.
|
||||
* Deprecated, use compilerOptions.hmr instead!
|
||||
*
|
||||
* @deprecated
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
|
||||
*
|
||||
* YOU HAVE BEEN WARNED
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* Set an object to pass custom options to svelte-hmr
|
||||
*
|
||||
* @see https://github.com/rixo/svelte-hmr#options
|
||||
* @default true for development, always false for production
|
||||
*/
|
||||
hot?: boolean;
|
||||
|
||||
hot?:
|
||||
| boolean
|
||||
| {
|
||||
injectCss?: boolean;
|
||||
partialAccept?: boolean;
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* Some Vite plugins can contribute additional preprocessors by defining `api.sveltePreprocess`.
|
||||
* If you don't want to use them, set this to true to ignore them all or use an array of strings
|
||||
@@ -92,9 +108,9 @@ export interface PluginOptions {
|
||||
* @example
|
||||
* ```
|
||||
* ({ filename, compileOptions }) => {
|
||||
* // Dynamically set runes mode per Svelte file
|
||||
* if (forceRunesMode(filename) && !compileOptions.runes) {
|
||||
* return { runes: true };
|
||||
* // Dynamically set hydration per Svelte file
|
||||
* if (compileWithHydratable(filename) && !compileOptions.hydratable) {
|
||||
* return { hydratable: true };
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
@@ -135,22 +151,8 @@ export interface SvelteConfig {
|
||||
|
||||
/**
|
||||
* Handles warning emitted from the Svelte compiler
|
||||
*
|
||||
* warnings emitted for files in node_modules are logged at the debug level, to see them run
|
||||
* `DEBUG=vite-plugin-svelte:node-modules-onwarn pnpm build`
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* (warning, defaultHandler) => {
|
||||
* // ignore some warnings
|
||||
* if (!['foo','bar'].includes(warning.code)) {
|
||||
* defaultHandler(warning);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
|
||||
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
|
||||
/**
|
||||
* Options for vite-plugin-svelte
|
||||
*/
|
||||
@@ -177,15 +179,6 @@ interface ExperimentalOptions {
|
||||
}
|
||||
|
||||
interface CompileModuleOptions {
|
||||
/**
|
||||
* infix that must be present in filename
|
||||
* @default ['.svelte.']
|
||||
*/
|
||||
infixes?: string[];
|
||||
/**
|
||||
* module extensions
|
||||
* @default ['.ts','.js']
|
||||
*/
|
||||
extensions?: string[];
|
||||
include?: Arrayable<string>;
|
||||
exclude?: Arrayable<string>;
|
||||
@@ -194,17 +187,8 @@ interface CompileModuleOptions {
|
||||
type Arrayable<T> = T | T[];
|
||||
|
||||
export interface VitePreprocessOptions {
|
||||
/**
|
||||
* preprocess script block with vite pipeline.
|
||||
* Since svelte5 this is not needed for typescript anymore
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
script?: boolean;
|
||||
/**
|
||||
* preprocess style blocks with vite pipeline
|
||||
*/
|
||||
style?: boolean | InlineConfig | ResolvedConfig;
|
||||
}
|
||||
// eslint-disable-next-line n/no-missing-import
|
||||
|
||||
export * from './index.js';
|
||||
|
5
node_modules/@sveltejs/vite-plugin-svelte/src/types/id.d.ts
generated
vendored
5
node_modules/@sveltejs/vite-plugin-svelte/src/types/id.d.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import type { CompileOptions } from 'svelte/compiler';
|
||||
import type { CompileOptions } from 'svelte/types/compiler/interfaces';
|
||||
|
||||
export type SvelteQueryTypes = 'style' | 'script' | 'preprocessed' | 'all';
|
||||
|
||||
@@ -9,13 +9,12 @@ export interface RequestQuery {
|
||||
sourcemap?: boolean;
|
||||
compilerOptions?: Pick<
|
||||
CompileOptions,
|
||||
'generate' | 'dev' | 'css' | 'customElement' | 'immutable'
|
||||
'generate' | 'dev' | 'css' | 'hydratable' | 'customElement' | 'immutable' | 'enableSourcemap'
|
||||
>;
|
||||
// vite specific
|
||||
url?: boolean;
|
||||
raw?: boolean;
|
||||
direct?: boolean;
|
||||
inline?: boolean;
|
||||
}
|
||||
|
||||
export interface SvelteRequest {
|
||||
|
6
node_modules/@sveltejs/vite-plugin-svelte/src/types/log.d.ts
generated
vendored
6
node_modules/@sveltejs/vite-plugin-svelte/src/types/log.d.ts
generated
vendored
@@ -1,14 +1,14 @@
|
||||
import type { Warning } from 'svelte/compiler';
|
||||
import type { Warning } from 'svelte/types/compiler/interfaces';
|
||||
|
||||
export interface LogFn extends SimpleLogFn {
|
||||
(message: string, payload?: unknown, namespace?: string): void;
|
||||
(message: string, payload?: any, namespace?: string): void;
|
||||
|
||||
enabled: boolean;
|
||||
once: SimpleLogFn;
|
||||
}
|
||||
|
||||
export interface SimpleLogFn {
|
||||
(message: string, payload?: unknown, namespace?: string): void;
|
||||
(message: string, payload?: any, namespace?: string): void;
|
||||
}
|
||||
|
||||
export type SvelteWarningsMessage = {
|
||||
|
3
node_modules/@sveltejs/vite-plugin-svelte/src/types/options.d.ts
generated
vendored
3
node_modules/@sveltejs/vite-plugin-svelte/src/types/options.d.ts
generated
vendored
@@ -1,6 +1,5 @@
|
||||
import type { CompileOptions } from 'svelte/compiler';
|
||||
import type { CompileOptions } from 'svelte/types/compiler/interfaces';
|
||||
import type { ViteDevServer } from 'vite';
|
||||
// eslint-disable-next-line n/no-missing-import
|
||||
import { VitePluginSvelteStats } from '../utils/vite-plugin-svelte-stats.js';
|
||||
import type { Options } from '../public.d.ts';
|
||||
|
||||
|
84
node_modules/@sveltejs/vite-plugin-svelte/src/utils/compile.js
generated
vendored
84
node_modules/@sveltejs/vite-plugin-svelte/src/utils/compile.js
generated
vendored
@@ -1,5 +1,6 @@
|
||||
import * as svelte from 'svelte/compiler';
|
||||
|
||||
// @ts-ignore
|
||||
import { createMakeHot } from 'svelte-hmr';
|
||||
import { safeBase64Hash } from './hash.js';
|
||||
import { log } from './log.js';
|
||||
|
||||
@@ -9,17 +10,19 @@ import {
|
||||
} from './preprocess.js';
|
||||
import { mapToRelative } from './sourcemaps.js';
|
||||
import { enhanceCompileError } from './error.js';
|
||||
import { isSvelte5 } from './svelte-version.js';
|
||||
|
||||
// TODO this is a patched version of https://github.com/sveltejs/vite-plugin-svelte/pull/796/files#diff-3bce0b33034aad4b35ca094893671f7e7ddf4d27254ae7b9b0f912027a001b15R10
|
||||
// which is closer to the other regexes in at least not falling into commented script
|
||||
// but ideally would be shared exactly with svelte and other tools that use it
|
||||
const scriptLangRE =
|
||||
/<!--[^]*?-->|<script\s+(?:[^>]*|(?:[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)\s+)*)lang=(["'])?([^"' >]+)\1[^>]*>/g;
|
||||
/<!--[^]*?-->|<script (?:[^>]*|(?:[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)\s+)*)lang=["']?([^"' >]+)["']?[^>]*>/g;
|
||||
|
||||
/**
|
||||
* @param {Function} [makeHot]
|
||||
* @returns {import('../types/compile.d.ts').CompileSvelte}
|
||||
*/
|
||||
export function createCompileSvelte() {
|
||||
export const _createCompileSvelte = (makeHot) => {
|
||||
/** @type {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection | undefined} */
|
||||
let stats;
|
||||
const devStylePreprocessor = createInjectScopeEverythingRulePreprocessorGroup();
|
||||
@@ -29,7 +32,7 @@ export function createCompileSvelte() {
|
||||
const { emitCss = true } = options;
|
||||
/** @type {string[]} */
|
||||
const dependencies = [];
|
||||
/** @type {import('svelte/compiler').Warning[]} */
|
||||
/** @type {import('svelte/types/compiler/interfaces').Warning[]} */
|
||||
const warnings = [];
|
||||
|
||||
if (options.stats) {
|
||||
@@ -60,17 +63,18 @@ export function createCompileSvelte() {
|
||||
const compileOptions = {
|
||||
...options.compilerOptions,
|
||||
filename,
|
||||
generate: ssr ? 'server' : 'client'
|
||||
// @ts-expect-error svelte5 uses server/client, svelte4 uses ssr/dom
|
||||
generate: isSvelte5 ? (ssr ? 'server' : 'client') : ssr ? 'ssr' : 'dom'
|
||||
};
|
||||
|
||||
if (compileOptions.hmr && options.emitCss) {
|
||||
if (options.hot && options.emitCss) {
|
||||
const hash = `s-${safeBase64Hash(normalizedFilename)}`;
|
||||
compileOptions.cssHash = () => hash;
|
||||
}
|
||||
|
||||
let preprocessed;
|
||||
let preprocessors = options.preprocess;
|
||||
if (!options.isBuild && options.emitCss && compileOptions.hmr) {
|
||||
if (!options.isBuild && options.emitCss && options.hot) {
|
||||
// inject preprocessor that ensures css hmr works better
|
||||
if (!Array.isArray(preprocessors)) {
|
||||
preprocessors = preprocessors
|
||||
@@ -128,22 +132,12 @@ export function createCompileSvelte() {
|
||||
...dynamicCompileOptions
|
||||
}
|
||||
: compileOptions;
|
||||
|
||||
const endStat = stats?.start(filename);
|
||||
/** @type {import('svelte/compiler').CompileResult} */
|
||||
/** @type {import('svelte/types/compiler/interfaces').CompileResult} */
|
||||
let compiled;
|
||||
try {
|
||||
compiled = svelte.compile(finalCode, { ...finalCompileOptions, filename });
|
||||
// patch output with partial accept until svelte does it
|
||||
// TODO remove later
|
||||
if (
|
||||
options.server?.config.experimental.hmrPartialAccept &&
|
||||
compiled.js.code.includes('import.meta.hot.accept(')
|
||||
) {
|
||||
compiled.js.code = compiled.js.code.replaceAll(
|
||||
'import.meta.hot.accept(',
|
||||
'import.meta.hot.acceptExports(["default"],'
|
||||
);
|
||||
}
|
||||
compiled = svelte.compile(finalCode, finalCompileOptions);
|
||||
} catch (e) {
|
||||
enhanceCompileError(e, code, preprocessors);
|
||||
throw e;
|
||||
@@ -162,18 +156,31 @@ export function createCompileSvelte() {
|
||||
}
|
||||
if (!raw) {
|
||||
// wire css import and code for hmr
|
||||
const hasCss = compiled.css?.code?.trim()?.length ?? 0 > 0;
|
||||
const hasCss = compiled.css?.code?.trim().length > 0;
|
||||
// compiler might not emit css with mode none or it may be empty
|
||||
if (emitCss && hasCss) {
|
||||
// TODO properly update sourcemap?
|
||||
compiled.js.code += `\nimport ${JSON.stringify(cssId)};\n`;
|
||||
}
|
||||
|
||||
// only apply hmr when not in ssr context and hot options are set
|
||||
if (!ssr && makeHot) {
|
||||
compiled.js.code = makeHot({
|
||||
id: filename,
|
||||
compiledCode: compiled.js.code,
|
||||
//@ts-expect-error hot isn't a boolean at this point
|
||||
hotOptions: { ...options.hot, injectCss: options.hot?.injectCss === true && hasCss },
|
||||
compiled,
|
||||
originalCode: code,
|
||||
compileOptions: finalCompileOptions
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let lang = 'js';
|
||||
for (const match of code.matchAll(scriptLangRE)) {
|
||||
if (match[2]) {
|
||||
lang = match[2];
|
||||
if (match[1]) {
|
||||
lang = match[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -182,10 +189,41 @@ export function createCompileSvelte() {
|
||||
filename,
|
||||
normalizedFilename,
|
||||
lang,
|
||||
// @ts-ignore
|
||||
compiled,
|
||||
ssr,
|
||||
dependencies,
|
||||
preprocessed: preprocessed ?? { code }
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {Function | undefined}
|
||||
*/
|
||||
function buildMakeHot(options) {
|
||||
const needsMakeHot =
|
||||
!isSvelte5 && options.hot !== false && options.isServe && !options.isProduction;
|
||||
if (needsMakeHot) {
|
||||
// @ts-ignore
|
||||
const hotApi = options?.hot?.hotApi;
|
||||
// @ts-ignore
|
||||
const adapter = options?.hot?.adapter;
|
||||
return createMakeHot({
|
||||
walk: svelte.walk,
|
||||
hotApi,
|
||||
adapter,
|
||||
hotOptions: { noOverlay: true, .../** @type {object} */ (options.hot) }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {import('../types/compile.d.ts').CompileSvelte}
|
||||
*/
|
||||
export function createCompileSvelte(options) {
|
||||
const makeHot = buildMakeHot(options);
|
||||
return _createCompileSvelte(makeHot);
|
||||
}
|
||||
|
45
node_modules/@sveltejs/vite-plugin-svelte/src/utils/constants.js
generated
vendored
45
node_modules/@sveltejs/vite-plugin-svelte/src/utils/constants.js
generated
vendored
@@ -1,26 +1,33 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { isSvelte5 } from './svelte-version.js';
|
||||
|
||||
export const SVELTE_IMPORTS = Object.entries(
|
||||
createRequire(import.meta.url)('svelte/package.json').exports
|
||||
)
|
||||
.map(([name, config]) => {
|
||||
// ignore type only
|
||||
if (typeof config === 'object' && Object.keys(config).length === 1 && config.types) {
|
||||
return '';
|
||||
export const VITE_RESOLVE_MAIN_FIELDS = ['browser', 'module', 'jsnext:main', 'jsnext'];
|
||||
|
||||
export const SVELTE_RESOLVE_MAIN_FIELDS = ['svelte'];
|
||||
|
||||
export const SVELTE_IMPORTS = [
|
||||
'svelte/animate',
|
||||
'svelte/easing',
|
||||
'svelte/internal',
|
||||
'svelte/internal/disclose-version',
|
||||
'svelte/motion',
|
||||
'svelte/ssr',
|
||||
'svelte/store',
|
||||
'svelte/transition',
|
||||
'svelte'
|
||||
];
|
||||
|
||||
export const SVELTE_HMR_IMPORTS = [
|
||||
'svelte-hmr/runtime/hot-api-esm.js',
|
||||
'svelte-hmr/runtime/proxy-adapter-dom.js',
|
||||
'svelte-hmr'
|
||||
];
|
||||
|
||||
if (isSvelte5) {
|
||||
SVELTE_IMPORTS.push('svelte/server', 'svelte/internal/server', 'svelte/legacy');
|
||||
SVELTE_HMR_IMPORTS.length = 0; // truncate, svelte-hmr isn't used with svelte5
|
||||
}
|
||||
// ignore names
|
||||
if (name === './package.json' || name === './compiler') {
|
||||
return '';
|
||||
}
|
||||
return name.replace(/^\./, 'svelte');
|
||||
})
|
||||
.filter((s) => s.length > 0);
|
||||
|
||||
export const SVELTE_EXPORT_CONDITIONS = ['svelte'];
|
||||
|
||||
export const FAQ_LINK_MISSING_EXPORTS_CONDITION =
|
||||
'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition';
|
||||
|
||||
export const DEFAULT_SVELTE_EXT = ['.svelte'];
|
||||
export const DEFAULT_SVELTE_MODULE_INFIX = ['.svelte.'];
|
||||
export const DEFAULT_SVELTE_MODULE_EXT = ['.js', '.ts'];
|
||||
|
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/dependencies.js
generated
vendored
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/dependencies.js
generated
vendored
@@ -46,6 +46,7 @@ const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
|
||||
'svelte',
|
||||
'svelte2tsx',
|
||||
'svelte-check',
|
||||
'svelte-hmr',
|
||||
'svelte-preprocess',
|
||||
'tslib',
|
||||
'typescript',
|
||||
|
47
node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js
generated
vendored
47
node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js
generated
vendored
@@ -2,7 +2,7 @@ import { buildExtendedLogMessage } from './log.js';
|
||||
|
||||
/**
|
||||
* convert an error thrown by svelte.compile to a RollupError so that vite displays it in a user friendly way
|
||||
* @param {import('svelte/compiler').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning & Error} error a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {import('vite').Rollup.RollupError} the converted error
|
||||
*/
|
||||
@@ -29,7 +29,7 @@ export function toRollupError(error, options) {
|
||||
|
||||
/**
|
||||
* convert an error thrown by svelte.compile to an esbuild PartialMessage
|
||||
* @param {import('svelte/compiler').Warning & Error & {frame?: string}} error a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning & Error} error a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {import('esbuild').PartialMessage} the converted error
|
||||
*/
|
||||
@@ -102,17 +102,7 @@ function formatFrameForVite(frame) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} code the svelte error code
|
||||
* @see https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/compiler/errors.js
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function couldBeFixedByCssPreprocessor(code) {
|
||||
return code === 'expected_token' || code === 'unexpected_eof' || code?.startsWith('css_');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('svelte/compiler').Warning & Error} err a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning & Error} err a svelte compiler error, which is a mix of Warning and an error
|
||||
* @param {string} originalCode
|
||||
* @param {import('../public.d.ts').Options['preprocess']} [preprocessors]
|
||||
*/
|
||||
@@ -122,8 +112,37 @@ export function enhanceCompileError(err, originalCode, preprocessors) {
|
||||
/** @type {string[]} */
|
||||
const additionalMessages = [];
|
||||
|
||||
// Handle incorrect TypeScript usage
|
||||
if (err.code === 'parse-error') {
|
||||
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L259
|
||||
const scriptRe =
|
||||
/<!--[^]*?-->|<script((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;
|
||||
const errIndex = err.pos ?? -1;
|
||||
|
||||
let m;
|
||||
while ((m = scriptRe.exec(originalCode))) {
|
||||
const matchStart = m.index;
|
||||
const matchEnd = matchStart + m[0].length;
|
||||
const isErrorInScript = matchStart <= errIndex && errIndex <= matchEnd;
|
||||
if (isErrorInScript) {
|
||||
// Warn missing lang="ts"
|
||||
const hasLangTs = m[1]?.includes('lang="ts"');
|
||||
if (!hasLangTs) {
|
||||
additionalMessages.push('Did you forget to add lang="ts" to your script tag?');
|
||||
}
|
||||
// Warn missing script preprocessor
|
||||
if (preprocessors.every((p) => p.script == null)) {
|
||||
const preprocessorType = hasLangTs ? 'TypeScript' : 'script';
|
||||
additionalMessages.push(
|
||||
`Did you forget to add a ${preprocessorType} preprocessor? See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/preprocess.md for more information.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle incorrect CSS preprocessor usage
|
||||
if (couldBeFixedByCssPreprocessor(err.code)) {
|
||||
if (err.code === 'css-syntax-error') {
|
||||
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L257
|
||||
const styleRe =
|
||||
/<!--[^]*?-->|<style((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
|
||||
|
100
node_modules/@sveltejs/vite-plugin-svelte/src/utils/esbuild.js
generated
vendored
100
node_modules/@sveltejs/vite-plugin-svelte/src/utils/esbuild.js
generated
vendored
@@ -2,8 +2,7 @@ import { readFileSync } from 'node:fs';
|
||||
import * as svelte from 'svelte/compiler';
|
||||
import { log } from './log.js';
|
||||
import { toESBuildError } from './error.js';
|
||||
import { safeBase64Hash } from './hash.js';
|
||||
import { normalize } from './id.js';
|
||||
import { isSvelte5 } from './svelte-version.js';
|
||||
|
||||
/**
|
||||
* @typedef {NonNullable<import('vite').DepOptimizationOptions['esbuildOptions']>} EsbuildOptions
|
||||
@@ -11,7 +10,8 @@ import { normalize } from './id.js';
|
||||
*/
|
||||
|
||||
export const facadeEsbuildSveltePluginName = 'vite-plugin-svelte:facade';
|
||||
export const facadeEsbuildSvelteModulePluginName = 'vite-plugin-svelte-module:facade';
|
||||
|
||||
const svelteModuleExtension = '.svelte.js';
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
@@ -25,15 +25,19 @@ export function esbuildSveltePlugin(options) {
|
||||
// Otherwise this would heavily slow down the scanning phase.
|
||||
if (build.initialOptions.plugins?.some((v) => v.name === 'vite:dep-scan')) return;
|
||||
|
||||
const filter = /\.svelte(?:\?.*)?$/;
|
||||
const svelteExtensions = (options.extensions ?? ['.svelte']).map((ext) => ext.slice(1));
|
||||
if (isSvelte5) {
|
||||
svelteExtensions.push(svelteModuleExtension.slice(1));
|
||||
}
|
||||
const svelteFilter = new RegExp('\\.(' + svelteExtensions.join('|') + ')(\\?.*)?$');
|
||||
/** @type {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection | undefined} */
|
||||
let statsCollection;
|
||||
build.onStart(() => {
|
||||
statsCollection = options.stats?.startCollection('prebundle library components', {
|
||||
statsCollection = options.stats?.startCollection('prebundle libraries', {
|
||||
logResult: (c) => c.stats.length > 1
|
||||
});
|
||||
});
|
||||
build.onLoad({ filter }, async ({ path: filename }) => {
|
||||
build.onLoad({ filter: svelteFilter }, async ({ path: filename }) => {
|
||||
const code = readFileSync(filename, 'utf8');
|
||||
try {
|
||||
const contents = await compileSvelte(options, { filename, code }, statsCollection);
|
||||
@@ -51,30 +55,39 @@ export function esbuildSveltePlugin(options) {
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @param {{ filename: string, code: string }} input
|
||||
* @param {{ filename: string; code: string }} input
|
||||
* @param {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection} [statsCollection]
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function compileSvelte(options, { filename, code }, statsCollection) {
|
||||
if (isSvelte5 && filename.endsWith(svelteModuleExtension)) {
|
||||
const endStat = statsCollection?.start(filename);
|
||||
// @ts-expect-error compileModule does not exist in svelte4
|
||||
const compiled = svelte.compileModule(code, {
|
||||
filename,
|
||||
generate: 'client'
|
||||
});
|
||||
if (endStat) {
|
||||
endStat();
|
||||
}
|
||||
return compiled.js.map
|
||||
? compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl()
|
||||
: compiled.js.code;
|
||||
}
|
||||
let css = options.compilerOptions.css;
|
||||
if (css !== 'injected') {
|
||||
if (css !== 'none') {
|
||||
// TODO ideally we'd be able to externalize prebundled styles too, but for now always put them in the js
|
||||
css = 'injected';
|
||||
}
|
||||
/** @type {import('svelte/compiler').CompileOptions} */
|
||||
const compileOptions = {
|
||||
dev: true, // default to dev: true because prebundling is only used in dev
|
||||
...options.compilerOptions,
|
||||
css,
|
||||
filename,
|
||||
generate: 'client'
|
||||
// @ts-expect-error svelte4 uses 'dom', svelte5 uses 'client'
|
||||
generate: isSvelte5 ? 'client' : 'dom'
|
||||
};
|
||||
|
||||
if (compileOptions.hmr && options.emitCss) {
|
||||
const hash = `s-${safeBase64Hash(normalize(filename, options.root))}`;
|
||||
compileOptions.cssHash = () => hash;
|
||||
}
|
||||
|
||||
let preprocessed;
|
||||
|
||||
if (options.preprocess) {
|
||||
@@ -118,60 +131,3 @@ async function compileSvelte(options, { filename, code }, statsCollection) {
|
||||
? compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl()
|
||||
: compiled.js.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {EsbuildPlugin}
|
||||
*/
|
||||
export function esbuildSvelteModulePlugin(options) {
|
||||
return {
|
||||
name: 'vite-plugin-svelte-module:optimize-svelte',
|
||||
setup(build) {
|
||||
// Skip in scanning phase as Vite already handles scanning Svelte files.
|
||||
// Otherwise this would heavily slow down the scanning phase.
|
||||
if (build.initialOptions.plugins?.some((v) => v.name === 'vite:dep-scan')) return;
|
||||
|
||||
const filter = /\.svelte\.[jt]s(?:\?.*)?$/;
|
||||
/** @type {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection | undefined} */
|
||||
let statsCollection;
|
||||
build.onStart(() => {
|
||||
statsCollection = options.stats?.startCollection('prebundle library modules', {
|
||||
logResult: (c) => c.stats.length > 1
|
||||
});
|
||||
});
|
||||
build.onLoad({ filter }, async ({ path: filename }) => {
|
||||
const code = readFileSync(filename, 'utf8');
|
||||
try {
|
||||
const contents = await compileSvelteModule(options, { filename, code }, statsCollection);
|
||||
return { contents };
|
||||
} catch (e) {
|
||||
return { errors: [toESBuildError(e, options)] };
|
||||
}
|
||||
});
|
||||
build.onEnd(() => {
|
||||
statsCollection?.finish();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @param {{ filename: string; code: string }} input
|
||||
* @param {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection} [statsCollection]
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function compileSvelteModule(options, { filename, code }, statsCollection) {
|
||||
const endStat = statsCollection?.start(filename);
|
||||
const compiled = svelte.compileModule(code, {
|
||||
dev: options.compilerOptions?.dev ?? true, // default to dev: true because prebundling is only used in dev
|
||||
filename,
|
||||
generate: 'client'
|
||||
});
|
||||
if (endStat) {
|
||||
endStat();
|
||||
}
|
||||
return compiled.js.map
|
||||
? compiled.js.code + '//# sourceMappingURL=' + compiled.js.map.toUrl()
|
||||
: compiled.js.code;
|
||||
}
|
||||
|
2
node_modules/@sveltejs/vite-plugin-svelte/src/utils/hash.js
generated
vendored
2
node_modules/@sveltejs/vite-plugin-svelte/src/utils/hash.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import crypto from 'node:crypto';
|
||||
import * as crypto from 'node:crypto';
|
||||
|
||||
const hashes = Object.create(null);
|
||||
|
||||
|
50
node_modules/@sveltejs/vite-plugin-svelte/src/utils/id.js
generated
vendored
50
node_modules/@sveltejs/vite-plugin-svelte/src/utils/id.js
generated
vendored
@@ -1,14 +1,19 @@
|
||||
import { createFilter, normalizePath } from 'vite';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import * as fs from 'node:fs';
|
||||
import { log } from './log.js';
|
||||
import { DEFAULT_SVELTE_MODULE_EXT, DEFAULT_SVELTE_MODULE_INFIX } from './constants.js';
|
||||
|
||||
const VITE_FS_PREFIX = '/@fs/';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
const SUPPORTED_COMPILER_OPTIONS = ['generate', 'dev', 'css', 'customElement', 'immutable'];
|
||||
const SUPPORTED_COMPILER_OPTIONS = [
|
||||
'generate',
|
||||
'dev',
|
||||
'css',
|
||||
'hydratable',
|
||||
'customElement',
|
||||
'immutable',
|
||||
'enableSourcemap'
|
||||
];
|
||||
const TYPES_WITH_COMPILER_OPTIONS = ['style', 'script', 'all'];
|
||||
|
||||
/**
|
||||
@@ -84,7 +89,7 @@ function parseRequestQuery(rawQuery) {
|
||||
const query = Object.fromEntries(new URLSearchParams(rawQuery));
|
||||
for (const key in query) {
|
||||
if (query[key] === '') {
|
||||
// @ts-expect-error not boolean
|
||||
// @ts-ignore
|
||||
query[key] = true;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +99,7 @@ function parseRequestQuery(rawQuery) {
|
||||
throw new Error(
|
||||
`Invalid compilerOptions in query ${rawQuery}. CompilerOptions are only supported for raw or direct queries with type in "${TYPES_WITH_COMPILER_OPTIONS.join(
|
||||
', '
|
||||
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"server","dev":false}`
|
||||
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"ssr","dev":false}`
|
||||
);
|
||||
}
|
||||
try {
|
||||
@@ -126,7 +131,7 @@ function parseRequestQuery(rawQuery) {
|
||||
* @param {string} normalizedRoot
|
||||
* @returns {string}
|
||||
*/
|
||||
export function normalize(filename, normalizedRoot) {
|
||||
function normalize(filename, normalizedRoot) {
|
||||
return stripRoot(normalizePath(filename), normalizedRoot);
|
||||
}
|
||||
|
||||
@@ -164,26 +169,6 @@ function buildFilter(include, exclude, extensions) {
|
||||
return (filename) => rollupFilter(filename) && extensions.some((ext) => filename.endsWith(ext));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../public.d.ts').Options['include'] | undefined} include
|
||||
* @param {import('../public.d.ts').Options['exclude'] | undefined} exclude
|
||||
* @param {string[]} infixes
|
||||
* @param {string[]} extensions
|
||||
* @returns {(filename: string) => boolean}
|
||||
*/
|
||||
function buildModuleFilter(include, exclude, infixes, extensions) {
|
||||
const rollupFilter = createFilter(include, exclude);
|
||||
return (filename) => {
|
||||
const basename = path.basename(filename);
|
||||
|
||||
return (
|
||||
rollupFilter(filename) &&
|
||||
infixes.some((infix) => basename.includes(infix)) &&
|
||||
extensions.some((ext) => basename.endsWith(ext))
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
* @returns {import('../types/id.d.ts').IdParser}
|
||||
@@ -205,15 +190,10 @@ export function buildIdParser(options) {
|
||||
* @returns {import('../types/id.d.ts').ModuleIdParser}
|
||||
*/
|
||||
export function buildModuleIdParser(options) {
|
||||
const {
|
||||
include,
|
||||
exclude,
|
||||
infixes = DEFAULT_SVELTE_MODULE_INFIX,
|
||||
extensions = DEFAULT_SVELTE_MODULE_EXT
|
||||
} = options?.experimental?.compileModule ?? {};
|
||||
const { include, exclude, extensions } = options?.experimental?.compileModule ?? {};
|
||||
const root = options.root;
|
||||
const normalizedRoot = normalizePath(root);
|
||||
const filter = buildModuleFilter(include, exclude, infixes, extensions);
|
||||
const filter = buildFilter(include, exclude, extensions ?? ['.svelte.js', '.svelte.ts']);
|
||||
return (id, ssr, timestamp = Date.now()) => {
|
||||
const { filename, rawQuery } = splitId(id);
|
||||
if (filter(filename)) {
|
||||
|
23
node_modules/@sveltejs/vite-plugin-svelte/src/utils/load-raw.js
generated
vendored
23
node_modules/@sveltejs/vite-plugin-svelte/src/utils/load-raw.js
generated
vendored
@@ -1,7 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import { toRollupError } from './error.js';
|
||||
import { log } from './log.js';
|
||||
|
||||
import { isSvelte4, isSvelte5 } from './svelte-version.js';
|
||||
/**
|
||||
* utility function to compile ?raw and ?direct requests in load hook
|
||||
*
|
||||
@@ -18,16 +18,26 @@ export async function loadRaw(svelteRequest, compileSvelte, options) {
|
||||
const source = fs.readFileSync(filename, 'utf-8');
|
||||
try {
|
||||
//avoid compileSvelte doing extra ssr stuff unless requested
|
||||
svelteRequest.ssr = query.compilerOptions?.generate === 'server';
|
||||
//@ts-ignore //@ts-expect-error generate value differs between svelte4 and 5
|
||||
svelteRequest.ssr = query.compilerOptions?.generate === (isSvelte4 ? 'ssr' : 'server');
|
||||
const type = query.type;
|
||||
compileData = await compileSvelte(svelteRequest, source, {
|
||||
...options,
|
||||
// don't use dynamic vite-plugin-svelte defaults here to ensure stable result between ssr,dev and build
|
||||
compilerOptions: {
|
||||
dev: false,
|
||||
css: 'external',
|
||||
hmr: false,
|
||||
enableSourcemap: isSvelte5
|
||||
? undefined
|
||||
: query.sourcemap
|
||||
? {
|
||||
js: type === 'script' || type === 'all',
|
||||
css: type === 'style' || type === 'all'
|
||||
}
|
||||
: false,
|
||||
...svelteRequest.query.compilerOptions
|
||||
},
|
||||
hot: false,
|
||||
emitCss: true
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -35,7 +45,7 @@ export async function loadRaw(svelteRequest, compileSvelte, options) {
|
||||
}
|
||||
let result;
|
||||
if (query.type === 'style') {
|
||||
result = compileData.compiled.css ?? { code: '', map: null };
|
||||
result = compileData.compiled.css;
|
||||
} else if (query.type === 'script') {
|
||||
result = compileData.compiled.js;
|
||||
} else if (query.type === 'preprocessed') {
|
||||
@@ -58,9 +68,7 @@ export async function loadRaw(svelteRequest, compileSvelte, options) {
|
||||
}
|
||||
log.debug(`load returns direct result for ${id}`, undefined, 'load');
|
||||
let directOutput = result.code;
|
||||
// @ts-expect-error might not be SourceMap but toUrl check should suffice
|
||||
if (query.sourcemap && result.map?.toUrl) {
|
||||
// @ts-expect-error toUrl might not exist
|
||||
const map = `sourceMappingURL=${result.map.toUrl()}`;
|
||||
if (query.type === 'style') {
|
||||
directOutput += `\n\n/*# ${map} */\n`;
|
||||
@@ -114,7 +122,8 @@ function allToRawExports(compileData, source) {
|
||||
function toRawExports(object) {
|
||||
let exports =
|
||||
Object.entries(object)
|
||||
.filter(([_key, value]) => typeof value !== 'function') // preprocess output has a toString function that's enumerable
|
||||
//eslint-disable-next-line no-unused-vars
|
||||
.filter(([key, value]) => typeof value !== 'function') // preprocess output has a toString function that's enumerable
|
||||
.sort(([a], [b]) => (a < b ? -1 : a === b ? 0 : 1))
|
||||
.map(([key, value]) => `export const ${key}=${JSON.stringify(value)}`)
|
||||
.join('\n') + '\n';
|
||||
|
3
node_modules/@sveltejs/vite-plugin-svelte/src/utils/load-svelte-config.js
generated
vendored
3
node_modules/@sveltejs/vite-plugin-svelte/src/utils/load-svelte-config.js
generated
vendored
@@ -1,6 +1,5 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import fs from 'node:fs';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { log } from './log.js';
|
||||
@@ -62,7 +61,7 @@ export async function loadSvelteConfig(viteConfig, inlineOptions) {
|
||||
try {
|
||||
// identify which require function to use (esm and cjs mode)
|
||||
const _require = import.meta.url
|
||||
? (esmRequire ?? (esmRequire = createRequire(import.meta.url)))
|
||||
? esmRequire ?? (esmRequire = createRequire(import.meta.url))
|
||||
: // eslint-disable-next-line no-undef
|
||||
require;
|
||||
|
||||
|
56
node_modules/@sveltejs/vite-plugin-svelte/src/utils/log.js
generated
vendored
56
node_modules/@sveltejs/vite-plugin-svelte/src/utils/log.js
generated
vendored
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable no-console */
|
||||
import { cyan, red, yellow } from 'kleur/colors';
|
||||
import debug from 'debug';
|
||||
import { VERSION } from 'svelte/compiler';
|
||||
|
||||
/** @type {import('../types/log.d.ts').LogLevel[]} */
|
||||
const levels = ['debug', 'info', 'warn', 'error', 'silent'];
|
||||
@@ -72,11 +73,7 @@ function _log(logger, message, payload, namespace) {
|
||||
}
|
||||
log = logger.log.extend(namespace);
|
||||
}
|
||||
if (payload !== undefined) {
|
||||
log(message, payload);
|
||||
} else {
|
||||
log(message);
|
||||
}
|
||||
payload !== undefined ? log(message, payload) : log(message);
|
||||
} else {
|
||||
logger.log(
|
||||
logger.color(
|
||||
@@ -131,21 +128,21 @@ export const log = {
|
||||
|
||||
/**
|
||||
* @param {import('../types/id.d.ts').SvelteRequest | import('../types/id.d.ts').SvelteModuleRequest} svelteRequest
|
||||
* @param {import('svelte/compiler').Warning[]} warnings
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning[]} warnings
|
||||
* @param {import('../types/options.d.ts').ResolvedOptions} options
|
||||
*/
|
||||
export function logCompilerWarnings(svelteRequest, warnings, options) {
|
||||
const { emitCss, onwarn, isBuild } = options;
|
||||
const sendViaWS = !isBuild && options.experimental?.sendWarningsToBrowser;
|
||||
let warn = isBuild ? warnBuild : warnDev;
|
||||
/** @type {import('svelte/compiler').Warning[]} */
|
||||
/** @type {import('svelte/types/compiler/interfaces').Warning[]} */
|
||||
const handledByDefaultWarn = [];
|
||||
const notIgnored = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));
|
||||
const extra = buildExtraWarnings(warnings, isBuild);
|
||||
const allWarnings = [...notIgnored, ...extra];
|
||||
if (sendViaWS) {
|
||||
const _warn = warn;
|
||||
/** @type {(w: import('svelte/compiler').Warning) => void} */
|
||||
/** @type {(w: import('svelte/types/compiler/interfaces').Warning) => void} */
|
||||
warn = (w) => {
|
||||
handledByDefaultWarn.push(w);
|
||||
_warn(w);
|
||||
@@ -175,33 +172,33 @@ export function logCompilerWarnings(svelteRequest, warnings, options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('svelte/compiler').Warning} warning
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning} warning
|
||||
* @param {boolean} isBuild
|
||||
* @param {boolean} [emitCss]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function ignoreCompilerWarning(warning, isBuild, emitCss) {
|
||||
return (
|
||||
(!emitCss && warning.code === 'css_unused_selector') || // same as rollup-plugin-svelte
|
||||
(!emitCss && warning.code === 'css-unused-selector') || // same as rollup-plugin-svelte
|
||||
(!isBuild && isNoScopableElementWarning(warning))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('svelte/compiler').Warning} warning
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning} warning
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isNoScopableElementWarning(warning) {
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/153
|
||||
return warning.code === 'css_unused_selector' && warning.message.includes('"*"');
|
||||
return warning.code === 'css-unused-selector' && warning.message.includes('"*"');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('svelte/compiler').Warning[]} warnings
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning[]} warnings
|
||||
* @param {boolean} isBuild
|
||||
* @returns {import('svelte/compiler').Warning[]}
|
||||
* @returns {import('svelte/types/compiler/interfaces').Warning[]}
|
||||
*/
|
||||
function buildExtraWarnings(warnings, isBuild) {
|
||||
const extraWarnings = [];
|
||||
@@ -223,33 +220,21 @@ function buildExtraWarnings(warnings, isBuild) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('svelte/compiler').Warning} w
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning} w
|
||||
*/
|
||||
function warnDev(w) {
|
||||
if (w.filename?.includes('node_modules')) {
|
||||
if (isDebugNamespaceEnabled('node-modules-onwarn')) {
|
||||
log.debug(buildExtendedLogMessage(w), undefined, 'node-modules-onwarn');
|
||||
}
|
||||
} else if (log.info.enabled) {
|
||||
log.info(buildExtendedLogMessage(w));
|
||||
}
|
||||
log.info.enabled && log.info(buildExtendedLogMessage(w));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('svelte/compiler').Warning & {frame?: string}} w
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning} w
|
||||
*/
|
||||
function warnBuild(w) {
|
||||
if (w.filename?.includes('node_modules')) {
|
||||
if (isDebugNamespaceEnabled('node-modules-onwarn')) {
|
||||
log.debug(buildExtendedLogMessage(w), w.frame, 'node-modules-onwarn');
|
||||
}
|
||||
} else if (log.warn.enabled) {
|
||||
log.warn(buildExtendedLogMessage(w), w.frame);
|
||||
}
|
||||
log.warn.enabled && log.warn(buildExtendedLogMessage(w), w.frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('svelte/compiler').Warning} w
|
||||
* @param {import('svelte/types/compiler/interfaces').Warning} w
|
||||
*/
|
||||
export function buildExtendedLogMessage(w) {
|
||||
const parts = [];
|
||||
@@ -275,3 +260,12 @@ export function buildExtendedLogMessage(w) {
|
||||
export function isDebugNamespaceEnabled(namespace) {
|
||||
return debug.enabled(`${prefix}:${namespace}`);
|
||||
}
|
||||
|
||||
export function logSvelte5Warning() {
|
||||
log.warn(
|
||||
`You are using Svelte ${VERSION} with vite-plugin-svelte@3. Active Svelte 5 support has moved to vite-plugin-svelte@4.
|
||||
To receive bug fixes and new features update your devDependencies to "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6" and install.
|
||||
For framework integrations that depend on it, you might have to add an override:
|
||||
"overrides": {"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6"}`.replace(/\n\s*/gm, '\n\t')
|
||||
);
|
||||
}
|
||||
|
199
node_modules/@sveltejs/vite-plugin-svelte/src/utils/options.js
generated
vendored
199
node_modules/@sveltejs/vite-plugin-svelte/src/utils/options.js
generated
vendored
@@ -1,27 +1,18 @@
|
||||
import process from 'node:process';
|
||||
import {
|
||||
defaultClientMainFields,
|
||||
defaultServerMainFields,
|
||||
defaultClientConditions,
|
||||
defaultServerConditions,
|
||||
normalizePath
|
||||
} from 'vite';
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { normalizePath } from 'vite';
|
||||
import { isDebugNamespaceEnabled, log } from './log.js';
|
||||
import { loadSvelteConfig } from './load-svelte-config.js';
|
||||
import {
|
||||
DEFAULT_SVELTE_EXT,
|
||||
FAQ_LINK_MISSING_EXPORTS_CONDITION,
|
||||
SVELTE_EXPORT_CONDITIONS,
|
||||
SVELTE_IMPORTS
|
||||
SVELTE_HMR_IMPORTS,
|
||||
SVELTE_IMPORTS,
|
||||
SVELTE_RESOLVE_MAIN_FIELDS,
|
||||
VITE_RESOLVE_MAIN_FIELDS
|
||||
} from './constants.js';
|
||||
|
||||
import path from 'node:path';
|
||||
import {
|
||||
esbuildSvelteModulePlugin,
|
||||
esbuildSveltePlugin,
|
||||
facadeEsbuildSvelteModulePluginName,
|
||||
facadeEsbuildSveltePluginName
|
||||
} from './esbuild.js';
|
||||
import { esbuildSveltePlugin, facadeEsbuildSveltePluginName } from './esbuild.js';
|
||||
import { addExtraPreprocessors } from './preprocess.js';
|
||||
import deepmerge from 'deepmerge';
|
||||
import {
|
||||
@@ -34,6 +25,8 @@ import {
|
||||
|
||||
import { isCommonDepWithoutSvelteField } from './dependencies.js';
|
||||
import { VitePluginSvelteStats } from './vite-plugin-svelte-stats.js';
|
||||
import { VitePluginSvelteCache } from './vite-plugin-svelte-cache.js';
|
||||
import { isSvelte5, isSvelte5WithHMRSupport } from './svelte-version.js';
|
||||
|
||||
const allowedPluginOptions = new Set([
|
||||
'include',
|
||||
@@ -112,7 +105,7 @@ function convertPluginOptions(config) {
|
||||
)}`
|
||||
);
|
||||
unknownPluginOptions.forEach((unkownOption) => {
|
||||
// @ts-expect-error not typed
|
||||
// @ts-ignore
|
||||
delete pluginOptions[unkownOption];
|
||||
});
|
||||
}
|
||||
@@ -146,7 +139,7 @@ export async function preResolveOptions(inlineOptions, viteUserConfig, viteEnv)
|
||||
const isBuild = viteEnv.command === 'build';
|
||||
/** @type {Partial<import('../types/options.d.ts').PreResolvedOptions>} */
|
||||
const defaultOptions = {
|
||||
extensions: DEFAULT_SVELTE_EXT,
|
||||
extensions: ['.svelte'],
|
||||
emitCss: true,
|
||||
prebundleSvelteLibraries: !isBuild
|
||||
};
|
||||
@@ -194,7 +187,7 @@ function mergeConfigs(...configs) {
|
||||
*
|
||||
* @param {import('../types/options.d.ts').PreResolvedOptions} preResolveOptions
|
||||
* @param {import('vite').ResolvedConfig} viteConfig
|
||||
* @param {import('./vite-plugin-svelte-cache.js').VitePluginSvelteCache} cache
|
||||
* @param {VitePluginSvelteCache} cache
|
||||
* @returns {import('../types/options.d.ts').ResolvedOptions}
|
||||
*/
|
||||
export function resolveOptions(preResolveOptions, viteConfig, cache) {
|
||||
@@ -203,15 +196,24 @@ export function resolveOptions(preResolveOptions, viteConfig, cache) {
|
||||
const defaultOptions = {
|
||||
compilerOptions: {
|
||||
css,
|
||||
dev: !viteConfig.isProduction,
|
||||
hmr:
|
||||
!viteConfig.isProduction &&
|
||||
!preResolveOptions.isBuild &&
|
||||
viteConfig.server &&
|
||||
viteConfig.server.hmr !== false
|
||||
dev: !viteConfig.isProduction
|
||||
}
|
||||
};
|
||||
|
||||
const hot =
|
||||
!viteConfig.isProduction && !preResolveOptions.isBuild && viteConfig.server.hmr !== false;
|
||||
if (isSvelte5) {
|
||||
if (isSvelte5WithHMRSupport) {
|
||||
// @ts-expect-error svelte4 does not have hmr option
|
||||
defaultOptions.compilerOptions.hmr = hot;
|
||||
}
|
||||
} else {
|
||||
defaultOptions.hot = !hot
|
||||
? false
|
||||
: {
|
||||
injectCss: css === 'injected',
|
||||
partialAccept: !!viteConfig.experimental?.hmrPartialAccept
|
||||
};
|
||||
}
|
||||
/** @type {Partial<import('../types/options.d.ts').ResolvedOptions>} */
|
||||
const extraOptions = {
|
||||
root: viteConfig.root,
|
||||
@@ -238,18 +240,61 @@ export function resolveOptions(preResolveOptions, viteConfig, cache) {
|
||||
* @param {import('vite').ResolvedConfig} viteConfig
|
||||
*/
|
||||
function enforceOptionsForHmr(options, viteConfig) {
|
||||
if (options.hot) {
|
||||
if (options.hot && viteConfig.server.hmr === false) {
|
||||
log.warn(
|
||||
'svelte 5 has hmr integrated in core. Please remove the vitePlugin.hot option and use compilerOptions.hmr instead'
|
||||
'vite config server.hmr is false but hot is true. Forcing hot to false as it would not work.'
|
||||
);
|
||||
options.hot = false;
|
||||
}
|
||||
if (isSvelte5) {
|
||||
if (options.hot && isSvelte5WithHMRSupport) {
|
||||
log.warn(
|
||||
'svelte 5 has hmr integrated in core. Please remove the hot option and use compilerOptions.hmr instead'
|
||||
);
|
||||
delete options.hot;
|
||||
// @ts-expect-error hmr option doesn't exist in svelte4
|
||||
options.compilerOptions.hmr = true;
|
||||
}
|
||||
if (options.compilerOptions.hmr && viteConfig.server?.hmr === false) {
|
||||
} else {
|
||||
if (options.hot) {
|
||||
if (!options.compilerOptions.dev) {
|
||||
log.warn('hmr is enabled but compilerOptions.dev is false, forcing it to true');
|
||||
options.compilerOptions.dev = true;
|
||||
}
|
||||
if (options.emitCss) {
|
||||
if (options.hot !== true && options.hot.injectCss) {
|
||||
log.warn('hmr and emitCss are enabled but hot.injectCss is true, forcing it to false');
|
||||
options.hot.injectCss = false;
|
||||
}
|
||||
const css = options.compilerOptions.css;
|
||||
if (css === true || css === 'injected') {
|
||||
const forcedCss = 'external';
|
||||
log.warn(
|
||||
'vite config server.hmr is false but compilerOptions.hmr is true. Forcing compilerOptions.hmr to false as it would not work.'
|
||||
`hmr and emitCss are enabled but compilerOptions.css is ${css}, forcing it to ${forcedCss}`
|
||||
);
|
||||
options.compilerOptions.hmr = false;
|
||||
options.compilerOptions.css = forcedCss;
|
||||
}
|
||||
} else {
|
||||
if (options.hot === true || !options.hot.injectCss) {
|
||||
log.warn(
|
||||
'hmr with emitCss disabled requires option hot.injectCss to be enabled, forcing it to true'
|
||||
);
|
||||
if (options.hot === true) {
|
||||
options.hot = { injectCss: true };
|
||||
} else {
|
||||
options.hot.injectCss = true;
|
||||
}
|
||||
}
|
||||
const css = options.compilerOptions.css;
|
||||
if (!(css === true || css === 'injected')) {
|
||||
const forcedCss = 'injected';
|
||||
log.warn(
|
||||
`hmr with emitCss disabled requires compilerOptions.css to be enabled, forcing it to ${forcedCss}`
|
||||
);
|
||||
options.compilerOptions.css = forcedCss;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,11 +303,9 @@ function enforceOptionsForHmr(options, viteConfig) {
|
||||
*/
|
||||
function enforceOptionsForProduction(options) {
|
||||
if (options.isProduction) {
|
||||
if (options.compilerOptions.hmr) {
|
||||
log.warn(
|
||||
'you are building for production but compilerOptions.hmr is true, forcing it to false'
|
||||
);
|
||||
options.compilerOptions.hmr = false;
|
||||
if (options.hot) {
|
||||
log.warn('options.hot is enabled but does not work on production build, forcing it to false');
|
||||
options.hot = false;
|
||||
}
|
||||
if (options.compilerOptions.dev) {
|
||||
log.warn(
|
||||
@@ -278,7 +321,7 @@ function enforceOptionsForProduction(options) {
|
||||
*/
|
||||
function removeIgnoredOptions(options) {
|
||||
const ignoredCompilerOptions = ['generate', 'format', 'filename'];
|
||||
if (options.compilerOptions.hmr && options.emitCss) {
|
||||
if (options.hot && options.emitCss) {
|
||||
ignoredCompilerOptions.push('cssHash');
|
||||
}
|
||||
const passedCompilerOptions = Object.keys(options.compilerOptions || {});
|
||||
@@ -337,13 +380,25 @@ function resolveViteRoot(viteConfig) {
|
||||
* @returns {Promise<Partial<import('vite').UserConfig>>}
|
||||
*/
|
||||
export async function buildExtraViteConfig(options, config) {
|
||||
// make sure we only readd vite default mainFields when no other plugin has changed the config already
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/581
|
||||
if (!config.resolve) {
|
||||
config.resolve = {};
|
||||
}
|
||||
config.resolve.mainFields = [
|
||||
...SVELTE_RESOLVE_MAIN_FIELDS,
|
||||
...(config.resolve.mainFields ?? VITE_RESOLVE_MAIN_FIELDS)
|
||||
];
|
||||
|
||||
/** @type {Partial<import('vite').UserConfig>} */
|
||||
const extraViteConfig = {
|
||||
resolve: {
|
||||
dedupe: [...SVELTE_IMPORTS]
|
||||
dedupe: [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS],
|
||||
conditions: [...SVELTE_EXPORT_CONDITIONS]
|
||||
}
|
||||
// this option is still awaiting a PR in vite to be supported
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/60
|
||||
// @ts-ignore
|
||||
// knownJsSrcExtensions: options.extensions
|
||||
};
|
||||
|
||||
@@ -385,21 +440,24 @@ export async function buildExtraViteConfig(options, config) {
|
||||
extraViteConfig.optimizeDeps = {
|
||||
...extraViteConfig.optimizeDeps,
|
||||
// Experimental Vite API to allow these extensions to be scanned and prebundled
|
||||
// @ts-ignore
|
||||
extensions: options.extensions ?? ['.svelte'],
|
||||
// Add esbuild plugin to prebundle Svelte files.
|
||||
// Currently a placeholder as more information is needed after Vite config is resolved,
|
||||
// the real Svelte plugin is added in `patchResolvedViteConfig()`
|
||||
esbuildOptions: {
|
||||
plugins: [
|
||||
{ name: facadeEsbuildSveltePluginName, setup: () => {} },
|
||||
{ name: facadeEsbuildSvelteModulePluginName, setup: () => {} }
|
||||
]
|
||||
plugins: [{ name: facadeEsbuildSveltePluginName, setup: () => {} }]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// enable hmrPartialAccept if not explicitly disabled
|
||||
if (config.experimental?.hmrPartialAccept !== false) {
|
||||
if (
|
||||
(options.hot == null ||
|
||||
options.hot === true ||
|
||||
(options.hot && options.hot.partialAccept !== false)) && // deviate from svelte-hmr, default to true
|
||||
config.experimental?.hmrPartialAccept !== false
|
||||
) {
|
||||
log.debug('enabling "experimental.hmrPartialAccept" in vite config', undefined, 'config');
|
||||
extraViteConfig.experimental = { hmrPartialAccept: true };
|
||||
}
|
||||
@@ -544,12 +602,9 @@ function buildExtraConfigForSvelte(config) {
|
||||
// include svelte imports for optimization unless explicitly excluded
|
||||
/** @type {string[]} */
|
||||
const include = [];
|
||||
/** @type {string[]} */
|
||||
const exclude = [];
|
||||
const exclude = ['svelte-hmr'];
|
||||
if (!isDepExcluded('svelte', config.optimizeDeps?.exclude ?? [])) {
|
||||
const svelteImportsToInclude = SVELTE_IMPORTS.filter(
|
||||
(si) => !(si.endsWith('/server') || si.includes('/server/'))
|
||||
);
|
||||
const svelteImportsToInclude = SVELTE_IMPORTS.filter((x) => x !== 'svelte/ssr'); // not used on clientside
|
||||
log.debug(
|
||||
`adding bare svelte packages to optimizeDeps.include: ${svelteImportsToInclude.join(', ')} `,
|
||||
undefined,
|
||||
@@ -568,15 +623,10 @@ function buildExtraConfigForSvelte(config) {
|
||||
/** @type {string[]} */
|
||||
const external = [];
|
||||
// add svelte to ssr.noExternal unless it is present in ssr.external
|
||||
// so it is correctly resolving according to the conditions in sveltes exports map
|
||||
// so we can resolve it with svelte/ssr
|
||||
if (!isDepExternaled('svelte', config.ssr?.external ?? [])) {
|
||||
noExternal.push('svelte', /^svelte\//);
|
||||
}
|
||||
// esm-env needs to be bundled by default for the development/production condition
|
||||
// be properly used by svelte
|
||||
if (!isDepExternaled('esm-env', config.ssr?.external ?? [])) {
|
||||
noExternal.push('esm-env');
|
||||
}
|
||||
return { optimizeDeps: { include, exclude }, ssr: { noExternal, external } };
|
||||
}
|
||||
|
||||
@@ -600,47 +650,6 @@ export function patchResolvedViteConfig(viteConfig, options) {
|
||||
if (facadeEsbuildSveltePlugin) {
|
||||
Object.assign(facadeEsbuildSveltePlugin, esbuildSveltePlugin(options));
|
||||
}
|
||||
const facadeEsbuildSvelteModulePlugin = viteConfig.optimizeDeps.esbuildOptions?.plugins?.find(
|
||||
(plugin) => plugin.name === facadeEsbuildSvelteModulePluginName
|
||||
);
|
||||
if (facadeEsbuildSvelteModulePlugin) {
|
||||
Object.assign(facadeEsbuildSvelteModulePlugin, esbuildSvelteModulePlugin(options));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates `config` to ensure `resolve.mainFields` is set. If unset, it emulates Vite's default fallback.
|
||||
* @param {string} name
|
||||
* @param {import('vite').EnvironmentOptions} config
|
||||
* @param {{ isSsrTargetWebworker?: boolean }} opts
|
||||
*/
|
||||
export function ensureConfigEnvironmentMainFields(name, config, opts) {
|
||||
config.resolve ??= {};
|
||||
if (config.resolve.mainFields == null) {
|
||||
if (config.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {
|
||||
config.resolve.mainFields = [...defaultClientMainFields];
|
||||
} else {
|
||||
config.resolve.mainFields = [...defaultServerMainFields];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates `config` to ensure `resolve.conditions` is set. If unset, it emulates Vite's default fallback.
|
||||
* @param {string} name
|
||||
* @param {import('vite').EnvironmentOptions} config
|
||||
* @param {{ isSsrTargetWebworker?: boolean }} opts
|
||||
*/
|
||||
export function ensureConfigEnvironmentConditions(name, config, opts) {
|
||||
config.resolve ??= {};
|
||||
if (config.resolve.conditions == null) {
|
||||
if (config.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {
|
||||
config.resolve.conditions = [...defaultClientConditions];
|
||||
} else {
|
||||
config.resolve.conditions = [...defaultServerConditions];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
8
node_modules/@sveltejs/vite-plugin-svelte/src/utils/preprocess.js
generated
vendored
8
node_modules/@sveltejs/vite-plugin-svelte/src/utils/preprocess.js
generated
vendored
@@ -42,7 +42,7 @@ function buildExtraPreprocessors(options, config) {
|
||||
/** @type {import('svelte/compiler').PreprocessorGroup[]} */
|
||||
const appendPreprocessors = [];
|
||||
|
||||
// @ts-expect-error not typed
|
||||
// @ts-ignore
|
||||
const pluginsWithPreprocessorsDeprecated = config.plugins.filter((p) => p?.sveltePreprocess);
|
||||
if (pluginsWithPreprocessorsDeprecated.length > 0) {
|
||||
log.warn(
|
||||
@@ -56,7 +56,7 @@ function buildExtraPreprocessors(options, config) {
|
||||
p.api = {};
|
||||
}
|
||||
if (p.api.sveltePreprocess === undefined) {
|
||||
// @ts-expect-error not typed
|
||||
// @ts-ignore
|
||||
p.api.sveltePreprocess = p.sveltePreprocess;
|
||||
} else {
|
||||
log.error(
|
||||
@@ -127,10 +127,10 @@ export function addExtraPreprocessors(options, config) {
|
||||
*
|
||||
* @param filename {string}
|
||||
* @param dependencies {string[]}
|
||||
* @returns {({dependencies: string[], warnings:import('svelte/compiler').Warning[] })}
|
||||
* @returns {({dependencies: string[], warnings:import('svelte/types/compiler/interfaces').Warning[] })}
|
||||
*/
|
||||
export function checkPreprocessDependencies(filename, dependencies) {
|
||||
/** @type {import('svelte/compiler').Warning[]} */
|
||||
/** @type {import('svelte/types/compiler/interfaces').Warning[]} */
|
||||
const warnings = [];
|
||||
|
||||
// to find self, we have to compare normalized filenames, but must keep the original values in `dependencies`
|
||||
|
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/sourcemaps.js
generated
vendored
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/sourcemaps.js
generated
vendored
@@ -1,5 +1,4 @@
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
|
5
node_modules/@sveltejs/vite-plugin-svelte/src/utils/svelte-version.js
generated
vendored
5
node_modules/@sveltejs/vite-plugin-svelte/src/utils/svelte-version.js
generated
vendored
@@ -1,5 +1,10 @@
|
||||
import { VERSION } from 'svelte/compiler';
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
export const isSvelte4 = VERSION.startsWith('4.');
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
8
node_modules/@sveltejs/vite-plugin-svelte/src/utils/vite-plugin-svelte-cache.js
generated
vendored
8
node_modules/@sveltejs/vite-plugin-svelte/src/utils/vite-plugin-svelte-cache.js
generated
vendored
@@ -16,9 +16,9 @@ import { normalizePath } from 'vite';
|
||||
* @class
|
||||
*/
|
||||
export class VitePluginSvelteCache {
|
||||
/** @type {Map<string, import('../types/compile.d.ts').Code | null>} */
|
||||
/** @type {Map<string, import('../types/compile.d.ts').Code>} */
|
||||
#css = new Map();
|
||||
/** @type {Map<string, import('../types/compile.d.ts').Code | null>} */
|
||||
/** @type {Map<string, import('../types/compile.d.ts').Code>} */
|
||||
#js = new Map();
|
||||
/** @type {Map<string, string[]>} */
|
||||
#dependencies = new Map();
|
||||
@@ -133,7 +133,7 @@ export class VitePluginSvelteCache {
|
||||
|
||||
/**
|
||||
* @param {import('../types/id.d.ts').SvelteRequest} svelteRequest
|
||||
* @returns {import('../types/compile.d.ts').Code | undefined | null}
|
||||
* @returns {import('../types/compile.d.ts').Code | undefined}
|
||||
*/
|
||||
getCSS(svelteRequest) {
|
||||
return this.#css.get(svelteRequest.normalizedFilename);
|
||||
@@ -141,7 +141,7 @@ export class VitePluginSvelteCache {
|
||||
|
||||
/**
|
||||
* @param {import('../types/id.d.ts').SvelteRequest} svelteRequest
|
||||
* @returns {import('../types/compile.d.ts').Code | undefined | null}
|
||||
* @returns {import('../types/compile.d.ts').Code | undefined}
|
||||
*/
|
||||
getJS(svelteRequest) {
|
||||
if (!svelteRequest.ssr) {
|
||||
|
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/vite-plugin-svelte-stats.js
generated
vendored
1
node_modules/@sveltejs/vite-plugin-svelte/src/utils/vite-plugin-svelte-stats.js
generated
vendored
@@ -89,7 +89,6 @@ export class VitePluginSvelteStats {
|
||||
/** @type {import('../types/vite-plugin-svelte-stats.d.ts').Stat[]} */
|
||||
const stats = [];
|
||||
const collectionStart = performance.now();
|
||||
|
||||
const _this = this;
|
||||
let hasLoggedProgress = false;
|
||||
/** @type {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection} */
|
||||
|
2
node_modules/@sveltejs/vite-plugin-svelte/src/utils/watch.js
generated
vendored
2
node_modules/@sveltejs/vite-plugin-svelte/src/utils/watch.js
generated
vendored
@@ -22,7 +22,7 @@ export function setupWatchers(options, cache, requestParser) {
|
||||
dependants.forEach((dependant) => {
|
||||
if (fs.existsSync(dependant)) {
|
||||
log.debug(
|
||||
`emitting virtual change event for "${dependant}" because dependency "${filename}" changed`,
|
||||
`emitting virtual change event for "${dependant}" because depdendency "${filename}" changed`,
|
||||
undefined,
|
||||
'hmr'
|
||||
);
|
||||
|
75
node_modules/@sveltejs/vite-plugin-svelte/types/index.d.ts
generated
vendored
75
node_modules/@sveltejs/vite-plugin-svelte/types/index.d.ts
generated
vendored
@@ -1,6 +1,7 @@
|
||||
declare module '@sveltejs/vite-plugin-svelte' {
|
||||
import type { InlineConfig, ResolvedConfig } from 'vite';
|
||||
import type { CompileOptions, Warning, PreprocessorGroup } from 'svelte/compiler';
|
||||
import type { CompileOptions, PreprocessorGroup } from 'svelte/compiler';
|
||||
import type { Warning } from 'svelte/types/compiler/interfaces';
|
||||
import type { Options as InspectorOptions } from '@sveltejs/vite-plugin-svelte-inspector';
|
||||
export type Options = Omit<SvelteConfig, 'vitePlugin'> & PluginOptionsInline;
|
||||
|
||||
@@ -15,7 +16,7 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
configFile?: string | false;
|
||||
}
|
||||
|
||||
export interface PluginOptions {
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* A `picomatch` pattern, or array of patterns, which specifies the files the plugin should
|
||||
* operate on. By default, all svelte files are included.
|
||||
@@ -38,13 +39,27 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
emitCss?: boolean;
|
||||
/**
|
||||
* Enable or disable Hot Module Replacement.
|
||||
* Deprecated, use compilerOptions.hmr instead!
|
||||
*
|
||||
* @deprecated
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
|
||||
*
|
||||
* YOU HAVE BEEN WARNED
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* Set an object to pass custom options to svelte-hmr
|
||||
*
|
||||
* @see https://github.com/rixo/svelte-hmr#options
|
||||
* @default true for development, always false for production
|
||||
*/
|
||||
hot?: boolean;
|
||||
|
||||
hot?:
|
||||
| boolean
|
||||
| {
|
||||
injectCss?: boolean;
|
||||
partialAccept?: boolean;
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* Some Vite plugins can contribute additional preprocessors by defining `api.sveltePreprocess`.
|
||||
* If you don't want to use them, set this to true to ignore them all or use an array of strings
|
||||
@@ -92,9 +107,9 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
* @example
|
||||
* ```
|
||||
* ({ filename, compileOptions }) => {
|
||||
* // Dynamically set runes mode per Svelte file
|
||||
* if (forceRunesMode(filename) && !compileOptions.runes) {
|
||||
* return { runes: true };
|
||||
* // Dynamically set hydration per Svelte file
|
||||
* if (compileWithHydratable(filename) && !compileOptions.hydratable) {
|
||||
* return { hydratable: true };
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
@@ -135,22 +150,8 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
|
||||
/**
|
||||
* Handles warning emitted from the Svelte compiler
|
||||
*
|
||||
* warnings emitted for files in node_modules are logged at the debug level, to see them run
|
||||
* `DEBUG=vite-plugin-svelte:node-modules-onwarn pnpm build`
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* (warning, defaultHandler) => {
|
||||
* // ignore some warnings
|
||||
* if (!['foo','bar'].includes(warning.code)) {
|
||||
* defaultHandler(warning);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
|
||||
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
|
||||
/**
|
||||
* Options for vite-plugin-svelte
|
||||
*/
|
||||
@@ -177,15 +178,6 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
}
|
||||
|
||||
interface CompileModuleOptions {
|
||||
/**
|
||||
* infix that must be present in filename
|
||||
* @default ['.svelte.']
|
||||
*/
|
||||
infixes?: string[];
|
||||
/**
|
||||
* module extensions
|
||||
* @default ['.ts','.js']
|
||||
*/
|
||||
extensions?: string[];
|
||||
include?: Arrayable<string>;
|
||||
exclude?: Arrayable<string>;
|
||||
@@ -194,23 +186,12 @@ declare module '@sveltejs/vite-plugin-svelte' {
|
||||
type Arrayable<T> = T | T[];
|
||||
|
||||
export interface VitePreprocessOptions {
|
||||
/**
|
||||
* preprocess script block with vite pipeline.
|
||||
* Since svelte5 this is not needed for typescript anymore
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
script?: boolean;
|
||||
/**
|
||||
* preprocess style blocks with vite pipeline
|
||||
*/
|
||||
style?: boolean | InlineConfig | ResolvedConfig;
|
||||
}
|
||||
export function svelte(inlineOptions?: Partial<Options>): import("vite").Plugin[];
|
||||
export function vitePreprocess(opts?: VitePreprocessOptions): import("svelte/compiler").PreprocessorGroup;
|
||||
export function loadSvelteConfig(viteConfig?: import("vite").UserConfig, inlineOptions?: Partial<Options>): Promise<Partial<SvelteConfig> | undefined>;
|
||||
|
||||
export {};
|
||||
export function svelte(inlineOptions?: Partial<Options> | undefined): import('vite').Plugin[];
|
||||
export function vitePreprocess(opts?: VitePreprocessOptions | undefined): import('svelte/compiler').PreprocessorGroup;
|
||||
export function loadSvelteConfig(viteConfig?: import("vite").UserConfig | undefined, inlineOptions?: Partial<Options> | undefined): Promise<Partial<SvelteConfig> | undefined>;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.d.ts.map
|
4
node_modules/@sveltejs/vite-plugin-svelte/types/index.d.ts.map
generated
vendored
4
node_modules/@sveltejs/vite-plugin-svelte/types/index.d.ts.map
generated
vendored
@@ -3,7 +3,6 @@
|
||||
"file": "index.d.ts",
|
||||
"names": [
|
||||
"Options",
|
||||
"PluginOptions",
|
||||
"SvelteConfig",
|
||||
"VitePreprocessOptions",
|
||||
"svelte",
|
||||
@@ -22,6 +21,5 @@
|
||||
null,
|
||||
null
|
||||
],
|
||||
"mappings": ";;;;aAIYA,OAAOA;;;;;;;;;;;;;kBAaFC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgGbC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkFZC,qBAAqBA;;;;;;;;;;;;;iBCxKtBC,MAAMA;iBCXNC,cAAcA;iBCgBRC,gBAAgBA",
|
||||
"ignoreList": []
|
||||
"mappings": ";;;;;aAMYA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2HFC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2DZC,qBAAqBA;;;;iBChKtBC,MAAMA;iBCbNC,cAAcA;iBCgBRC,gBAAgBA"
|
||||
}
|
BIN
node_modules/esbuild/bin/esbuild
generated
vendored
BIN
node_modules/esbuild/bin/esbuild
generated
vendored
Binary file not shown.
2
node_modules/esbuild/install.js
generated
vendored
2
node_modules/esbuild/install.js
generated
vendored
@@ -49,9 +49,7 @@ var knownUnixlikePackages = {
|
||||
"linux s390x BE": "@esbuild/linux-s390x",
|
||||
"linux x64 LE": "@esbuild/linux-x64",
|
||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
||||
"netbsd arm64 LE": "@esbuild/netbsd-arm64",
|
||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
||||
"openbsd arm64 LE": "@esbuild/openbsd-arm64",
|
||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
||||
};
|
||||
|
10
node_modules/esbuild/lib/main.d.ts
generated
vendored
10
node_modules/esbuild/lib/main.d.ts
generated
vendored
@@ -125,7 +125,7 @@ export interface BuildOptions extends CommonOptions {
|
||||
/** Documentation: https://esbuild.github.io/api/#external */
|
||||
external?: string[]
|
||||
/** Documentation: https://esbuild.github.io/api/#packages */
|
||||
packages?: 'bundle' | 'external'
|
||||
packages?: 'external'
|
||||
/** Documentation: https://esbuild.github.io/api/#alias */
|
||||
alias?: Record<string, string>
|
||||
/** Documentation: https://esbuild.github.io/api/#loader */
|
||||
@@ -241,15 +241,9 @@ export interface ServeOptions {
|
||||
keyfile?: string
|
||||
certfile?: string
|
||||
fallback?: string
|
||||
cors?: CORSOptions
|
||||
onRequest?: (args: ServeOnRequestArgs) => void
|
||||
}
|
||||
|
||||
/** Documentation: https://esbuild.github.io/api/#cors */
|
||||
export interface CORSOptions {
|
||||
origin?: string | string[]
|
||||
}
|
||||
|
||||
export interface ServeOnRequestArgs {
|
||||
remoteAddress: string
|
||||
method: string
|
||||
@@ -262,7 +256,7 @@ export interface ServeOnRequestArgs {
|
||||
/** Documentation: https://esbuild.github.io/api/#serve-return-values */
|
||||
export interface ServeResult {
|
||||
port: number
|
||||
hosts: string[]
|
||||
host: string
|
||||
}
|
||||
|
||||
export interface TransformOptions extends CommonOptions {
|
||||
|
126
node_modules/esbuild/lib/main.js
generated
vendored
126
node_modules/esbuild/lib/main.js
generated
vendored
@@ -218,31 +218,25 @@ function writeUInt32LE(buffer, value, offset) {
|
||||
var quote = JSON.stringify;
|
||||
var buildLogLevelDefault = "warning";
|
||||
var transformLogLevelDefault = "silent";
|
||||
function validateAndJoinStringArray(values, what) {
|
||||
const toJoin = [];
|
||||
for (const value of values) {
|
||||
validateStringValue(value, what);
|
||||
if (value.indexOf(",") >= 0) throw new Error(`Invalid ${what}: ${value}`);
|
||||
toJoin.push(value);
|
||||
}
|
||||
return toJoin.join(",");
|
||||
function validateTarget(target) {
|
||||
validateStringValue(target, "target");
|
||||
if (target.indexOf(",") >= 0) throw new Error(`Invalid target: ${target}`);
|
||||
return target;
|
||||
}
|
||||
var canBeAnything = () => null;
|
||||
var mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
|
||||
var mustBeString = (value) => typeof value === "string" ? null : "a string";
|
||||
var mustBeRegExp = (value) => value instanceof RegExp ? null : "a RegExp object";
|
||||
var mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
|
||||
var mustBeValidPortNumber = (value) => typeof value === "number" && value === (value | 0) && value >= 0 && value <= 65535 ? null : "a valid port number";
|
||||
var mustBeFunction = (value) => typeof value === "function" ? null : "a function";
|
||||
var mustBeArray = (value) => Array.isArray(value) ? null : "an array";
|
||||
var mustBeArrayOfStrings = (value) => Array.isArray(value) && value.every((x) => typeof x === "string") ? null : "an array of strings";
|
||||
var mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
|
||||
var mustBeEntryPoints = (value) => typeof value === "object" && value !== null ? null : "an array or an object";
|
||||
var mustBeWebAssemblyModule = (value) => value instanceof WebAssembly.Module ? null : "a WebAssembly.Module";
|
||||
var mustBeObjectOrNull = (value) => typeof value === "object" && !Array.isArray(value) ? null : "an object or null";
|
||||
var mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
|
||||
var mustBeStringOrObject = (value) => typeof value === "string" || typeof value === "object" && value !== null && !Array.isArray(value) ? null : "a string or an object";
|
||||
var mustBeStringOrArrayOfStrings = (value) => typeof value === "string" || Array.isArray(value) && value.every((x) => typeof x === "string") ? null : "a string or an array of strings";
|
||||
var mustBeStringOrArray = (value) => typeof value === "string" || Array.isArray(value) ? null : "a string or an array";
|
||||
var mustBeStringOrUint8Array = (value) => typeof value === "string" || value instanceof Uint8Array ? null : "a string or a Uint8Array";
|
||||
var mustBeStringOrURL = (value) => typeof value === "string" || value instanceof URL ? null : "a string or a URL";
|
||||
function getFlag(object, keys, key, mustBeFn) {
|
||||
@@ -306,7 +300,7 @@ function pushCommonFlags(flags, options, keys) {
|
||||
let legalComments = getFlag(options, keys, "legalComments", mustBeString);
|
||||
let sourceRoot = getFlag(options, keys, "sourceRoot", mustBeString);
|
||||
let sourcesContent = getFlag(options, keys, "sourcesContent", mustBeBoolean);
|
||||
let target = getFlag(options, keys, "target", mustBeStringOrArrayOfStrings);
|
||||
let target = getFlag(options, keys, "target", mustBeStringOrArray);
|
||||
let format = getFlag(options, keys, "format", mustBeString);
|
||||
let globalName = getFlag(options, keys, "globalName", mustBeString);
|
||||
let mangleProps = getFlag(options, keys, "mangleProps", mustBeRegExp);
|
||||
@@ -317,8 +311,8 @@ function pushCommonFlags(flags, options, keys) {
|
||||
let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
|
||||
let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
|
||||
let lineLimit = getFlag(options, keys, "lineLimit", mustBeInteger);
|
||||
let drop = getFlag(options, keys, "drop", mustBeArrayOfStrings);
|
||||
let dropLabels = getFlag(options, keys, "dropLabels", mustBeArrayOfStrings);
|
||||
let drop = getFlag(options, keys, "drop", mustBeArray);
|
||||
let dropLabels = getFlag(options, keys, "dropLabels", mustBeArray);
|
||||
let charset = getFlag(options, keys, "charset", mustBeString);
|
||||
let treeShaking = getFlag(options, keys, "treeShaking", mustBeBoolean);
|
||||
let ignoreAnnotations = getFlag(options, keys, "ignoreAnnotations", mustBeBoolean);
|
||||
@@ -331,14 +325,17 @@ function pushCommonFlags(flags, options, keys) {
|
||||
let define = getFlag(options, keys, "define", mustBeObject);
|
||||
let logOverride = getFlag(options, keys, "logOverride", mustBeObject);
|
||||
let supported = getFlag(options, keys, "supported", mustBeObject);
|
||||
let pure = getFlag(options, keys, "pure", mustBeArrayOfStrings);
|
||||
let pure = getFlag(options, keys, "pure", mustBeArray);
|
||||
let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
|
||||
let platform = getFlag(options, keys, "platform", mustBeString);
|
||||
let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
|
||||
if (legalComments) flags.push(`--legal-comments=${legalComments}`);
|
||||
if (sourceRoot !== void 0) flags.push(`--source-root=${sourceRoot}`);
|
||||
if (sourcesContent !== void 0) flags.push(`--sources-content=${sourcesContent}`);
|
||||
if (target) flags.push(`--target=${validateAndJoinStringArray(Array.isArray(target) ? target : [target], "target")}`);
|
||||
if (target) {
|
||||
if (Array.isArray(target)) flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
|
||||
else flags.push(`--target=${validateTarget(target)}`);
|
||||
}
|
||||
if (format) flags.push(`--format=${format}`);
|
||||
if (globalName) flags.push(`--global-name=${globalName}`);
|
||||
if (platform) flags.push(`--platform=${platform}`);
|
||||
@@ -352,9 +349,9 @@ function pushCommonFlags(flags, options, keys) {
|
||||
if (treeShaking !== void 0) flags.push(`--tree-shaking=${treeShaking}`);
|
||||
if (ignoreAnnotations) flags.push(`--ignore-annotations`);
|
||||
if (drop) for (let what of drop) flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
||||
if (dropLabels) flags.push(`--drop-labels=${validateAndJoinStringArray(dropLabels, "drop label")}`);
|
||||
if (mangleProps) flags.push(`--mangle-props=${jsRegExpToGoRegExp(mangleProps)}`);
|
||||
if (reserveProps) flags.push(`--reserve-props=${jsRegExpToGoRegExp(reserveProps)}`);
|
||||
if (dropLabels) flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
||||
if (mangleProps) flags.push(`--mangle-props=${mangleProps.source}`);
|
||||
if (reserveProps) flags.push(`--reserve-props=${reserveProps.source}`);
|
||||
if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
|
||||
if (jsx) flags.push(`--jsx=${jsx}`);
|
||||
if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
|
||||
@@ -403,11 +400,11 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
||||
let outdir = getFlag(options, keys, "outdir", mustBeString);
|
||||
let outbase = getFlag(options, keys, "outbase", mustBeString);
|
||||
let tsconfig = getFlag(options, keys, "tsconfig", mustBeString);
|
||||
let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArrayOfStrings);
|
||||
let nodePathsInput = getFlag(options, keys, "nodePaths", mustBeArrayOfStrings);
|
||||
let mainFields = getFlag(options, keys, "mainFields", mustBeArrayOfStrings);
|
||||
let conditions = getFlag(options, keys, "conditions", mustBeArrayOfStrings);
|
||||
let external = getFlag(options, keys, "external", mustBeArrayOfStrings);
|
||||
let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArray);
|
||||
let nodePathsInput = getFlag(options, keys, "nodePaths", mustBeArray);
|
||||
let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
|
||||
let conditions = getFlag(options, keys, "conditions", mustBeArray);
|
||||
let external = getFlag(options, keys, "external", mustBeArray);
|
||||
let packages = getFlag(options, keys, "packages", mustBeString);
|
||||
let alias = getFlag(options, keys, "alias", mustBeObject);
|
||||
let loader = getFlag(options, keys, "loader", mustBeObject);
|
||||
@@ -416,7 +413,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
||||
let entryNames = getFlag(options, keys, "entryNames", mustBeString);
|
||||
let chunkNames = getFlag(options, keys, "chunkNames", mustBeString);
|
||||
let assetNames = getFlag(options, keys, "assetNames", mustBeString);
|
||||
let inject = getFlag(options, keys, "inject", mustBeArrayOfStrings);
|
||||
let inject = getFlag(options, keys, "inject", mustBeArray);
|
||||
let banner = getFlag(options, keys, "banner", mustBeObject);
|
||||
let footer = getFlag(options, keys, "footer", mustBeObject);
|
||||
let entryPoints = getFlag(options, keys, "entryPoints", mustBeEntryPoints);
|
||||
@@ -438,13 +435,37 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
|
||||
if (outbase) flags.push(`--outbase=${outbase}`);
|
||||
if (tsconfig) flags.push(`--tsconfig=${tsconfig}`);
|
||||
if (packages) flags.push(`--packages=${packages}`);
|
||||
if (resolveExtensions) flags.push(`--resolve-extensions=${validateAndJoinStringArray(resolveExtensions, "resolve extension")}`);
|
||||
if (resolveExtensions) {
|
||||
let values = [];
|
||||
for (let value of resolveExtensions) {
|
||||
validateStringValue(value, "resolve extension");
|
||||
if (value.indexOf(",") >= 0) throw new Error(`Invalid resolve extension: ${value}`);
|
||||
values.push(value);
|
||||
}
|
||||
flags.push(`--resolve-extensions=${values.join(",")}`);
|
||||
}
|
||||
if (publicPath) flags.push(`--public-path=${publicPath}`);
|
||||
if (entryNames) flags.push(`--entry-names=${entryNames}`);
|
||||
if (chunkNames) flags.push(`--chunk-names=${chunkNames}`);
|
||||
if (assetNames) flags.push(`--asset-names=${assetNames}`);
|
||||
if (mainFields) flags.push(`--main-fields=${validateAndJoinStringArray(mainFields, "main field")}`);
|
||||
if (conditions) flags.push(`--conditions=${validateAndJoinStringArray(conditions, "condition")}`);
|
||||
if (mainFields) {
|
||||
let values = [];
|
||||
for (let value of mainFields) {
|
||||
validateStringValue(value, "main field");
|
||||
if (value.indexOf(",") >= 0) throw new Error(`Invalid main field: ${value}`);
|
||||
values.push(value);
|
||||
}
|
||||
flags.push(`--main-fields=${values.join(",")}`);
|
||||
}
|
||||
if (conditions) {
|
||||
let values = [];
|
||||
for (let value of conditions) {
|
||||
validateStringValue(value, "condition");
|
||||
if (value.indexOf(",") >= 0) throw new Error(`Invalid condition: ${value}`);
|
||||
values.push(value);
|
||||
}
|
||||
flags.push(`--conditions=${values.join(",")}`);
|
||||
}
|
||||
if (external) for (let name of external) flags.push(`--external:${validateStringValue(name, "external")}`);
|
||||
if (alias) {
|
||||
for (let old in alias) {
|
||||
@@ -641,8 +662,8 @@ function createChannel(streamIn) {
|
||||
if (isFirstPacket) {
|
||||
isFirstPacket = false;
|
||||
let binaryVersion = String.fromCharCode(...bytes);
|
||||
if (binaryVersion !== "0.25.4") {
|
||||
throw new Error(`Cannot start service: Host version "${"0.25.4"}" does not match binary version ${quote(binaryVersion)}`);
|
||||
if (binaryVersion !== "0.21.5") {
|
||||
throw new Error(`Cannot start service: Host version "${"0.21.5"}" does not match binary version ${quote(binaryVersion)}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -997,13 +1018,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
||||
serve: (options2 = {}) => new Promise((resolve, reject) => {
|
||||
if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
|
||||
const keys = {};
|
||||
const port = getFlag(options2, keys, "port", mustBeValidPortNumber);
|
||||
const port = getFlag(options2, keys, "port", mustBeInteger);
|
||||
const host = getFlag(options2, keys, "host", mustBeString);
|
||||
const servedir = getFlag(options2, keys, "servedir", mustBeString);
|
||||
const keyfile = getFlag(options2, keys, "keyfile", mustBeString);
|
||||
const certfile = getFlag(options2, keys, "certfile", mustBeString);
|
||||
const fallback = getFlag(options2, keys, "fallback", mustBeString);
|
||||
const cors = getFlag(options2, keys, "cors", mustBeObject);
|
||||
const onRequest = getFlag(options2, keys, "onRequest", mustBeFunction);
|
||||
checkForInvalidFlags(options2, keys, `in serve() call`);
|
||||
const request2 = {
|
||||
@@ -1017,13 +1037,6 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
|
||||
if (keyfile !== void 0) request2.keyfile = keyfile;
|
||||
if (certfile !== void 0) request2.certfile = certfile;
|
||||
if (fallback !== void 0) request2.fallback = fallback;
|
||||
if (cors) {
|
||||
const corsKeys = {};
|
||||
const origin = getFlag(cors, corsKeys, "origin", mustBeStringOrArrayOfStrings);
|
||||
checkForInvalidFlags(cors, corsKeys, `on "cors" object`);
|
||||
if (Array.isArray(origin)) request2.corsOrigin = origin;
|
||||
else if (origin !== void 0) request2.corsOrigin = [origin];
|
||||
}
|
||||
sendRequest(refs, request2, (error2, response2) => {
|
||||
if (error2) return reject(new Error(error2));
|
||||
if (onRequest) {
|
||||
@@ -1159,7 +1172,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
||||
if (filter == null) throw new Error(`onResolve() call is missing a filter`);
|
||||
let id = nextCallbackID++;
|
||||
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
||||
plugin.onResolve.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
||||
plugin.onResolve.push({ id, filter: filter.source, namespace: namespace || "" });
|
||||
},
|
||||
onLoad(options, callback) {
|
||||
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
||||
@@ -1171,7 +1184,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
||||
if (filter == null) throw new Error(`onLoad() call is missing a filter`);
|
||||
let id = nextCallbackID++;
|
||||
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
||||
plugin.onLoad.push({ id, filter: jsRegExpToGoRegExp(filter), namespace: namespace || "" });
|
||||
plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
|
||||
},
|
||||
onDispose(callback) {
|
||||
onDisposeCallbacks.push(callback);
|
||||
@@ -1185,7 +1198,6 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
||||
}
|
||||
}
|
||||
requestCallbacks["on-start"] = async (id, request) => {
|
||||
details.clear();
|
||||
let response = { errors: [], warnings: [] };
|
||||
await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {
|
||||
try {
|
||||
@@ -1231,8 +1243,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
||||
let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
|
||||
let errors = getFlag(result, keys, "errors", mustBeArray);
|
||||
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
||||
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArrayOfStrings);
|
||||
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArrayOfStrings);
|
||||
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
||||
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
||||
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);
|
||||
response.id = id2;
|
||||
if (pluginName != null) response.pluginName = pluginName;
|
||||
@@ -1277,8 +1289,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
||||
let loader = getFlag(result, keys, "loader", mustBeString);
|
||||
let errors = getFlag(result, keys, "errors", mustBeArray);
|
||||
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
||||
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArrayOfStrings);
|
||||
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArrayOfStrings);
|
||||
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
||||
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
||||
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);
|
||||
response.id = id2;
|
||||
if (pluginName != null) response.pluginName = pluginName;
|
||||
@@ -1359,9 +1371,6 @@ function createObjectStash() {
|
||||
const map = /* @__PURE__ */ new Map();
|
||||
let nextID = 0;
|
||||
return {
|
||||
clear() {
|
||||
map.clear();
|
||||
},
|
||||
load(id) {
|
||||
return map.get(id);
|
||||
},
|
||||
@@ -1582,11 +1591,6 @@ function convertOutputFiles({ path: path3, contents, hash }) {
|
||||
}
|
||||
};
|
||||
}
|
||||
function jsRegExpToGoRegExp(regexp) {
|
||||
let result = regexp.source;
|
||||
if (regexp.flags) result = `(?${regexp.flags})${result}`;
|
||||
return result;
|
||||
}
|
||||
|
||||
// lib/npm/node-platform.ts
|
||||
var fs = require("fs");
|
||||
@@ -1617,9 +1621,7 @@ var knownUnixlikePackages = {
|
||||
"linux s390x BE": "@esbuild/linux-s390x",
|
||||
"linux x64 LE": "@esbuild/linux-x64",
|
||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
||||
"netbsd arm64 LE": "@esbuild/netbsd-arm64",
|
||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
||||
"openbsd arm64 LE": "@esbuild/openbsd-arm64",
|
||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
||||
};
|
||||
@@ -1765,7 +1767,7 @@ for your current platform.`);
|
||||
"node_modules",
|
||||
".cache",
|
||||
"esbuild",
|
||||
`pnpapi-${pkg.replace("/", "-")}-${"0.25.4"}-${path.basename(subpath)}`
|
||||
`pnpapi-${pkg.replace("/", "-")}-${"0.21.5"}-${path.basename(subpath)}`
|
||||
);
|
||||
if (!fs.existsSync(binTargetPath)) {
|
||||
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
|
||||
@@ -1800,7 +1802,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
||||
}
|
||||
}
|
||||
var _a;
|
||||
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.25.4";
|
||||
var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.21.5";
|
||||
var esbuildCommandAndArgs = () => {
|
||||
if ((!ESBUILD_BINARY_PATH || false) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
|
||||
throw new Error(
|
||||
@@ -1867,7 +1869,7 @@ var fsAsync = {
|
||||
}
|
||||
}
|
||||
};
|
||||
var version = "0.25.4";
|
||||
var version = "0.21.5";
|
||||
var build = (options) => ensureServiceIsRunning().build(options);
|
||||
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
||||
var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
|
||||
@@ -1970,7 +1972,7 @@ var stopService;
|
||||
var ensureServiceIsRunning = () => {
|
||||
if (longLivedService) return longLivedService;
|
||||
let [command, args] = esbuildCommandAndArgs();
|
||||
let child = child_process.spawn(command, args.concat(`--service=${"0.25.4"}`, "--ping"), {
|
||||
let child = child_process.spawn(command, args.concat(`--service=${"0.21.5"}`, "--ping"), {
|
||||
windowsHide: true,
|
||||
stdio: ["pipe", "pipe", "inherit"],
|
||||
cwd: defaultWD
|
||||
@@ -2074,7 +2076,7 @@ var runServiceSync = (callback) => {
|
||||
esbuild: node_exports
|
||||
});
|
||||
callback(service);
|
||||
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.25.4"}`), {
|
||||
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.21.5"}`), {
|
||||
cwd: defaultWD,
|
||||
windowsHide: true,
|
||||
input: stdin,
|
||||
@@ -2094,7 +2096,7 @@ var workerThreadService = null;
|
||||
var startWorkerThreadService = (worker_threads2) => {
|
||||
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
||||
let worker = new worker_threads2.Worker(__filename, {
|
||||
workerData: { workerPort, defaultWD, esbuildVersion: "0.25.4" },
|
||||
workerData: { workerPort, defaultWD, esbuildVersion: "0.21.5" },
|
||||
transferList: [workerPort],
|
||||
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
||||
//
|
||||
|
52
node_modules/esbuild/package.json
generated
vendored
52
node_modules/esbuild/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "esbuild",
|
||||
"version": "0.25.4",
|
||||
"version": "0.21.5",
|
||||
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -12,37 +12,35 @@
|
||||
"main": "lib/main.js",
|
||||
"types": "lib/main.d.ts",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12"
|
||||
},
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.4",
|
||||
"@esbuild/android-arm": "0.25.4",
|
||||
"@esbuild/android-arm64": "0.25.4",
|
||||
"@esbuild/android-x64": "0.25.4",
|
||||
"@esbuild/darwin-arm64": "0.25.4",
|
||||
"@esbuild/darwin-x64": "0.25.4",
|
||||
"@esbuild/freebsd-arm64": "0.25.4",
|
||||
"@esbuild/freebsd-x64": "0.25.4",
|
||||
"@esbuild/linux-arm": "0.25.4",
|
||||
"@esbuild/linux-arm64": "0.25.4",
|
||||
"@esbuild/linux-ia32": "0.25.4",
|
||||
"@esbuild/linux-loong64": "0.25.4",
|
||||
"@esbuild/linux-mips64el": "0.25.4",
|
||||
"@esbuild/linux-ppc64": "0.25.4",
|
||||
"@esbuild/linux-riscv64": "0.25.4",
|
||||
"@esbuild/linux-s390x": "0.25.4",
|
||||
"@esbuild/linux-x64": "0.25.4",
|
||||
"@esbuild/netbsd-arm64": "0.25.4",
|
||||
"@esbuild/netbsd-x64": "0.25.4",
|
||||
"@esbuild/openbsd-arm64": "0.25.4",
|
||||
"@esbuild/openbsd-x64": "0.25.4",
|
||||
"@esbuild/sunos-x64": "0.25.4",
|
||||
"@esbuild/win32-arm64": "0.25.4",
|
||||
"@esbuild/win32-ia32": "0.25.4",
|
||||
"@esbuild/win32-x64": "0.25.4"
|
||||
"@esbuild/aix-ppc64": "0.21.5",
|
||||
"@esbuild/android-arm": "0.21.5",
|
||||
"@esbuild/android-arm64": "0.21.5",
|
||||
"@esbuild/android-x64": "0.21.5",
|
||||
"@esbuild/darwin-arm64": "0.21.5",
|
||||
"@esbuild/darwin-x64": "0.21.5",
|
||||
"@esbuild/freebsd-arm64": "0.21.5",
|
||||
"@esbuild/freebsd-x64": "0.21.5",
|
||||
"@esbuild/linux-arm": "0.21.5",
|
||||
"@esbuild/linux-arm64": "0.21.5",
|
||||
"@esbuild/linux-ia32": "0.21.5",
|
||||
"@esbuild/linux-loong64": "0.21.5",
|
||||
"@esbuild/linux-mips64el": "0.21.5",
|
||||
"@esbuild/linux-ppc64": "0.21.5",
|
||||
"@esbuild/linux-riscv64": "0.21.5",
|
||||
"@esbuild/linux-s390x": "0.21.5",
|
||||
"@esbuild/linux-x64": "0.21.5",
|
||||
"@esbuild/netbsd-x64": "0.21.5",
|
||||
"@esbuild/openbsd-x64": "0.21.5",
|
||||
"@esbuild/sunos-x64": "0.21.5",
|
||||
"@esbuild/win32-arm64": "0.21.5",
|
||||
"@esbuild/win32-ia32": "0.21.5",
|
||||
"@esbuild/win32-x64": "0.21.5"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
5
node_modules/vite/node_modules/picomatch/LICENSE → node_modules/fsevents/LICENSE
generated
vendored
5
node_modules/vite/node_modules/picomatch/LICENSE → node_modules/fsevents/LICENSE
generated
vendored
@@ -1,6 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
Copyright (c) 2017-present, Jon Schlinkert.
|
||||
Copyright (C) 2010-2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
89
node_modules/fsevents/README.md
generated
vendored
Normal file
89
node_modules/fsevents/README.md
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# fsevents
|
||||
|
||||
Native access to MacOS FSEvents in [Node.js](https://nodejs.org/)
|
||||
|
||||
The FSEvents API in MacOS allows applications to register for notifications of
|
||||
changes to a given directory tree. It is a very fast and lightweight alternative
|
||||
to kqueue.
|
||||
|
||||
This is a low-level library. For a cross-platform file watching module that
|
||||
uses fsevents, check out [Chokidar](https://github.com/paulmillr/chokidar).
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
npm install fsevents
|
||||
```
|
||||
|
||||
Supports only **Node.js v8.16 and higher**.
|
||||
|
||||
```js
|
||||
const fsevents = require('fsevents');
|
||||
|
||||
// To start observation
|
||||
const stop = fsevents.watch(__dirname, (path, flags, id) => {
|
||||
const info = fsevents.getInfo(path, flags);
|
||||
});
|
||||
|
||||
// To end observation
|
||||
stop();
|
||||
```
|
||||
|
||||
> **Important note:** The API behaviour is slightly different from typical JS APIs. The `stop` function **must** be
|
||||
> retrieved and stored somewhere, even if you don't plan to stop the watcher. If you forget it, the garbage collector
|
||||
> will eventually kick in, the watcher will be unregistered, and your callbacks won't be called anymore.
|
||||
|
||||
The callback passed as the second parameter to `.watch` get's called whenever the operating system detects a
|
||||
a change in the file system. It takes three arguments:
|
||||
|
||||
###### `fsevents.watch(dirname: string, (path: string, flags: number, id: string) => void): () => Promise<undefined>`
|
||||
|
||||
* `path: string` - the item in the filesystem that have been changed
|
||||
* `flags: number` - a numeric value describing what the change was
|
||||
* `id: string` - an unique-id identifying this specific event
|
||||
|
||||
Returns closer callback which when called returns a Promise resolving when the watcher process has been shut down.
|
||||
|
||||
###### `fsevents.getInfo(path: string, flags: number, id: string): FsEventInfo`
|
||||
|
||||
The `getInfo` function takes the `path`, `flags` and `id` arguments and converts those parameters into a structure
|
||||
that is easier to digest to determine what the change was.
|
||||
|
||||
The `FsEventsInfo` has the following shape:
|
||||
|
||||
```js
|
||||
/**
|
||||
* @typedef {'created'|'modified'|'deleted'|'moved'|'root-changed'|'cloned'|'unknown'} FsEventsEvent
|
||||
* @typedef {'file'|'directory'|'symlink'} FsEventsType
|
||||
*/
|
||||
{
|
||||
"event": "created", // {FsEventsEvent}
|
||||
"path": "file.txt",
|
||||
"type": "file", // {FsEventsType}
|
||||
"changes": {
|
||||
"inode": true, // Had iNode Meta-Information changed
|
||||
"finder": false, // Had Finder Meta-Data changed
|
||||
"access": false, // Had access permissions changed
|
||||
"xattrs": false // Had xAttributes changed
|
||||
},
|
||||
"flags": 0x100000000
|
||||
}
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
- v2.3 supports Apple Silicon ARM CPUs
|
||||
- v2 supports node 8.16+ and reduces package size massively
|
||||
- v1.2.8 supports node 6+
|
||||
- v1.2.7 supports node 4+
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- I'm getting `EBADPLATFORM` `Unsupported platform for fsevents` error.
|
||||
- It's fine, nothing is broken. fsevents is macos-only. Other platforms are skipped. If you want to hide this warning, report a bug to NPM bugtracker asking them to hide ebadplatform warnings by default.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License Copyright (C) 2010-2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller — see LICENSE file.
|
||||
|
||||
Visit our [GitHub page](https://github.com/fsevents/fsevents) and [NPM Page](https://npmjs.org/package/fsevents)
|
46
node_modules/fsevents/fsevents.d.ts
generated
vendored
Normal file
46
node_modules/fsevents/fsevents.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
declare type Event = "created" | "cloned" | "modified" | "deleted" | "moved" | "root-changed" | "unknown";
|
||||
declare type Type = "file" | "directory" | "symlink";
|
||||
declare type FileChanges = {
|
||||
inode: boolean;
|
||||
finder: boolean;
|
||||
access: boolean;
|
||||
xattrs: boolean;
|
||||
};
|
||||
declare type Info = {
|
||||
event: Event;
|
||||
path: string;
|
||||
type: Type;
|
||||
changes: FileChanges;
|
||||
flags: number;
|
||||
};
|
||||
declare type WatchHandler = (path: string, flags: number, id: string) => void;
|
||||
export declare function watch(path: string, handler: WatchHandler): () => Promise<void>;
|
||||
export declare function watch(path: string, since: number, handler: WatchHandler): () => Promise<void>;
|
||||
export declare function getInfo(path: string, flags: number): Info;
|
||||
export declare const constants: {
|
||||
None: 0x00000000;
|
||||
MustScanSubDirs: 0x00000001;
|
||||
UserDropped: 0x00000002;
|
||||
KernelDropped: 0x00000004;
|
||||
EventIdsWrapped: 0x00000008;
|
||||
HistoryDone: 0x00000010;
|
||||
RootChanged: 0x00000020;
|
||||
Mount: 0x00000040;
|
||||
Unmount: 0x00000080;
|
||||
ItemCreated: 0x00000100;
|
||||
ItemRemoved: 0x00000200;
|
||||
ItemInodeMetaMod: 0x00000400;
|
||||
ItemRenamed: 0x00000800;
|
||||
ItemModified: 0x00001000;
|
||||
ItemFinderInfoMod: 0x00002000;
|
||||
ItemChangeOwner: 0x00004000;
|
||||
ItemXattrMod: 0x00008000;
|
||||
ItemIsFile: 0x00010000;
|
||||
ItemIsDir: 0x00020000;
|
||||
ItemIsSymlink: 0x00040000;
|
||||
ItemIsHardlink: 0x00100000;
|
||||
ItemIsLastHardlink: 0x00200000;
|
||||
OwnEvent: 0x00080000;
|
||||
ItemCloned: 0x00400000;
|
||||
};
|
||||
export {};
|
83
node_modules/fsevents/fsevents.js
generated
vendored
Normal file
83
node_modules/fsevents/fsevents.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
** © 2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
||||
** Licensed under MIT License.
|
||||
*/
|
||||
|
||||
/* jshint node:true */
|
||||
"use strict";
|
||||
|
||||
if (process.platform !== "darwin") {
|
||||
throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`);
|
||||
}
|
||||
|
||||
const Native = require("./fsevents.node");
|
||||
const events = Native.constants;
|
||||
|
||||
function watch(path, since, handler) {
|
||||
if (typeof path !== "string") {
|
||||
throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
|
||||
}
|
||||
if ("function" === typeof since && "undefined" === typeof handler) {
|
||||
handler = since;
|
||||
since = Native.flags.SinceNow;
|
||||
}
|
||||
if (typeof since !== "number") {
|
||||
throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`);
|
||||
}
|
||||
if (typeof handler !== "function") {
|
||||
throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`);
|
||||
}
|
||||
|
||||
let instance = Native.start(Native.global, path, since, handler);
|
||||
if (!instance) throw new Error(`could not watch: ${path}`);
|
||||
return () => {
|
||||
const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(undefined);
|
||||
instance = undefined;
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function getInfo(path, flags) {
|
||||
return {
|
||||
path,
|
||||
flags,
|
||||
event: getEventType(flags),
|
||||
type: getFileType(flags),
|
||||
changes: getFileChanges(flags),
|
||||
};
|
||||
}
|
||||
|
||||
function getFileType(flags) {
|
||||
if (events.ItemIsFile & flags) return "file";
|
||||
if (events.ItemIsDir & flags) return "directory";
|
||||
if (events.MustScanSubDirs & flags) return "directory";
|
||||
if (events.ItemIsSymlink & flags) return "symlink";
|
||||
}
|
||||
function anyIsTrue(obj) {
|
||||
for (let key in obj) {
|
||||
if (obj[key]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getEventType(flags) {
|
||||
if (events.ItemRemoved & flags) return "deleted";
|
||||
if (events.ItemRenamed & flags) return "moved";
|
||||
if (events.ItemCreated & flags) return "created";
|
||||
if (events.ItemModified & flags) return "modified";
|
||||
if (events.RootChanged & flags) return "root-changed";
|
||||
if (events.ItemCloned & flags) return "cloned";
|
||||
if (anyIsTrue(flags)) return "modified";
|
||||
return "unknown";
|
||||
}
|
||||
function getFileChanges(flags) {
|
||||
return {
|
||||
inode: !!(events.ItemInodeMetaMod & flags),
|
||||
finder: !!(events.ItemFinderInfoMod & flags),
|
||||
access: !!(events.ItemChangeOwner & flags),
|
||||
xattrs: !!(events.ItemXattrMod & flags),
|
||||
};
|
||||
}
|
||||
|
||||
exports.watch = watch;
|
||||
exports.getInfo = getInfo;
|
||||
exports.constants = events;
|
BIN
node_modules/fsevents/fsevents.node
generated
vendored
Executable file
BIN
node_modules/fsevents/fsevents.node
generated
vendored
Executable file
Binary file not shown.
62
node_modules/fsevents/package.json
generated
vendored
Normal file
62
node_modules/fsevents/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "fsevents",
|
||||
"version": "2.3.3",
|
||||
"description": "Native Access to MacOS FSEvents",
|
||||
"main": "fsevents.js",
|
||||
"types": "fsevents.d.ts",
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"files": [
|
||||
"fsevents.d.ts",
|
||||
"fsevents.js",
|
||||
"fsevents.node"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "node-gyp clean && rm -f fsevents.node",
|
||||
"build": "node-gyp clean && rm -f fsevents.node && node-gyp rebuild && node-gyp clean",
|
||||
"test": "/bin/bash ./test.sh 2>/dev/null",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fsevents/fsevents.git"
|
||||
},
|
||||
"keywords": [
|
||||
"fsevents",
|
||||
"mac"
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Philipp Dunkel",
|
||||
"email": "pip@pipobscure.com"
|
||||
},
|
||||
{
|
||||
"name": "Ben Noordhuis",
|
||||
"email": "info@bnoordhuis.nl"
|
||||
},
|
||||
{
|
||||
"name": "Elan Shankar",
|
||||
"email": "elan.shanker@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Miroslav Bajtoš",
|
||||
"email": "mbajtoss@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Paul Miller",
|
||||
"url": "https://paulmillr.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/fsevents/fsevents/issues"
|
||||
},
|
||||
"homepage": "https://github.com/fsevents/fsevents",
|
||||
"devDependencies": {
|
||||
"node-gyp": "^9.4.0"
|
||||
}
|
||||
}
|
13
node_modules/svelte-hmr/LICENSE
generated
vendored
Normal file
13
node_modules/svelte-hmr/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright 2019 - 2020, rixo and the svelte-hmr contributors.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
223
node_modules/svelte-hmr/README.md
generated
vendored
Normal file
223
node_modules/svelte-hmr/README.md
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
# svelte-hmr
|
||||
|
||||
HMR commons for Svelte 3.
|
||||
|
||||
This packages provides shared dependencies for implementing Svelte HMR in any bundler plugins.
|
||||
|
||||
If you want to _use_ HMR in your Svelte project, what you need is a HMR enabled plugin for your bundler (e.g. Rollup or Webpack). You'll find a list of available tools at the end of this doc.
|
||||
|
||||
On the other hand, if you are really developing a plugin... Sorry, no docs for now! Drop me a line, I'd be happy to help!
|
||||
|
||||
## Features
|
||||
|
||||
- update Svelte components in place
|
||||
|
||||
- preservation of component state, including local state (i.e. `let` vars in your components)
|
||||
|
||||
- inject CSS instead of doing a full replace when only the component's CSS has changed, with compatible HMR APIs (`rollup-plugin-hot`, Nollup, and Snowpack for now)
|
||||
|
||||
## Options
|
||||
|
||||
Those are the HMR options that are implemented by `svelte-hmr` itself, and so should be supported by any plugin listed bellow (especially if they include a link pointing to this section). How to pass those options is specific to each plugins, so refer to their specific docs on this point.
|
||||
|
||||
#### noReload
|
||||
|
||||
Type: `bool`<br>
|
||||
Default: `false`
|
||||
|
||||
By default, `svelte-hmr` will trigger a full browser reload when it detects an error that will prevent subsequent HMR updates to be applied correctly. Set this to `true` to prevent automatic reloads. Note that Svelte Native does _not_ execute in a browser, and so this option has no effect there.
|
||||
|
||||
#### noPreserveState
|
||||
|
||||
**Deprecated: removed and default changed from version 0.12. Use `preserveLocalState` instead.**
|
||||
|
||||
#### preserveLocalState
|
||||
|
||||
Type: `bool`<br>
|
||||
Default: `false`
|
||||
|
||||
Enable [preservation of local state](#preservation-of-local-state) for all variables in all components.
|
||||
|
||||
#### noPreserveStateKey
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'@hmr:reset'` (also accepts legacy `'@!hmr'`)
|
||||
|
||||
Force disable preservation of local state for this component.
|
||||
|
||||
This flag has priority over all other settings of state preservation. If it is present, all the state of the component will be reset on the next update, regardless of the value of all the other state preservation settings.
|
||||
|
||||
```svelte
|
||||
<!-- @hmr:reset -->
|
||||
|
||||
<script>
|
||||
'@hmr:reset'
|
||||
|
||||
// @hmr:reset
|
||||
</script>
|
||||
```
|
||||
|
||||
#### preserveAllLocalStateKey
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'@hmr:keep-all'`
|
||||
|
||||
Force preservation of all local variables of this component.
|
||||
|
||||
```svelte
|
||||
<!-- @hmr:keep-all -->
|
||||
|
||||
<script>
|
||||
'@hmr:keep-all'
|
||||
|
||||
// @hmr:keep-all
|
||||
</script>
|
||||
```
|
||||
|
||||
#### preserveLocalStateKey
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'@hmr:keep'`
|
||||
|
||||
Force preservation of a given local variable in this component.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
// @hmr:keep
|
||||
let x = 0
|
||||
|
||||
let y = 0 // @hmr:keep
|
||||
|
||||
x = 1 // @hmr:keep
|
||||
</script>
|
||||
```
|
||||
|
||||
#### optimistic
|
||||
|
||||
Type: `bool`<br>
|
||||
Default: `false`
|
||||
|
||||
When `false`, runtime errors during component init (i.e. when your `<script>` code is run) are considered fatal to HMR (hence worthy of a full reload if `noReload` option is not set). When `true`, `svelte-hmr` will try to render the next version of the component in the place of the one that has crashed instead of programming a full reload.
|
||||
|
||||
## What's HMR, by the way?
|
||||
|
||||
> **NOTE** To avoid repetition, the following text only mentions HMR in the context of browsers, but it can also be used in other platforms. For example `svelte-hmr` is also used in Svelte Native.
|
||||
|
||||
HMR stands for Hot Module Replacement. It is a tool that is used during development to replace only the parts that have changed in a _running_ application, without the need to reload the whole browser page.
|
||||
|
||||
It's nice because it shortens your feedback loop (you don't lose the current state of the page you're working it with each code change), and it feels like magic! :sparkles:
|
||||
|
||||
Well, since you're reading this, let me tell you a little more about HMR. Magic is actually not such a good think in software development, so if we can demystify HMR a bit, it will probably benefits you when it comes to answer setup questions or, generally, get the most out of your HMR experience.
|
||||
|
||||
So... There are multiple layers to HMR. The first one is the technical capacity to actually replace a JS _module_ (think ES module -- in practice a JS file) at runtime. This capacity is provided (or not) by your bundler or dev server (e.g. Webpack, Parcel, Vite, Snowpack...). A notable absent in the HMR capable bundlers is Rollup, but a HMR plugin exists, as well as a Rollup-compatible super fast dev bundler and server, Nollup (see links below).
|
||||
|
||||
The HMR capacity essentially revolves around watching your file system and sending events to the browser when this happens (and, of course, doing all the other bundler stuff, but they're not interesting for this discussion).
|
||||
|
||||
In the browser, we need something to receive and process those events. And so there is a HMR runtime (i.e. some JS code) that is injected in the browser when you enable HMR. This runtime exposes a HMR (or hot) API. The hot API differs with each bundler, even if there is some level of standardization. For example, `rollup-plugin-hot`'s API looks like this:
|
||||
|
||||
```js
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.dispose(data => {
|
||||
// do cleanup
|
||||
})
|
||||
import.meta.hot.accept(() => {
|
||||
// adjust side effects
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Why do we need a hot API?
|
||||
|
||||
Because just replacing a whole chunk of JS code doesn't really gets you what you want. Let's think about it: what does replacing a JS module really means? You can't unrun the previously executed module. So that's merely running the new version of the module.
|
||||
|
||||
And that's about all what your HMR server will give you. But it's not enough. If your module was a helper function, new calls will go to the new version of the function, but the result of calling the previous version are still visible on the page. Same with a UI component: newly created components will be fresh, but existing components on the page are still from the previous versions...
|
||||
|
||||
That's why we need this hot API. We need to provide HMR handlers, that is HMR specific code to properly apply the effects of the code change in the app, and cleanup the effects of the previous module versions.
|
||||
|
||||
Actually, what should be done to reflect a code update is hyper specific to the content of the module. Typically, you'd need specific HMR handlers for each one of your modules (i.e. files). For most kind of contents, this cannot be automatized. Oh, and did I tell you that HMR handlers are pretty tedious things to write?
|
||||
|
||||
Oops. Does this makes HMR essentially worthless? No! Because, fortunately, there is one kind of content for which we know how to do automatic HMR handlers. Those are UI components. When a HMR update hits a component, we can destroy all existing instances of the component and replace them with new instances created with the updated version of the component. Bim. Well, there's also a part of dark magic involved because we need to recreate the new instances in the same state as the previous instance we're destroying. We need to pass the right props, transfer inner state, local state, event listeners, etc.
|
||||
|
||||
This kind of automatic HMR handlers for Svelte components -- and associated dark magic -- is what `svelte-hmr` provides! (For the sake of completeness, it also provides some Node utils to help bundlers apply the code transform needed to inject those HMR handlers into a Svelte component.)
|
||||
|
||||
Cool! So you can have HMR with a lot of your modules without having to write HMR handlers yourself, that's good news. And there are more. HMR APIs implements a _bubbling mechanism_. In HMR linguo, when a module has some HMR handlers, it is said to be "accepted". When a HMR update hits a module that is not accepted, this will not immediately translate into a full reload of the page. Instead, the HMR engine will check all the modules that imports the unaccepted module and, if they are all accepted, then it will refresh all those parent modules instead (refresh means running HMR handlers, here). If some of the parents are themselves unaccepted, the HMR update will continue to bubble up toward the app's entry point, stopping at accepted module on each branch. If an update hits the entry point (and the entry point itself is not accepted), then only will it command a full reload.
|
||||
|
||||
It makes sense: all those modules boast of being able to apply a code change to themselves so, if we refresh all of them, we should theoretically also see the updated effect of their dependencies, no? Well, unfortunately, it depends... If your updated module is exporting values or pure functions, it will work perfectly. If your module uses `setInterval` and there isn't a HMR handler to dispose that, the `setInterval` function will keep running (and each HMR update will probably add a new one). It all depends on how stateful or how much side effects your module has. But in many cases it can work and, in those cases, you'll also get HMR for free (since all HMR updates will probably be stopped by Svelte components). For the remaining cases... Well, you're probably left with [learning how to write HMR handlers](https://github.com/rixo/rollup-plugin-hot#api), or accept to manually reload the browser.
|
||||
|
||||
Here you are. This is what HMR is, and how it works.
|
||||
|
||||
I think the most important take away is that the component that is affected by a change will be recreated. Its state will be preserved but all its children will be recreated too, and their state not preserved. This is a necessity because the elements / child components structure of a component can be entirely different after the file has been modified (and we don't really have the technical capacity to track children).
|
||||
|
||||
Now, the best way to see what it can do for you is probably to checkout the template bellow and get your hands at it! (Add 500 components and try Nollup, you should love the speed!)
|
||||
|
||||
### Preservation of local state
|
||||
|
||||
**From version 0.12** this behaviour has been deemed too confusing and hard to anticipate, so preservation of state is now disabled by default, and some escape hatches to preserve the state of some given variables have been added.
|
||||
|
||||
Local state can be preserved by Svelte HMR, that is any state that Svelte itself tracks as reactive (basically any root scope `let` vars, exported or not).
|
||||
|
||||
This means that in code like this:
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
let x = 1
|
||||
x++ // x is now 2
|
||||
</script>
|
||||
|
||||
<p>{x}</p>
|
||||
```
|
||||
|
||||
If you replace `let x = 1` by `let x = 10` and save, the previous value of `x` will be preserved. That is, `x` will be 2 and not 10. The restoration of previous state happens _after_ the init code of the component has run, so the value will not be 11 either, despite the `x++` that is still here.
|
||||
|
||||
If you want this behaviour for all the state of all your components, you can enable it by setting the `preserveLocalState` option to `true`.
|
||||
|
||||
If you then want to disable it for just one particular file, or just temporarily, you can turn it off by adding a `// @hmr:reset` comment somewhere in your component.
|
||||
|
||||
On the contrary, if you keep the default `preserveLocalState` to `false`, you can enable preservation of all the local state of a given component by adding the following comment: `// @hmr:keep-all`. You can also preserve only the state of some specific variables, by annotating them with: `// @hmr:keep`.
|
||||
|
||||
For example:
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
let x = 0 // @hmr:keep
|
||||
|
||||
// or:
|
||||
|
||||
// @hmr:keep
|
||||
let y = 1,
|
||||
z = 2
|
||||
</script>
|
||||
```
|
||||
|
||||
## Svelte HMR tools
|
||||
|
||||
### Vite
|
||||
|
||||
The [official Svelte plugin for Vite][vite-plugin-svelte] has HMR support.
|
||||
|
||||
### Webpack
|
||||
|
||||
The [official loader for Webpack][svelte-loader] now has HMR support.
|
||||
|
||||
### Rollup
|
||||
|
||||
Rollup does not natively support HMR, so we recommend using Vite. However, if you'd like to add HMR support to Rollup, the best way to get started is to refer to [svelte-template-hot], which demonstrates usage of both [rollup-plugin-hot] and [rollup-plugin-svelte-hot].
|
||||
|
||||
### Svelte Native
|
||||
|
||||
The official [Svelte Native template][svelte-native-template] already includes HMR support.
|
||||
|
||||
## License
|
||||
|
||||
[ISC](LICENSE)
|
||||
|
||||
[vite-plugin-svelte]: https://www.npmjs.com/package/@sveltejs/vite-plugin-svelte
|
||||
[svelte-loader]: https://github.com/sveltejs/svelte-loader
|
||||
[rollup-plugin-hot]: https://github.com/rixo/rollup-plugin-hot
|
||||
[rollup-plugin-svelte-hot]: https://github.com/rixo/rollup-plugin-svelte-hot
|
||||
[rollup-plugin-svelte]: https://github.com/rollup/rollup-plugin-svelte
|
||||
[svelte-template-hot]: https://github.com/rixo/svelte-template-hot
|
||||
[svelte-template]: https://github.com/sveltejs/template
|
||||
[svelte-native-template]: https://github.com/halfnelson/svelte-native-template
|
||||
[svelte-loader-hot]: https://github.com/rixo/svelte-loader-hot
|
||||
[svelte-template-webpack-hot]: https://github.com/rixo/svelte-template-webpack-hot
|
12
node_modules/svelte-hmr/index.js
generated
vendored
Normal file
12
node_modules/svelte-hmr/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
const createMakeHotFactory = require('./lib/make-hot.js')
|
||||
const { resolve } = require('path')
|
||||
const { name, version } = require('./package.json')
|
||||
|
||||
const resolveAbsoluteImport = target => resolve(__dirname, target)
|
||||
|
||||
const createMakeHot = createMakeHotFactory({
|
||||
pkg: { name, version },
|
||||
resolveAbsoluteImport,
|
||||
})
|
||||
|
||||
module.exports = { createMakeHot }
|
18
node_modules/svelte-hmr/lib/css-only.js
generated
vendored
Normal file
18
node_modules/svelte-hmr/lib/css-only.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Injects a `{}*` CSS rule to force Svelte compiler to scope every elements.
|
||||
*/
|
||||
export const injectScopeEverythingCssRule = (parse, code) => {
|
||||
const { css } = parse(code)
|
||||
if (!css) return code
|
||||
const {
|
||||
content: { end },
|
||||
} = css
|
||||
return code.slice(0, end) + '*{}' + code.slice(end)
|
||||
}
|
||||
|
||||
export const normalizeJsCode = code => {
|
||||
// Svelte now adds locations in dev mode, code locations can change when
|
||||
// CSS change, but we're unaffected (not real behaviour changes)
|
||||
code = code.replace(/\badd_location\s*\([^)]*\)\s*;?/g, '')
|
||||
return code
|
||||
}
|
499
node_modules/svelte-hmr/lib/make-hot.js
generated
vendored
Normal file
499
node_modules/svelte-hmr/lib/make-hot.js
generated
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
const globalName = '___SVELTE_HMR_HOT_API'
|
||||
const globalAdapterName = '___SVELTE_HMR_HOT_API_PROXY_ADAPTER'
|
||||
|
||||
const defaultHotOptions = {
|
||||
// preserve all local state
|
||||
preserveLocalState: false,
|
||||
|
||||
// escape hatchs from preservation of local state
|
||||
//
|
||||
// disable preservation of state for this component
|
||||
noPreserveStateKey: ['@hmr:reset', '@!hmr'],
|
||||
// enable preservation of state for all variables in this component
|
||||
preserveAllLocalStateKey: '@hmr:keep-all',
|
||||
// enable preservation of state for a given variable (must be inline or
|
||||
// above the target variable or variables; can be repeated)
|
||||
preserveLocalStateKey: '@hmr:keep',
|
||||
|
||||
// don't reload on fatal error
|
||||
noReload: false,
|
||||
// try to recover after runtime errors during component init
|
||||
// defaults to false because some runtime errors are fatal and require a full reload
|
||||
optimistic: false,
|
||||
// auto accept modules of components that have named exports (i.e. exports
|
||||
// from context="module")
|
||||
acceptNamedExports: true,
|
||||
// auto accept modules of components have accessors (either accessors compile
|
||||
// option, or <svelte:option accessors={true} />) -- this means that if you
|
||||
// set accessors compile option globally, you must also set this option to
|
||||
// true, or no component will be hot reloaded (but there are a lot of edge
|
||||
// cases that HMR can't support correctly with accessors)
|
||||
acceptAccessors: true,
|
||||
// only inject CSS instead of recreating components when only CSS changes
|
||||
injectCss: false,
|
||||
// to mitigate FOUC between dispose (remove stylesheet) and accept
|
||||
cssEjectDelay: 100,
|
||||
|
||||
// Svelte Native mode
|
||||
native: false,
|
||||
// name of the adapter import binding
|
||||
importAdapterName: globalAdapterName,
|
||||
|
||||
// disable runtime error overlay
|
||||
noOverlay: false,
|
||||
|
||||
// set to true on systems that supports them, to avoid useless caught /
|
||||
// managed (but still...) exceptions, by using Svelte's current_component
|
||||
// instead of get_current_component
|
||||
allowLiveBinding: false,
|
||||
|
||||
// use acceptExports instead of accept, to fix support of context:module
|
||||
partialAccept: false,
|
||||
}
|
||||
|
||||
const defaultHotApi = 'hot-api-esm.js'
|
||||
|
||||
const json = JSON.stringify
|
||||
|
||||
const posixify = file => file.replace(/[/\\]/g, '/')
|
||||
|
||||
const renderApplyHmr = ({
|
||||
id,
|
||||
cssId,
|
||||
nonCssHash,
|
||||
hotOptions: {
|
||||
injectCss,
|
||||
partialAccept,
|
||||
_accept = partialAccept ? "acceptExports(['default'])" : 'accept()',
|
||||
},
|
||||
hotOptionsJson,
|
||||
hotApiImport,
|
||||
adapterImport,
|
||||
importAdapterName,
|
||||
meta,
|
||||
acceptable,
|
||||
preserveLocalState,
|
||||
emitCss,
|
||||
imports = [
|
||||
`import * as ${globalName} from ${JSON.stringify(hotApiImport)}`,
|
||||
`import { adapter as ${importAdapterName} } from ${JSON.stringify(
|
||||
adapterImport
|
||||
)}`,
|
||||
],
|
||||
}) =>
|
||||
// this silly formatting keeps all original characters in their position,
|
||||
// thus saving us from having to provide a sourcemap
|
||||
//
|
||||
// NOTE the `if (false) accept()` line is for tools that wants to see the
|
||||
// accept call in the actual accepted module to enable HMR (Vite and, I
|
||||
// believe, Snowpack 3)
|
||||
//
|
||||
`${imports.join(';')};${`
|
||||
if (${meta} && ${meta}.hot) {
|
||||
${acceptable ? `if (false) ${meta}.hot.${_accept};` : ''};
|
||||
$2 = ${globalName}.applyHmr({
|
||||
m: ${meta},
|
||||
id: ${json(id)},
|
||||
hotOptions: ${hotOptionsJson},
|
||||
Component: $2,
|
||||
ProxyAdapter: ${importAdapterName},
|
||||
acceptable: ${json(acceptable)},
|
||||
preserveLocalState: ${json(preserveLocalState)},
|
||||
${cssId ? `cssId: ${json(cssId)},` : ''}
|
||||
${nonCssHash ? `nonCssHash: ${json(nonCssHash)},` : ''}
|
||||
emitCss: ${json(emitCss)},
|
||||
});
|
||||
}
|
||||
`
|
||||
.split('\n')
|
||||
.map(x => x.trim())
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
export default $2;
|
||||
${
|
||||
// NOTE when doing CSS only voodoo, we have to inject the stylesheet as soon
|
||||
// as the component is loaded because Svelte normally do that when a component
|
||||
// is instantiated, but we might already have instances in the large when a
|
||||
// component is loaded with HMR
|
||||
cssId && injectCss && !emitCss
|
||||
? `
|
||||
if (typeof add_css !== 'undefined' && !document.getElementById(${json(
|
||||
cssId
|
||||
)})) add_css();`
|
||||
: ``
|
||||
}
|
||||
`
|
||||
|
||||
// replace from last occurrence of the splitter
|
||||
const replaceLast = (string, splitter, regex, replacer) => {
|
||||
const lastIndex = string.lastIndexOf(splitter)
|
||||
return (
|
||||
string.slice(0, lastIndex) +
|
||||
string.slice(lastIndex).replace(regex, replacer)
|
||||
)
|
||||
}
|
||||
|
||||
// https://github.com/darkskyapp/string-hash/blob/master/index.js
|
||||
// (via https://github.com/sveltejs/svelte/blob/91d758e35b2b2154512ddd11e6b6d9d65708a99e/src/compiler/compile/utils/hash.ts#L2)
|
||||
const stringHashcode = str => {
|
||||
let hash = 5381
|
||||
let i = str.length
|
||||
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i)
|
||||
return (hash >>> 0).toString(36)
|
||||
}
|
||||
|
||||
const normalizeJsCode = (code, cssHash) =>
|
||||
code
|
||||
// ignore css hashes in the code (that have changed, necessarily)
|
||||
.replace(new RegExp('\\b' + cssHash + '\\b', 'g'), '')
|
||||
// Svelte now adds locations in dev mode, code locations can change when
|
||||
// CSS change, but we're unaffected (not real behaviour changes)
|
||||
.replace(/\badd_location\s*\([^)]*\)\s*;?/g, '')
|
||||
|
||||
const parseCssId = (code, compileOptions = {}, parseHash, originalCode) => {
|
||||
// the regex matching is very pretty conservative 'cause I don't want to
|
||||
// match something else by error... I'm probably make it more lax if I have
|
||||
// to fix it 3 times in a single week ¯\_(ツ)_/¯
|
||||
let match = /^function add_css\(\) \{[\s\S]*?^}/m.exec(code)
|
||||
|
||||
if (!match) {
|
||||
// guard: injectCss is off, no need to compute hashes
|
||||
if (!parseHash) return {}
|
||||
// guard: compile.css is true, so we should have found the add_css function,
|
||||
// something unexpected is unraveling here, fall back to caution
|
||||
if (compileOptions.css) return {}
|
||||
// trying to get CSS id the same way as Svelte does it
|
||||
match = /<style[^>]*>([\s\S]*)<\/\s*style\s*>/.exec(originalCode)
|
||||
const cssHash = match && match[1] ? stringHashcode(match[1]) : null
|
||||
if (!cssHash) return {}
|
||||
return {
|
||||
cssId: `svelte-${cssHash}-style`,
|
||||
nonCssHash: stringHashcode(normalizeJsCode(code, cssHash)),
|
||||
}
|
||||
}
|
||||
|
||||
const codeExceptCSS =
|
||||
code.slice(0, match.index) + code.slice(match.index + match[0].length)
|
||||
|
||||
match = /\bstyle\.id\s*=\s*(['"])([^'"]*)\1/.exec(match[0])
|
||||
const cssId = match ? match[2] : null
|
||||
|
||||
if (!parseHash || !cssId) return { cssId }
|
||||
|
||||
const cssHash = cssId.split('-')[1]
|
||||
const nonCssHash = stringHashcode(normalizeJsCode(codeExceptCSS, cssHash))
|
||||
|
||||
return { cssId, nonCssHash }
|
||||
}
|
||||
|
||||
const isNamedExport = v => v.export_name && v.module
|
||||
|
||||
const isProp = v => v.export_name && !v.module
|
||||
|
||||
const resolvePackageImport = (name = 'svelte-hmr', version = '') => {
|
||||
const versionSpec = version ? '@' + version : ''
|
||||
return target => `${name}${versionSpec}/${target}`
|
||||
}
|
||||
|
||||
const createMakeHot = ({ resolveAbsoluteImport, pkg = {} }) => ({
|
||||
// NOTE hotOptions can be customized by end user through plugin options, while
|
||||
// options passed to this function can only customized by the plugin implementer
|
||||
//
|
||||
// meta can be 'import.meta' or 'module'
|
||||
// const createMakeHot = (hotApi = defaultHotApi, options) => {
|
||||
walk,
|
||||
meta = 'import.meta',
|
||||
|
||||
hotApi: customHotApi = '',
|
||||
adapter: customAdapter = '',
|
||||
// use absolute file paths to import runtime deps of svelte-hmr
|
||||
// - pnpm needs absolute paths because svelte-hmr, being a transitive dep via
|
||||
// the bundler plugin, is not directly importable from user's project
|
||||
// (see https://github.com/rixo/svelte-hmr/issues/11)
|
||||
// - Snowpack source=remote needs a version number, otherwise it will try to
|
||||
// load import, resulting in a possible version mismatch between the code
|
||||
// transform and the runtime
|
||||
// (see: https://github.com/rixo/svelte-hmr/issues/27#issuecomment-800142127)
|
||||
absoluteImports = true,
|
||||
versionNonAbsoluteImports = true,
|
||||
|
||||
hotOptions: hotOptionsArg = {},
|
||||
}) => {
|
||||
const hotOptions = { ...defaultHotOptions, ...hotOptionsArg }
|
||||
|
||||
const hotOptionsJson = JSON.stringify(hotOptions)
|
||||
|
||||
// NOTE Native adapter cannot be required in code (as opposed to this
|
||||
// generated code) because it requires modules from NativeScript's code that
|
||||
// are not resolvable for non-native users (and those missing modules would
|
||||
// prevent webpack from building).
|
||||
//
|
||||
// careful with relative paths
|
||||
// (see https://github.com/rixo/svelte-hmr/issues/11)
|
||||
const defaultAdapter = hotOptions.native
|
||||
? 'svelte-native/proxy-adapter-native.js'
|
||||
: 'proxy-adapter-dom.js'
|
||||
|
||||
const resolveImport = absoluteImports
|
||||
? resolveAbsoluteImport
|
||||
: resolvePackageImport(pkg.name, versionNonAbsoluteImports && pkg.version)
|
||||
|
||||
const adapterImport = posixify(
|
||||
customAdapter || resolveImport('runtime/' + defaultAdapter)
|
||||
)
|
||||
|
||||
const hotApiImport = posixify(
|
||||
customHotApi || resolveImport('runtime/' + defaultHotApi)
|
||||
)
|
||||
|
||||
const resolvePreserveLocalStateKey = ({
|
||||
preserveLocalStateKey,
|
||||
compiled,
|
||||
}) => {
|
||||
const containsKey = comments =>
|
||||
comments &&
|
||||
comments.some(({ value }) => value.includes(preserveLocalStateKey))
|
||||
|
||||
const variables = new Set()
|
||||
|
||||
const addReference = node => {
|
||||
if (!node.name) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Incorrect identifier for preserveLocalStateKey')
|
||||
}
|
||||
variables.add(node.name)
|
||||
}
|
||||
|
||||
const processNodes = targets => targets.forEach(processNode)
|
||||
|
||||
const processNode = node => {
|
||||
switch (node.type) {
|
||||
case 'Identifier':
|
||||
variables.add(node.name)
|
||||
return true
|
||||
case 'UpdateExpression':
|
||||
addReference(node.argument)
|
||||
return true
|
||||
case 'VariableDeclarator':
|
||||
addReference(node.id)
|
||||
return true
|
||||
case 'AssignmentExpression':
|
||||
processNode(node.left)
|
||||
return true
|
||||
case 'ExpressionStatement':
|
||||
processNode(node.expression)
|
||||
return true
|
||||
|
||||
case 'VariableDeclaration':
|
||||
processNodes(node.declarations)
|
||||
return true
|
||||
case 'SequenceExpression': // ++, --
|
||||
processNodes(node.expressions)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const stack = []
|
||||
|
||||
if (compiled.ast.instance) {
|
||||
walk(compiled.ast.instance, {
|
||||
leave() {
|
||||
stack.shift()
|
||||
},
|
||||
enter(node) {
|
||||
stack.unshift(node)
|
||||
if (
|
||||
containsKey(node.leadingComments) ||
|
||||
containsKey(node.trailingComments)
|
||||
) {
|
||||
stack
|
||||
.slice(0, 3)
|
||||
.reverse()
|
||||
.some(processNode)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return [...variables]
|
||||
}
|
||||
|
||||
const resolvePreserveLocalState = ({
|
||||
hotOptions,
|
||||
originalCode,
|
||||
compiled,
|
||||
}) => {
|
||||
const {
|
||||
preserveLocalState,
|
||||
noPreserveStateKey,
|
||||
preserveLocalStateKey,
|
||||
preserveAllLocalStateKey,
|
||||
} = hotOptions
|
||||
if (originalCode) {
|
||||
const hasKey = key => {
|
||||
const test = k => originalCode.indexOf(k) !== -1
|
||||
return Array.isArray(key) ? key.some(test) : test(key)
|
||||
}
|
||||
// noPreserveStateKey
|
||||
if (noPreserveStateKey && hasKey(noPreserveStateKey)) {
|
||||
return false
|
||||
}
|
||||
// preserveAllLocalStateKey
|
||||
if (preserveAllLocalStateKey && hasKey(preserveAllLocalStateKey)) {
|
||||
return true
|
||||
}
|
||||
// preserveLocalStateKey
|
||||
if (preserveLocalStateKey && hasKey(preserveLocalStateKey)) {
|
||||
// returns an array of variable names to preserve
|
||||
return resolvePreserveLocalStateKey({ preserveLocalStateKey, compiled })
|
||||
}
|
||||
}
|
||||
// preserveLocalState
|
||||
if (preserveLocalState) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const hasAccessorsOption = compiled => {
|
||||
if (!compiled.ast || !compiled.ast.html) return
|
||||
let accessors = false
|
||||
walk(compiled.ast.html, {
|
||||
enter(node) {
|
||||
if (accessors) return
|
||||
if (node.type !== 'Options') return
|
||||
if (!node.attributes) return
|
||||
accessors = node.attributes.some(
|
||||
({ name, value }) => name === 'accessors' && value
|
||||
)
|
||||
},
|
||||
})
|
||||
return accessors
|
||||
}
|
||||
|
||||
const isAcceptable = (hotOptions, compileOptions, compiled) => {
|
||||
if (!compiled || !compileOptions) {
|
||||
// this should never happen, since it's the bundler plugins that control
|
||||
// what version of svelte-hmr they embark, and they should be kept up to
|
||||
// date with our API
|
||||
//
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
'WARNING Your bundler plugin is outdated for this version of svelte-hmr'
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
const { vars } = compiled
|
||||
|
||||
// if the module has named exports (in context="module"), then we can't
|
||||
// auto accept the component, since all the consumers need to be aware of
|
||||
// the change (e.g. rerender with the new exports value)
|
||||
if (!hotOptions.acceptNamedExports && vars.some(isNamedExport)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// ...same for accessors: if accessible props change, then we need to
|
||||
// rerender/rerun all the consumers to reflect the change
|
||||
//
|
||||
// NOTE we can still accept components with no props, since they won't
|
||||
// have accessors... this is actually all we can safely accept in this case
|
||||
//
|
||||
if (
|
||||
!hotOptions.acceptAccessors &&
|
||||
// we test is we have props first, because searching for the
|
||||
// <svelte:options /> tag in the AST is probably the most expensive here
|
||||
vars.some(isProp) &&
|
||||
(compileOptions.accessors || hasAccessorsOption(compiled))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const parseMakeHotArgs = args => {
|
||||
// case: named args (object)
|
||||
if (args.length === 1) return args[0]
|
||||
// case: legacy (positional)
|
||||
const [
|
||||
id,
|
||||
compiledCode,
|
||||
hotOptions,
|
||||
compiled,
|
||||
originalCode,
|
||||
compileOptions,
|
||||
] = args
|
||||
return {
|
||||
id,
|
||||
compiledCode,
|
||||
hotOptions,
|
||||
compiled,
|
||||
originalCode,
|
||||
compileOptions,
|
||||
}
|
||||
}
|
||||
|
||||
function makeHot(...args) {
|
||||
const {
|
||||
id,
|
||||
compiledCode,
|
||||
compiled,
|
||||
originalCode,
|
||||
compileOptions,
|
||||
} = parseMakeHotArgs(args)
|
||||
|
||||
const { importAdapterName, injectCss } = hotOptions
|
||||
|
||||
const emitCss =
|
||||
compileOptions &&
|
||||
(compileOptions.css === false || compileOptions.css === 'external')
|
||||
|
||||
const preserveLocalState = resolvePreserveLocalState({
|
||||
hotOptions,
|
||||
originalCode,
|
||||
compiled,
|
||||
})
|
||||
|
||||
const replacement = renderApplyHmr({
|
||||
id,
|
||||
// adds cssId & nonCssHash
|
||||
...((injectCss || !emitCss) &&
|
||||
parseCssId(compiledCode, compileOptions, injectCss, originalCode)),
|
||||
hotOptions,
|
||||
hotOptionsJson,
|
||||
preserveLocalState,
|
||||
hotApiImport,
|
||||
adapterImport,
|
||||
importAdapterName,
|
||||
meta,
|
||||
acceptable: isAcceptable(hotOptions, compileOptions, compiled),
|
||||
// CSS is handled outside of Svelte: don't tamper with it!
|
||||
emitCss,
|
||||
})
|
||||
|
||||
// NOTE export default can appear in strings in use code
|
||||
// see: https://github.com/rixo/svelte-hmr/issues/34
|
||||
return replaceLast(
|
||||
compiledCode,
|
||||
'export default',
|
||||
/(\n?export default ([^;]*);)/,
|
||||
(match, $1, $2) => replacement.replace(/\$2/g, () => $2)
|
||||
)
|
||||
}
|
||||
|
||||
// rollup-plugin-svelte-hot needs hotApi path (for tests)
|
||||
// makeHot.hotApi = hotApi
|
||||
Object.defineProperty(makeHot, 'hotApi', {
|
||||
get() {
|
||||
// TODO makeHot.hotApi has been lost in 0.12 => 0.13... still needed?
|
||||
debugger // eslint-disable-line no-debugger
|
||||
return undefined
|
||||
},
|
||||
})
|
||||
|
||||
return makeHot
|
||||
}
|
||||
|
||||
module.exports = createMakeHot
|
44
node_modules/svelte-hmr/package.json
generated
vendored
Normal file
44
node_modules/svelte-hmr/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "svelte-hmr",
|
||||
"version": "0.16.0",
|
||||
"description": "Bundler agnostic HMR utils for Svelte 3",
|
||||
"main": "index.js",
|
||||
"author": "rixo <rixo@rixo.fr>",
|
||||
"license": "ISC",
|
||||
"homepage": "https://github.com/sveltejs/svelte-hmr",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sveltejs/svelte-hmr/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sveltejs/svelte-hmr",
|
||||
"directory": "packages/svelte-hmr"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib",
|
||||
"runtime"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^12.20 || ^14.13.1 || >= 16"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^3.19.0 || ^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^10.0.0",
|
||||
"prettier": "^1.19.1",
|
||||
"svelte": "^3.59.2",
|
||||
"tap-mocha-reporter": "^5.0.3",
|
||||
"zoar": "^0.3.0",
|
||||
"zorax": "^0.0.14"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint '**/*.{js,cjs,mjs}'",
|
||||
"lint:fix": "pnpm run lint --fix",
|
||||
"format": "prettier '**/*.{js,cjs,mjs}' --check",
|
||||
"format:fix": "pnpm run format --write",
|
||||
"test:fancy": "zoar --pipe 'tap-mocha-reporter spec'",
|
||||
"test": "zoar --exit"
|
||||
}
|
||||
}
|
7
node_modules/svelte-hmr/runtime/hot-api-esm.js
generated
vendored
Normal file
7
node_modules/svelte-hmr/runtime/hot-api-esm.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { makeApplyHmr } from '../runtime/index.js'
|
||||
|
||||
export const applyHmr = makeApplyHmr(args =>
|
||||
Object.assign({}, args, {
|
||||
hot: args.m.hot,
|
||||
})
|
||||
)
|
172
node_modules/svelte-hmr/runtime/hot-api.js
generated
vendored
Normal file
172
node_modules/svelte-hmr/runtime/hot-api.js
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
import { createProxy, hasFatalError } from './proxy.js'
|
||||
|
||||
const logPrefix = '[HMR:Svelte]'
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = (...args) => console.log(logPrefix, ...args)
|
||||
|
||||
const domReload = () => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const win = typeof window !== 'undefined' && window
|
||||
if (win && win.location && win.location.reload) {
|
||||
log('Reload')
|
||||
win.location.reload()
|
||||
} else {
|
||||
log('Full reload required')
|
||||
}
|
||||
}
|
||||
|
||||
const replaceCss = (previousId, newId) => {
|
||||
if (typeof document === 'undefined') return false
|
||||
if (!previousId) return false
|
||||
if (!newId) return false
|
||||
// svelte-xxx-style => svelte-xxx
|
||||
const previousClass = previousId.slice(0, -6)
|
||||
const newClass = newId.slice(0, -6)
|
||||
// eslint-disable-next-line no-undef
|
||||
document.querySelectorAll('.' + previousClass).forEach(el => {
|
||||
el.classList.remove(previousClass)
|
||||
el.classList.add(newClass)
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
const removeStylesheet = cssId => {
|
||||
if (cssId == null) return
|
||||
if (typeof document === 'undefined') return
|
||||
// eslint-disable-next-line no-undef
|
||||
const el = document.getElementById(cssId)
|
||||
if (el) el.remove()
|
||||
return
|
||||
}
|
||||
|
||||
const defaultArgs = {
|
||||
reload: domReload,
|
||||
}
|
||||
|
||||
export const makeApplyHmr = transformArgs => args => {
|
||||
const allArgs = transformArgs({ ...defaultArgs, ...args })
|
||||
return applyHmr(allArgs)
|
||||
}
|
||||
|
||||
let needsReload = false
|
||||
|
||||
function applyHmr(args) {
|
||||
const {
|
||||
id,
|
||||
cssId,
|
||||
nonCssHash,
|
||||
reload = domReload,
|
||||
// normalized hot API (must conform to rollup-plugin-hot)
|
||||
hot,
|
||||
hotOptions,
|
||||
Component,
|
||||
acceptable, // some types of components are impossible to HMR correctly
|
||||
preserveLocalState,
|
||||
ProxyAdapter,
|
||||
emitCss,
|
||||
} = args
|
||||
|
||||
const existing = hot.data && hot.data.record
|
||||
|
||||
const canAccept = acceptable && (!existing || existing.current.canAccept)
|
||||
|
||||
const r =
|
||||
existing ||
|
||||
createProxy({
|
||||
Adapter: ProxyAdapter,
|
||||
id,
|
||||
Component,
|
||||
hotOptions,
|
||||
canAccept,
|
||||
preserveLocalState,
|
||||
})
|
||||
|
||||
const cssOnly =
|
||||
hotOptions.injectCss &&
|
||||
existing &&
|
||||
nonCssHash &&
|
||||
existing.current.nonCssHash === nonCssHash
|
||||
|
||||
r.update({
|
||||
Component,
|
||||
hotOptions,
|
||||
canAccept,
|
||||
nonCssHash,
|
||||
cssId,
|
||||
previousCssId: r.current.cssId,
|
||||
cssOnly,
|
||||
preserveLocalState,
|
||||
})
|
||||
|
||||
hot.dispose(data => {
|
||||
// handle previous fatal errors
|
||||
if (needsReload || hasFatalError()) {
|
||||
if (hotOptions && hotOptions.noReload) {
|
||||
log('Full reload required')
|
||||
} else {
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
||||
// 2020-09-21 Snowpack master doesn't pass data as arg to dispose handler
|
||||
data = data || hot.data
|
||||
|
||||
data.record = r
|
||||
|
||||
if (!emitCss && cssId && r.current.cssId !== cssId) {
|
||||
if (hotOptions.cssEjectDelay) {
|
||||
setTimeout(() => removeStylesheet(cssId), hotOptions.cssEjectDelay)
|
||||
} else {
|
||||
removeStylesheet(cssId)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (canAccept) {
|
||||
hot.accept(async arg => {
|
||||
const { bubbled } = arg || {}
|
||||
|
||||
// NOTE Snowpack registers accept handlers only once, so we can NOT rely
|
||||
// on the surrounding scope variables -- they're not the last version!
|
||||
const { cssId: newCssId, previousCssId } = r.current
|
||||
const cssChanged = newCssId !== previousCssId
|
||||
// ensure old style sheet has been removed by now
|
||||
if (!emitCss && cssChanged) removeStylesheet(previousCssId)
|
||||
// guard: css only change
|
||||
if (
|
||||
// NOTE bubbled is provided only by rollup-plugin-hot, and we
|
||||
// can't safely assume a CSS only change without it... this means we
|
||||
// can't support CSS only injection with Nollup or Webpack currently
|
||||
bubbled === false && // WARNING check false, not falsy!
|
||||
r.current.cssOnly &&
|
||||
(!cssChanged || replaceCss(previousCssId, newCssId))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const success = await r.reload()
|
||||
|
||||
if (hasFatalError() || (!success && !hotOptions.optimistic)) {
|
||||
needsReload = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// well, endgame... we won't be able to render next updates, even successful,
|
||||
// if we don't have proxies in svelte's tree
|
||||
//
|
||||
// since we won't return the proxy and the app will expect a svelte component,
|
||||
// it's gonna crash... so it's best to report the real cause
|
||||
//
|
||||
// full reload required
|
||||
//
|
||||
const proxyOk = r && r.proxy
|
||||
if (!proxyOk) {
|
||||
throw new Error(`Failed to create HMR proxy for Svelte component ${id}`)
|
||||
}
|
||||
|
||||
return r.proxy
|
||||
}
|
1
node_modules/svelte-hmr/runtime/index.js
generated
vendored
Normal file
1
node_modules/svelte-hmr/runtime/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { makeApplyHmr } from './hot-api.js'
|
133
node_modules/svelte-hmr/runtime/overlay.js
generated
vendored
Normal file
133
node_modules/svelte-hmr/runtime/overlay.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
const removeElement = el => el && el.parentNode && el.parentNode.removeChild(el)
|
||||
|
||||
const ErrorOverlay = () => {
|
||||
let errors = []
|
||||
let compileError = null
|
||||
|
||||
const errorsTitle = 'Failed to init component'
|
||||
const compileErrorTitle = 'Failed to compile'
|
||||
|
||||
const style = {
|
||||
section: `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 32px;
|
||||
background: rgba(0, 0, 0, .85);
|
||||
font-family: Menlo, Consolas, monospace;
|
||||
font-size: large;
|
||||
color: rgb(232, 232, 232);
|
||||
overflow: auto;
|
||||
z-index: 2147483647;
|
||||
`,
|
||||
h1: `
|
||||
margin-top: 0;
|
||||
color: #E36049;
|
||||
font-size: large;
|
||||
font-weight: normal;
|
||||
`,
|
||||
h2: `
|
||||
margin: 32px 0 0;
|
||||
font-size: large;
|
||||
font-weight: normal;
|
||||
`,
|
||||
pre: ``,
|
||||
}
|
||||
|
||||
const createOverlay = () => {
|
||||
const h1 = document.createElement('h1')
|
||||
h1.style = style.h1
|
||||
const section = document.createElement('section')
|
||||
section.appendChild(h1)
|
||||
section.style = style.section
|
||||
const body = document.createElement('div')
|
||||
section.appendChild(body)
|
||||
return { h1, el: section, body }
|
||||
}
|
||||
|
||||
const setTitle = title => {
|
||||
overlay.h1.textContent = title
|
||||
}
|
||||
|
||||
const show = () => {
|
||||
const { el } = overlay
|
||||
if (!el.parentNode) {
|
||||
const target = document.body
|
||||
target.appendChild(overlay.el)
|
||||
}
|
||||
}
|
||||
|
||||
const hide = () => {
|
||||
const { el } = overlay
|
||||
if (el.parentNode) {
|
||||
overlay.el.remove()
|
||||
}
|
||||
}
|
||||
|
||||
const update = () => {
|
||||
if (compileError) {
|
||||
overlay.body.innerHTML = ''
|
||||
setTitle(compileErrorTitle)
|
||||
const errorEl = renderError(compileError)
|
||||
overlay.body.appendChild(errorEl)
|
||||
show()
|
||||
} else if (errors.length > 0) {
|
||||
overlay.body.innerHTML = ''
|
||||
setTitle(errorsTitle)
|
||||
errors.forEach(({ title, message }) => {
|
||||
const errorEl = renderError(message, title)
|
||||
overlay.body.appendChild(errorEl)
|
||||
})
|
||||
show()
|
||||
} else {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
|
||||
const renderError = (message, title) => {
|
||||
const div = document.createElement('div')
|
||||
if (title) {
|
||||
const h2 = document.createElement('h2')
|
||||
h2.textContent = title
|
||||
h2.style = style.h2
|
||||
div.appendChild(h2)
|
||||
}
|
||||
const pre = document.createElement('pre')
|
||||
pre.textContent = message
|
||||
div.appendChild(pre)
|
||||
return div
|
||||
}
|
||||
|
||||
const addError = (error, title) => {
|
||||
const message = (error && error.stack) || error
|
||||
errors.push({ title, message })
|
||||
update()
|
||||
}
|
||||
|
||||
const clearErrors = () => {
|
||||
errors.forEach(({ element }) => {
|
||||
removeElement(element)
|
||||
})
|
||||
errors = []
|
||||
update()
|
||||
}
|
||||
|
||||
const setCompileError = message => {
|
||||
compileError = message
|
||||
update()
|
||||
}
|
||||
|
||||
const overlay = createOverlay()
|
||||
|
||||
return {
|
||||
addError,
|
||||
clearErrors,
|
||||
setCompileError,
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorOverlay
|
105
node_modules/svelte-hmr/runtime/proxy-adapter-dom.js
generated
vendored
Normal file
105
node_modules/svelte-hmr/runtime/proxy-adapter-dom.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/* global window, document */
|
||||
import * as svelteInternal from 'svelte/internal'
|
||||
// NOTE from 3.38.3 (or so), insert was carrying the hydration logic, that must
|
||||
// be used because DOM elements are reused more (and so insertion points are not
|
||||
// necessarily added in order); then in 3.40 the logic was moved to
|
||||
// insert_hydration, which is the one we must use for HMR
|
||||
const svelteInsert = svelteInternal.insert_hydration || svelteInternal.insert
|
||||
if (!svelteInsert) {
|
||||
throw new Error(
|
||||
'failed to find insert_hydration and insert in svelte/internal'
|
||||
)
|
||||
}
|
||||
|
||||
import ErrorOverlay from './overlay.js'
|
||||
|
||||
const removeElement = el => el && el.parentNode && el.parentNode.removeChild(el)
|
||||
|
||||
export const adapter = class ProxyAdapterDom {
|
||||
constructor(instance) {
|
||||
this.instance = instance
|
||||
this.insertionPoint = null
|
||||
|
||||
this.afterMount = this.afterMount.bind(this)
|
||||
this.rerender = this.rerender.bind(this)
|
||||
|
||||
this._noOverlay = !!instance.hotOptions.noOverlay
|
||||
}
|
||||
|
||||
// NOTE overlay is only created before being actually shown to help test
|
||||
// runner (it won't have to account for error overlay when running assertions
|
||||
// about the contents of the rendered page)
|
||||
static getErrorOverlay(noCreate = false) {
|
||||
if (!noCreate && !this.errorOverlay) {
|
||||
this.errorOverlay = ErrorOverlay()
|
||||
}
|
||||
return this.errorOverlay
|
||||
}
|
||||
|
||||
// TODO this is probably unused now: remove in next breaking release
|
||||
static renderCompileError(message) {
|
||||
const noCreate = !message
|
||||
const overlay = this.getErrorOverlay(noCreate)
|
||||
if (!overlay) return
|
||||
overlay.setCompileError(message)
|
||||
}
|
||||
|
||||
dispose() {
|
||||
// Component is being destroyed, detaching is not optional in Svelte3's
|
||||
// component API, so we can dispose of the insertion point in every case.
|
||||
if (this.insertionPoint) {
|
||||
removeElement(this.insertionPoint)
|
||||
this.insertionPoint = null
|
||||
}
|
||||
this.clearError()
|
||||
}
|
||||
|
||||
// NOTE afterMount CAN be called multiple times (e.g. keyed list)
|
||||
afterMount(target, anchor) {
|
||||
const {
|
||||
instance: { debugName },
|
||||
} = this
|
||||
if (!this.insertionPoint) {
|
||||
this.insertionPoint = document.createComment(debugName)
|
||||
}
|
||||
svelteInsert(target, this.insertionPoint, anchor)
|
||||
}
|
||||
|
||||
rerender() {
|
||||
this.clearError()
|
||||
const {
|
||||
instance: { refreshComponent },
|
||||
insertionPoint,
|
||||
} = this
|
||||
if (!insertionPoint) {
|
||||
throw new Error('Cannot rerender: missing insertion point')
|
||||
}
|
||||
refreshComponent(insertionPoint.parentNode, insertionPoint)
|
||||
}
|
||||
|
||||
renderError(err) {
|
||||
if (this._noOverlay) return
|
||||
const {
|
||||
instance: { debugName },
|
||||
} = this
|
||||
const title = debugName || err.moduleName || 'Error'
|
||||
this.constructor.getErrorOverlay().addError(err, title)
|
||||
}
|
||||
|
||||
clearError() {
|
||||
if (this._noOverlay) return
|
||||
const overlay = this.constructor.getErrorOverlay(true)
|
||||
if (!overlay) return
|
||||
overlay.clearErrors()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO this is probably unused now: remove in next breaking release
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__SVELTE_HMR_ADAPTER = adapter
|
||||
}
|
||||
|
||||
// mitigate situation with Snowpack remote source pulling latest of runtime,
|
||||
// but using previous version of the Node code transform in the plugin
|
||||
// see: https://github.com/rixo/svelte-hmr/issues/27
|
||||
export default adapter
|
427
node_modules/svelte-hmr/runtime/proxy.js
generated
vendored
Normal file
427
node_modules/svelte-hmr/runtime/proxy.js
generated
vendored
Normal file
@@ -0,0 +1,427 @@
|
||||
/* eslint-env browser */
|
||||
/**
|
||||
* The HMR proxy is a component-like object whose task is to sit in the
|
||||
* component tree in place of the proxied component, and rerender each
|
||||
* successive versions of said component.
|
||||
*/
|
||||
|
||||
import { createProxiedComponent } from './svelte-hooks.js'
|
||||
|
||||
const handledMethods = ['constructor', '$destroy']
|
||||
const forwardedMethods = ['$set', '$on']
|
||||
|
||||
const logError = (msg, err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('[HMR][Svelte]', msg)
|
||||
if (err) {
|
||||
// NOTE avoid too much wrapping around user errors
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
const posixify = file => file.replace(/[/\\]/g, '/')
|
||||
|
||||
const getBaseName = id =>
|
||||
id
|
||||
.split('/')
|
||||
.pop()
|
||||
.split('.')
|
||||
.slice(0, -1)
|
||||
.join('.')
|
||||
|
||||
const capitalize = str => str[0].toUpperCase() + str.slice(1)
|
||||
|
||||
const getFriendlyName = id => capitalize(getBaseName(posixify(id)))
|
||||
|
||||
const getDebugName = id => `<${getFriendlyName(id)}>`
|
||||
|
||||
const relayCalls = (getTarget, names, dest = {}) => {
|
||||
for (const key of names) {
|
||||
dest[key] = function(...args) {
|
||||
const target = getTarget()
|
||||
if (!target) {
|
||||
return
|
||||
}
|
||||
return target[key] && target[key].call(this, ...args)
|
||||
}
|
||||
}
|
||||
return dest
|
||||
}
|
||||
|
||||
const isInternal = key => key !== '$$' && key.slice(0, 2) === '$$'
|
||||
|
||||
// This is intented as a somewhat generic / prospective fix to the situation
|
||||
// that arised with the introduction of $$set in Svelte 3.24.1 -- trying to
|
||||
// avoid giving full knowledge (like its name) of this implementation detail
|
||||
// to the proxy. The $$set method can be present or not on the component, and
|
||||
// its presence impacts the behaviour (but with HMR it will be tested if it is
|
||||
// present _on the proxy_). So the idea here is to expose exactly the same $$
|
||||
// props as the current version of the component and, for those that are
|
||||
// functions, proxy the calls to the current component.
|
||||
const relayInternalMethods = (proxy, cmp) => {
|
||||
// delete any previously added $$ prop
|
||||
Object.keys(proxy)
|
||||
.filter(isInternal)
|
||||
.forEach(key => {
|
||||
delete proxy[key]
|
||||
})
|
||||
// guard: no component
|
||||
if (!cmp) return
|
||||
// proxy current $$ props to the actual component
|
||||
Object.keys(cmp)
|
||||
.filter(isInternal)
|
||||
.forEach(key => {
|
||||
Object.defineProperty(proxy, key, {
|
||||
configurable: true,
|
||||
get() {
|
||||
const value = cmp[key]
|
||||
if (typeof value !== 'function') return value
|
||||
return (
|
||||
value &&
|
||||
function(...args) {
|
||||
return value.apply(this, args)
|
||||
}
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// proxy custom methods
|
||||
const copyComponentProperties = (proxy, cmp, previous) => {
|
||||
if (previous) {
|
||||
previous.forEach(prop => {
|
||||
delete proxy[prop]
|
||||
})
|
||||
}
|
||||
|
||||
const props = Object.getOwnPropertyNames(Object.getPrototypeOf(cmp))
|
||||
const wrappedProps = props.filter(prop => {
|
||||
if (!handledMethods.includes(prop) && !forwardedMethods.includes(prop)) {
|
||||
Object.defineProperty(proxy, prop, {
|
||||
configurable: true,
|
||||
get() {
|
||||
return cmp[prop]
|
||||
},
|
||||
set(value) {
|
||||
// we're changing it on the real component first to see what it
|
||||
// gives... if it throws an error, we want to throw the same error in
|
||||
// order to most closely follow non-hmr behaviour.
|
||||
cmp[prop] = value
|
||||
},
|
||||
})
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
return wrappedProps
|
||||
}
|
||||
|
||||
// everything in the constructor!
|
||||
//
|
||||
// so we don't polute the component class with new members
|
||||
//
|
||||
class ProxyComponent {
|
||||
constructor(
|
||||
{
|
||||
Adapter,
|
||||
id,
|
||||
debugName,
|
||||
current, // { Component, hotOptions: { preserveLocalState, ... } }
|
||||
register,
|
||||
},
|
||||
options // { target, anchor, ... }
|
||||
) {
|
||||
let cmp
|
||||
let disposed = false
|
||||
let lastError = null
|
||||
|
||||
const setComponent = _cmp => {
|
||||
cmp = _cmp
|
||||
relayInternalMethods(this, cmp)
|
||||
}
|
||||
|
||||
const getComponent = () => cmp
|
||||
|
||||
const destroyComponent = () => {
|
||||
// destroyComponent is tolerant (don't crash on no cmp) because it
|
||||
// is possible that reload/rerender is called after a previous
|
||||
// createComponent has failed (hence we have a proxy, but no cmp)
|
||||
if (cmp) {
|
||||
cmp.$destroy()
|
||||
setComponent(null)
|
||||
}
|
||||
}
|
||||
|
||||
const refreshComponent = (target, anchor, conservativeDestroy) => {
|
||||
if (lastError) {
|
||||
lastError = null
|
||||
adapter.rerender()
|
||||
} else {
|
||||
try {
|
||||
const replaceOptions = {
|
||||
target,
|
||||
anchor,
|
||||
preserveLocalState: current.preserveLocalState,
|
||||
}
|
||||
if (conservativeDestroy) {
|
||||
replaceOptions.conservativeDestroy = true
|
||||
}
|
||||
cmp.$replace(current.Component, replaceOptions)
|
||||
} catch (err) {
|
||||
setError(err, target, anchor)
|
||||
if (
|
||||
!current.hotOptions.optimistic ||
|
||||
// non acceptable components (that is components that have to defer
|
||||
// to their parent for rerender -- e.g. accessors, named exports)
|
||||
// are most tricky, and they havent been considered when most of the
|
||||
// code has been written... as a result, they are especially tricky
|
||||
// to deal with, it's better to consider any error with them to be
|
||||
// fatal to avoid odities
|
||||
!current.canAccept ||
|
||||
(err && err.hmrFatal)
|
||||
) {
|
||||
throw err
|
||||
} else {
|
||||
// const errString = String((err && err.stack) || err)
|
||||
logError(`Error during component init: ${debugName}`, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const setError = err => {
|
||||
lastError = err
|
||||
adapter.renderError(err)
|
||||
}
|
||||
|
||||
const instance = {
|
||||
hotOptions: current.hotOptions,
|
||||
proxy: this,
|
||||
id,
|
||||
debugName,
|
||||
refreshComponent,
|
||||
}
|
||||
|
||||
const adapter = new Adapter(instance)
|
||||
|
||||
const { afterMount, rerender } = adapter
|
||||
|
||||
// $destroy is not called when a child component is disposed, so we
|
||||
// need to hook from fragment.
|
||||
const onDestroy = () => {
|
||||
// NOTE do NOT call $destroy on the cmp from here; the cmp is already
|
||||
// dead, this would not work
|
||||
if (!disposed) {
|
||||
disposed = true
|
||||
adapter.dispose()
|
||||
unregister()
|
||||
}
|
||||
}
|
||||
|
||||
// ---- register proxy instance ----
|
||||
|
||||
const unregister = register(rerender)
|
||||
|
||||
// ---- augmented methods ----
|
||||
|
||||
this.$destroy = () => {
|
||||
destroyComponent()
|
||||
onDestroy()
|
||||
}
|
||||
|
||||
// ---- forwarded methods ----
|
||||
|
||||
relayCalls(getComponent, forwardedMethods, this)
|
||||
|
||||
// ---- create & mount target component instance ---
|
||||
|
||||
try {
|
||||
let lastProperties
|
||||
createProxiedComponent(current.Component, options, {
|
||||
allowLiveBinding: current.hotOptions.allowLiveBinding,
|
||||
onDestroy,
|
||||
onMount: afterMount,
|
||||
onInstance: comp => {
|
||||
setComponent(comp)
|
||||
// WARNING the proxy MUST use the same $$ object as its component
|
||||
// instance, because a lot of wiring happens during component
|
||||
// initialisation... lots of references to $$ and $$.fragment have
|
||||
// already been distributed around when the component constructor
|
||||
// returns, before we have a chance to wrap them (and so we can't
|
||||
// wrap them no more, because existing references would become
|
||||
// invalid)
|
||||
this.$$ = comp.$$
|
||||
lastProperties = copyComponentProperties(this, comp, lastProperties)
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
const { target, anchor } = options
|
||||
setError(err, target, anchor)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const syncStatics = (component, proxy, previousKeys) => {
|
||||
// remove previously copied keys
|
||||
if (previousKeys) {
|
||||
for (const key of previousKeys) {
|
||||
delete proxy[key]
|
||||
}
|
||||
}
|
||||
|
||||
// forward static properties and methods
|
||||
const keys = []
|
||||
for (const key in component) {
|
||||
keys.push(key)
|
||||
proxy[key] = component[key]
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
const globalListeners = {}
|
||||
|
||||
const onGlobal = (event, fn) => {
|
||||
event = event.toLowerCase()
|
||||
if (!globalListeners[event]) globalListeners[event] = []
|
||||
globalListeners[event].push(fn)
|
||||
}
|
||||
|
||||
const fireGlobal = (event, ...args) => {
|
||||
const listeners = globalListeners[event]
|
||||
if (!listeners) return
|
||||
for (const fn of listeners) {
|
||||
fn(...args)
|
||||
}
|
||||
}
|
||||
|
||||
const fireBeforeUpdate = () => fireGlobal('beforeupdate')
|
||||
|
||||
const fireAfterUpdate = () => fireGlobal('afterupdate')
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__SVELTE_HMR = {
|
||||
on: onGlobal,
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent('svelte-hmr:ready'))
|
||||
}
|
||||
|
||||
let fatalError = false
|
||||
|
||||
export const hasFatalError = () => fatalError
|
||||
|
||||
/**
|
||||
* Creates a HMR proxy and its associated `reload` function that pushes a new
|
||||
* version to all existing instances of the component.
|
||||
*/
|
||||
export function createProxy({
|
||||
Adapter,
|
||||
id,
|
||||
Component,
|
||||
hotOptions,
|
||||
canAccept,
|
||||
preserveLocalState,
|
||||
}) {
|
||||
const debugName = getDebugName(id)
|
||||
const instances = []
|
||||
|
||||
// current object will be updated, proxy instances will keep a ref
|
||||
const current = {
|
||||
Component,
|
||||
hotOptions,
|
||||
canAccept,
|
||||
preserveLocalState,
|
||||
}
|
||||
|
||||
const name = `Proxy${debugName}`
|
||||
|
||||
// this trick gives the dynamic name Proxy<MyComponent> to the concrete
|
||||
// proxy class... unfortunately, this doesn't shows in dev tools, but
|
||||
// it stills allow to inspect cmp.constructor.name to confirm an instance
|
||||
// is a proxy
|
||||
const proxy = {
|
||||
[name]: class extends ProxyComponent {
|
||||
constructor(options) {
|
||||
try {
|
||||
super(
|
||||
{
|
||||
Adapter,
|
||||
id,
|
||||
debugName,
|
||||
current,
|
||||
register: rerender => {
|
||||
instances.push(rerender)
|
||||
const unregister = () => {
|
||||
const i = instances.indexOf(rerender)
|
||||
instances.splice(i, 1)
|
||||
}
|
||||
return unregister
|
||||
},
|
||||
},
|
||||
options
|
||||
)
|
||||
} catch (err) {
|
||||
// If we fail to create a proxy instance, any instance, that means
|
||||
// that we won't be able to fix this instance when it is updated.
|
||||
// Recovering to normal state will be impossible. HMR's dead.
|
||||
//
|
||||
// Fatal error will trigger a full reload on next update (reloading
|
||||
// right now is kinda pointless since buggy code still exists).
|
||||
//
|
||||
// NOTE Only report first error to avoid too much polution -- following
|
||||
// errors are probably caused by the first one, or they will show up
|
||||
// in turn when the first one is fixed ¯\_(ツ)_/¯
|
||||
//
|
||||
if (!fatalError) {
|
||||
fatalError = true
|
||||
logError(
|
||||
`Unrecoverable HMR error in ${debugName}: ` +
|
||||
`next update will trigger a full reload`
|
||||
)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
},
|
||||
}[name]
|
||||
|
||||
// initialize static members
|
||||
let previousStatics = syncStatics(current.Component, proxy)
|
||||
|
||||
const update = newState => Object.assign(current, newState)
|
||||
|
||||
// reload all existing instances of this component
|
||||
const reload = () => {
|
||||
fireBeforeUpdate()
|
||||
|
||||
// copy statics before doing anything because a static prop/method
|
||||
// could be used somewhere in the create/render call
|
||||
previousStatics = syncStatics(current.Component, proxy, previousStatics)
|
||||
|
||||
const errors = []
|
||||
|
||||
instances.forEach(rerender => {
|
||||
try {
|
||||
rerender()
|
||||
} catch (err) {
|
||||
logError(`Failed to rerender ${debugName}`, err)
|
||||
errors.push(err)
|
||||
}
|
||||
})
|
||||
|
||||
if (errors.length > 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
fireAfterUpdate()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const hasFatalError = () => fatalError
|
||||
|
||||
return { id, proxy, update, reload, hasFatalError, current }
|
||||
}
|
347
node_modules/svelte-hmr/runtime/svelte-hooks.js
generated
vendored
Normal file
347
node_modules/svelte-hmr/runtime/svelte-hooks.js
generated
vendored
Normal file
@@ -0,0 +1,347 @@
|
||||
/**
|
||||
* Emulates forthcoming HMR hooks in Svelte.
|
||||
*
|
||||
* All references to private component state ($$) are now isolated in this
|
||||
* module.
|
||||
*/
|
||||
import {
|
||||
current_component,
|
||||
get_current_component,
|
||||
set_current_component,
|
||||
} from 'svelte/internal'
|
||||
|
||||
const captureState = cmp => {
|
||||
// sanity check: propper behaviour here is to crash noisily so that
|
||||
// user knows that they're looking at something broken
|
||||
if (!cmp) {
|
||||
throw new Error('Missing component')
|
||||
}
|
||||
if (!cmp.$$) {
|
||||
throw new Error('Invalid component')
|
||||
}
|
||||
|
||||
const {
|
||||
$$: { callbacks, bound, ctx, props },
|
||||
} = cmp
|
||||
|
||||
const state = cmp.$capture_state()
|
||||
|
||||
// capturing current value of props (or we'll recreate the component with the
|
||||
// initial prop values, that may have changed -- and would not be reflected in
|
||||
// options.props)
|
||||
const hmr_props_values = {}
|
||||
Object.keys(cmp.$$.props).forEach(prop => {
|
||||
hmr_props_values[prop] = ctx[props[prop]]
|
||||
})
|
||||
|
||||
return {
|
||||
ctx,
|
||||
props,
|
||||
callbacks,
|
||||
bound,
|
||||
state,
|
||||
hmr_props_values,
|
||||
}
|
||||
}
|
||||
|
||||
// remapping all existing bindings (including hmr_future_foo ones) to the
|
||||
// new version's props indexes, and refresh them with the new value from
|
||||
// context
|
||||
const restoreBound = (cmp, restore) => {
|
||||
// reverse prop:ctxIndex in $$.props to ctxIndex:prop
|
||||
//
|
||||
// ctxIndex can be either a regular index in $$.ctx or a hmr_future_ prop
|
||||
//
|
||||
const propsByIndex = {}
|
||||
for (const [name, i] of Object.entries(restore.props)) {
|
||||
propsByIndex[i] = name
|
||||
}
|
||||
|
||||
// NOTE $$.bound cannot change in the HMR lifetime of a component, because
|
||||
// if bindings changes, that means the parent component has changed,
|
||||
// which means the child (current) component will be wholly recreated
|
||||
for (const [oldIndex, updateBinding] of Object.entries(restore.bound)) {
|
||||
// can be either regular prop, or future_hmr_ prop
|
||||
const propName = propsByIndex[oldIndex]
|
||||
|
||||
// this should never happen if remembering of future props is enabled...
|
||||
// in any case, there's nothing we can do about it if we have lost prop
|
||||
// name knowledge at this point
|
||||
if (propName == null) continue
|
||||
|
||||
// NOTE $$.props[propName] also propagates knowledge of a possible
|
||||
// future prop to the new $$.props (via $$.props being a Proxy)
|
||||
const newIndex = cmp.$$.props[propName]
|
||||
cmp.$$.bound[newIndex] = updateBinding
|
||||
|
||||
// NOTE if the prop doesn't exist or doesn't exist anymore in the new
|
||||
// version of the component, clearing the binding is the expected
|
||||
// behaviour (since that's what would happen in non HMR code)
|
||||
const newValue = cmp.$$.ctx[newIndex]
|
||||
updateBinding(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
// restoreState
|
||||
//
|
||||
// It is too late to restore context at this point because component instance
|
||||
// function has already been called (and so context has already been read).
|
||||
// Instead, we rely on setting current_component to the same value it has when
|
||||
// the component was first rendered -- which fix support for context, and is
|
||||
// also generally more respectful of normal operation.
|
||||
//
|
||||
const restoreState = (cmp, restore) => {
|
||||
if (!restore) return
|
||||
|
||||
if (restore.callbacks) {
|
||||
cmp.$$.callbacks = restore.callbacks
|
||||
}
|
||||
|
||||
if (restore.bound) {
|
||||
restoreBound(cmp, restore)
|
||||
}
|
||||
|
||||
// props, props.$$slots are restored at component creation (works
|
||||
// better -- well, at all actually)
|
||||
}
|
||||
|
||||
const get_current_component_safe = () => {
|
||||
// NOTE relying on dynamic bindings (current_component) makes us dependent on
|
||||
// bundler config (and apparently it does not work in demo-svelte-nollup)
|
||||
try {
|
||||
// unfortunately, unlike current_component, get_current_component() can
|
||||
// crash in the normal path (when there is really no parent)
|
||||
return get_current_component()
|
||||
} catch (err) {
|
||||
// ... so we need to consider that this error means that there is no parent
|
||||
//
|
||||
// that makes us tightly coupled to the error message but, at least, we
|
||||
// won't mute an unexpected error, which is quite a horrible thing to do
|
||||
if (err.message === 'Function called outside component initialization') {
|
||||
// who knows...
|
||||
return current_component
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const createProxiedComponent = (
|
||||
Component,
|
||||
initialOptions,
|
||||
{ allowLiveBinding, onInstance, onMount, onDestroy }
|
||||
) => {
|
||||
let cmp
|
||||
let options = initialOptions
|
||||
|
||||
const isCurrent = _cmp => cmp === _cmp
|
||||
|
||||
const assignOptions = (target, anchor, restore, preserveLocalState) => {
|
||||
const props = Object.assign({}, options.props)
|
||||
|
||||
// Filtering props to avoid "unexpected prop" warning
|
||||
// NOTE this is based on props present in initial options, but it should
|
||||
// always works, because props that are passed from the parent can't
|
||||
// change without a code change to the parent itself -- hence, the
|
||||
// child component will be fully recreated, and initial options should
|
||||
// always represent props that are currnetly passed by the parent
|
||||
if (options.props && restore.hmr_props_values) {
|
||||
for (const prop of Object.keys(options.props)) {
|
||||
if (restore.hmr_props_values.hasOwnProperty(prop)) {
|
||||
props[prop] = restore.hmr_props_values[prop]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (preserveLocalState && restore.state) {
|
||||
if (Array.isArray(preserveLocalState)) {
|
||||
// form ['a', 'b'] => preserve only 'a' and 'b'
|
||||
props.$$inject = {}
|
||||
for (const key of preserveLocalState) {
|
||||
props.$$inject[key] = restore.state[key]
|
||||
}
|
||||
} else {
|
||||
props.$$inject = restore.state
|
||||
}
|
||||
} else {
|
||||
delete props.$$inject
|
||||
}
|
||||
options = Object.assign({}, initialOptions, {
|
||||
target,
|
||||
anchor,
|
||||
props,
|
||||
hydrate: false,
|
||||
})
|
||||
}
|
||||
|
||||
// Preserving knowledge of "future props" -- very hackish version (maybe
|
||||
// there should be an option to opt out of this)
|
||||
//
|
||||
// The use case is bind:something where something doesn't exist yet in the
|
||||
// target component, but comes to exist later, after a HMR update.
|
||||
//
|
||||
// If Svelte can't map a prop in the current version of the component, it
|
||||
// will just completely discard it:
|
||||
// https://github.com/sveltejs/svelte/blob/1632bca34e4803d6b0e0b0abd652ab5968181860/src/runtime/internal/Component.ts#L46
|
||||
//
|
||||
const rememberFutureProps = cmp => {
|
||||
if (typeof Proxy === 'undefined') return
|
||||
|
||||
cmp.$$.props = new Proxy(cmp.$$.props, {
|
||||
get(target, name) {
|
||||
if (target[name] === undefined) {
|
||||
target[name] = 'hmr_future_' + name
|
||||
}
|
||||
return target[name]
|
||||
},
|
||||
set(target, name, value) {
|
||||
target[name] = value
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const instrument = targetCmp => {
|
||||
const createComponent = (Component, restore, previousCmp) => {
|
||||
set_current_component(parentComponent || previousCmp)
|
||||
const comp = new Component(options)
|
||||
// NOTE must be instrumented before restoreState, because restoring
|
||||
// bindings relies on hacked $$.props
|
||||
instrument(comp)
|
||||
restoreState(comp, restore)
|
||||
return comp
|
||||
}
|
||||
|
||||
rememberFutureProps(targetCmp)
|
||||
|
||||
targetCmp.$$.on_hmr = []
|
||||
|
||||
// `conservative: true` means we want to be sure that the new component has
|
||||
// actually been successfuly created before destroying the old instance.
|
||||
// This could be useful for preventing runtime errors in component init to
|
||||
// bring down the whole HMR. Unfortunately the implementation bellow is
|
||||
// broken (FIXME), but that remains an interesting target for when HMR hooks
|
||||
// will actually land in Svelte itself.
|
||||
//
|
||||
// The goal would be to render an error inplace in case of error, to avoid
|
||||
// losing the navigation stack (especially annoying in native, that is not
|
||||
// based on URL navigation, so we lose the current page on each error).
|
||||
//
|
||||
targetCmp.$replace = (
|
||||
Component,
|
||||
{
|
||||
target = options.target,
|
||||
anchor = options.anchor,
|
||||
preserveLocalState,
|
||||
conservative = false,
|
||||
}
|
||||
) => {
|
||||
const restore = captureState(targetCmp)
|
||||
assignOptions(
|
||||
target || options.target,
|
||||
anchor,
|
||||
restore,
|
||||
preserveLocalState
|
||||
)
|
||||
|
||||
const callbacks = cmp ? cmp.$$.on_hmr : []
|
||||
|
||||
const afterCallbacks = callbacks.map(fn => fn(cmp)).filter(Boolean)
|
||||
|
||||
const previous = cmp
|
||||
if (conservative) {
|
||||
try {
|
||||
const next = createComponent(Component, restore, previous)
|
||||
// prevents on_destroy from firing on non-final cmp instance
|
||||
cmp = null
|
||||
previous.$destroy()
|
||||
cmp = next
|
||||
} catch (err) {
|
||||
cmp = previous
|
||||
throw err
|
||||
}
|
||||
} else {
|
||||
// prevents on_destroy from firing on non-final cmp instance
|
||||
cmp = null
|
||||
if (previous) {
|
||||
// previous can be null if last constructor has crashed
|
||||
previous.$destroy()
|
||||
}
|
||||
cmp = createComponent(Component, restore, cmp)
|
||||
}
|
||||
|
||||
cmp.$$.hmr_cmp = cmp
|
||||
|
||||
for (const fn of afterCallbacks) {
|
||||
fn(cmp)
|
||||
}
|
||||
|
||||
cmp.$$.on_hmr = callbacks
|
||||
|
||||
return cmp
|
||||
}
|
||||
|
||||
// NOTE onMount must provide target & anchor (for us to be able to determinate
|
||||
// actual DOM insertion point)
|
||||
//
|
||||
// And also, to support keyed list, it needs to be called each time the
|
||||
// component is moved (same as $$.fragment.m)
|
||||
if (onMount) {
|
||||
const m = targetCmp.$$.fragment.m
|
||||
targetCmp.$$.fragment.m = (...args) => {
|
||||
const result = m(...args)
|
||||
onMount(...args)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE onDestroy must be called even if the call doesn't pass through the
|
||||
// component's $destroy method (that we can hook onto by ourselves, since
|
||||
// it's public API) -- this happens a lot in svelte's internals, that
|
||||
// manipulates cmp.$$.fragment directly, often binding to fragment.d,
|
||||
// for example
|
||||
if (onDestroy) {
|
||||
targetCmp.$$.on_destroy.push(() => {
|
||||
if (isCurrent(targetCmp)) {
|
||||
onDestroy()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (onInstance) {
|
||||
onInstance(targetCmp)
|
||||
}
|
||||
|
||||
// Svelte 3 creates and mount components from their constructor if
|
||||
// options.target is present.
|
||||
//
|
||||
// This means that at this point, the component's `fragment.c` and,
|
||||
// most notably, `fragment.m` will already have been called _from inside
|
||||
// createComponent_. That is: before we have a chance to hook on it.
|
||||
//
|
||||
// Proxy's constructor
|
||||
// -> createComponent
|
||||
// -> component constructor
|
||||
// -> component.$$.fragment.c(...) (or l, if hydrate:true)
|
||||
// -> component.$$.fragment.m(...)
|
||||
//
|
||||
// -> you are here <-
|
||||
//
|
||||
if (onMount) {
|
||||
const { target, anchor } = options
|
||||
if (target) {
|
||||
onMount(target, anchor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const parentComponent = allowLiveBinding
|
||||
? current_component
|
||||
: get_current_component_safe()
|
||||
|
||||
cmp = new Component(options)
|
||||
cmp.$$.hmr_cmp = cmp
|
||||
|
||||
instrument(cmp)
|
||||
|
||||
return cmp
|
||||
}
|
62
node_modules/svelte-hmr/runtime/svelte-native/patch-page-show-modal.js
generated
vendored
Normal file
62
node_modules/svelte-hmr/runtime/svelte-native/patch-page-show-modal.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
// This module monkey patches Page#showModal in order to be able to
|
||||
// access from the HMR proxy data passed to `showModal` in svelte-native.
|
||||
//
|
||||
// Data are stored in a opaque prop accessible with `getModalData`.
|
||||
//
|
||||
// It also switches the `closeCallback` option with a custom brewed one
|
||||
// in order to give the proxy control over when its own instance will be
|
||||
// destroyed.
|
||||
//
|
||||
// Obviously this method suffer from extreme coupling with the target code
|
||||
// in svelte-native. So it would be wise to recheck compatibility on SN
|
||||
// version upgrades.
|
||||
//
|
||||
// Relevant code is there (last checked version):
|
||||
//
|
||||
// https://github.com/halfnelson/svelte-native/blob/48fdc97d2eb4d3958cfcb4ff6cf5755a220829eb/src/dom/navigation.ts#L132
|
||||
//
|
||||
|
||||
// FIXME should we override ViewBase#showModal instead?
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { Page } from '@nativescript/core'
|
||||
|
||||
const prop =
|
||||
typeof Symbol !== 'undefined'
|
||||
? Symbol('hmr_svelte_native_modal')
|
||||
: '___HMR_SVELTE_NATIVE_MODAL___'
|
||||
|
||||
const sup = Page.prototype.showModal
|
||||
|
||||
let patched = false
|
||||
|
||||
export const patchShowModal = () => {
|
||||
// guard: already patched
|
||||
if (patched) return
|
||||
patched = true
|
||||
|
||||
Page.prototype.showModal = function(modalView, options) {
|
||||
const modalData = {
|
||||
originalOptions: options,
|
||||
closeCallback: options.closeCallback,
|
||||
}
|
||||
|
||||
modalView[prop] = modalData
|
||||
|
||||
// Proxies to a function that can be swapped on the fly by HMR proxy.
|
||||
//
|
||||
// The default is still to call the original closeCallback from svelte
|
||||
// navtive, which will destroy the modal view & component. This way, if
|
||||
// no HMR happens on the modal content, normal behaviour is preserved
|
||||
// without the proxy having any work to do.
|
||||
//
|
||||
const closeCallback = (...args) => {
|
||||
return modalData.closeCallback(...args)
|
||||
}
|
||||
|
||||
const tamperedOptions = Object.assign({}, options, { closeCallback })
|
||||
|
||||
return sup.call(this, modalView, tamperedOptions)
|
||||
}
|
||||
}
|
||||
|
||||
export const getModalData = modalView => modalView[prop]
|
249
node_modules/svelte-hmr/runtime/svelte-native/proxy-adapter-native.js
generated
vendored
Normal file
249
node_modules/svelte-hmr/runtime/svelte-native/proxy-adapter-native.js
generated
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
/* global document */
|
||||
|
||||
import { adapter as ProxyAdapterDom } from '../proxy-adapter-dom'
|
||||
|
||||
import { patchShowModal, getModalData } from './patch-page-show-modal'
|
||||
|
||||
patchShowModal()
|
||||
|
||||
// Svelte Native support
|
||||
// =====================
|
||||
//
|
||||
// Rerendering Svelte Native page proves challenging...
|
||||
//
|
||||
// In NativeScript, pages are the top level component. They are normally
|
||||
// introduced into NativeScript's runtime by its `navigate` function. This
|
||||
// is how Svelte Natives handles it: it renders the Page component to a
|
||||
// dummy fragment, and "navigate" to the page element thus created.
|
||||
//
|
||||
// As long as modifications only impact child components of the page, then
|
||||
// we can keep the existing page and replace its content for HMR.
|
||||
//
|
||||
// However, if the page component itself is modified (including its system
|
||||
// title bar), things get hairy...
|
||||
//
|
||||
// Apparently, the sole way of introducing a new page in a NS application is
|
||||
// to navigate to it (no way to just replace it in its parent "element", for
|
||||
// example). This is how it is done in NS's own "core" HMR.
|
||||
//
|
||||
// NOTE The last paragraph has not really been confirmed with NS6.
|
||||
//
|
||||
// Unfortunately the API they're using to do that is not public... Its various
|
||||
// parts remain exposed though (but documented as private), so this exploratory
|
||||
// work now relies on it. It might be fragile...
|
||||
//
|
||||
// The problem is that there is no public API that can navigate to a page and
|
||||
// replace (like location.replace) the current history entry. Actually there
|
||||
// is an active issue at NS asking for that. Incidentally, members of
|
||||
// NativeScript-Vue have commented on the issue to weight in for it -- they
|
||||
// probably face some similar challenge.
|
||||
//
|
||||
// https://github.com/NativeScript/NativeScript/issues/6283
|
||||
|
||||
const getNavTransition = ({ transition }) => {
|
||||
if (typeof transition === 'string') {
|
||||
transition = { name: transition }
|
||||
}
|
||||
return transition ? { animated: true, transition } : { animated: false }
|
||||
}
|
||||
|
||||
export const adapter = class ProxyAdapterNative extends ProxyAdapterDom {
|
||||
constructor(instance) {
|
||||
super(instance)
|
||||
|
||||
this.nativePageElement = null
|
||||
}
|
||||
|
||||
dispose() {
|
||||
super.dispose()
|
||||
this.releaseNativePageElement()
|
||||
}
|
||||
|
||||
releaseNativePageElement() {
|
||||
if (this.nativePageElement) {
|
||||
// native cleaning will happen when navigating back from the page
|
||||
this.nativePageElement = null
|
||||
}
|
||||
}
|
||||
|
||||
afterMount(target, anchor) {
|
||||
// nativePageElement needs to be updated each time (only for page
|
||||
// components, native component that are not pages follow normal flow)
|
||||
//
|
||||
// TODO quid of components that are initially a page, but then have the
|
||||
// <page> tag removed while running? or the opposite?
|
||||
//
|
||||
// insertionPoint needs to be updated _only when the target changes_ --
|
||||
// i.e. when the component is mount, i.e. (in svelte3) when the component
|
||||
// is _created_, and svelte3 doesn't allow it to move afterward -- that
|
||||
// is, insertionPoint only needs to be created once when the component is
|
||||
// first mounted.
|
||||
//
|
||||
// TODO is it really true that components' elements cannot move in the
|
||||
// DOM? what about keyed list?
|
||||
//
|
||||
|
||||
const isNativePage =
|
||||
(target.tagName === 'fragment' || target.tagName === 'frame') &&
|
||||
target.firstChild &&
|
||||
target.firstChild.tagName == 'page'
|
||||
if (isNativePage) {
|
||||
const nativePageElement = target.firstChild
|
||||
this.nativePageElement = nativePageElement
|
||||
} else {
|
||||
// try to protect against components changing from page to no-page
|
||||
// or vice versa -- see DEBUG 1 above. NOT TESTED so prolly not working
|
||||
this.nativePageElement = null
|
||||
super.afterMount(target, anchor)
|
||||
}
|
||||
}
|
||||
|
||||
rerender() {
|
||||
const { nativePageElement } = this
|
||||
if (nativePageElement) {
|
||||
this.rerenderNative()
|
||||
} else {
|
||||
super.rerender()
|
||||
}
|
||||
}
|
||||
|
||||
rerenderNative() {
|
||||
const { nativePageElement: oldPageElement } = this
|
||||
const nativeView = oldPageElement.nativeView
|
||||
const frame = nativeView.frame
|
||||
if (frame) {
|
||||
return this.rerenderPage(frame, nativeView)
|
||||
}
|
||||
const modalParent = nativeView._modalParent // FIXME private API
|
||||
if (modalParent) {
|
||||
return this.rerenderModal(modalParent, nativeView)
|
||||
}
|
||||
// wtf? hopefully a race condition with a destroyed component, so
|
||||
// we have nothing more to do here
|
||||
//
|
||||
// for once, it happens when hot reloading dev deps, like this file
|
||||
//
|
||||
}
|
||||
|
||||
rerenderPage(frame, previousPageView) {
|
||||
const isCurrentPage = frame.currentPage === previousPageView
|
||||
if (isCurrentPage) {
|
||||
const {
|
||||
instance: { hotOptions },
|
||||
} = this
|
||||
const newPageElement = this.createPage()
|
||||
if (!newPageElement) {
|
||||
throw new Error('Failed to create updated page')
|
||||
}
|
||||
const isFirstPage = !frame.canGoBack()
|
||||
const nativeView = newPageElement.nativeView
|
||||
const navigationEntry = Object.assign(
|
||||
{},
|
||||
{
|
||||
create: () => nativeView,
|
||||
clearHistory: true,
|
||||
},
|
||||
getNavTransition(hotOptions)
|
||||
)
|
||||
|
||||
if (isFirstPage) {
|
||||
// NOTE not so sure of bellow with the new NS6 method for replace
|
||||
//
|
||||
// The "replacePage" strategy does not work on the first page
|
||||
// of the stack.
|
||||
//
|
||||
// Resulting bug:
|
||||
// - launch
|
||||
// - change first page => HMR
|
||||
// - navigate to other page
|
||||
// - back
|
||||
// => actual: back to OS
|
||||
// => expected: back to page 1
|
||||
//
|
||||
// Fortunately, we can overwrite history in this case.
|
||||
//
|
||||
frame.navigate(navigationEntry)
|
||||
} else {
|
||||
frame.replacePage(navigationEntry)
|
||||
}
|
||||
} else {
|
||||
const backEntry = frame.backStack.find(
|
||||
({ resolvedPage: page }) => page === previousPageView
|
||||
)
|
||||
if (!backEntry) {
|
||||
// well... looks like we didn't make it to history after all
|
||||
return
|
||||
}
|
||||
// replace existing nativeView
|
||||
const newPageElement = this.createPage()
|
||||
if (newPageElement) {
|
||||
backEntry.resolvedPage = newPageElement.nativeView
|
||||
} else {
|
||||
throw new Error('Failed to create updated page')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// modalParent is the page on which showModal(...) was called
|
||||
// oldPageElement is the modal content, that we're actually trying to reload
|
||||
rerenderModal(modalParent, modalView) {
|
||||
const modalData = getModalData(modalView)
|
||||
|
||||
modalData.closeCallback = () => {
|
||||
const nativePageElement = this.createPage()
|
||||
if (!nativePageElement) {
|
||||
throw new Error('Failed to created updated modal page')
|
||||
}
|
||||
const { nativeView } = nativePageElement
|
||||
const { originalOptions } = modalData
|
||||
// Options will get monkey patched again, the only work left for us
|
||||
// is to try to reduce visual disturbances.
|
||||
//
|
||||
// FIXME Even that proves too much unfortunately... Apparently TNS
|
||||
// does not respect the `animated` option in this context:
|
||||
// https://docs.nativescript.org/api-reference/interfaces/_ui_core_view_base_.showmodaloptions#animated
|
||||
//
|
||||
const options = Object.assign({}, originalOptions, { animated: false })
|
||||
modalParent.showModal(nativeView, options)
|
||||
}
|
||||
|
||||
modalView.closeModal()
|
||||
}
|
||||
|
||||
createPage() {
|
||||
const {
|
||||
instance: { refreshComponent },
|
||||
} = this
|
||||
const { nativePageElement: oldNativePageElement } = this
|
||||
const oldNativeView = oldNativePageElement.nativeView
|
||||
// rerender
|
||||
const target = document.createElement('fragment')
|
||||
|
||||
// not using conservative for now, since there's nothing in place here to
|
||||
// leverage it (yet?) -- and it might be easier to miss breakages in native
|
||||
// only code paths
|
||||
refreshComponent(target, null)
|
||||
|
||||
// this.nativePageElement is updated in afterMount, triggered by proxy / hooks
|
||||
const newPageElement = this.nativePageElement
|
||||
|
||||
// svelte-native uses navigateFrom event + e.isBackNavigation to know when to $destroy the component.
|
||||
// To keep that behaviour after refresh, we move event handler from old native view to the new one using
|
||||
// __navigateFromHandler property that svelte-native provides us with.
|
||||
const navigateFromHandler = oldNativeView.__navigateFromHandler
|
||||
if (navigateFromHandler) {
|
||||
oldNativeView.off('navigatedFrom', navigateFromHandler)
|
||||
newPageElement.nativeView.on('navigatedFrom', navigateFromHandler)
|
||||
newPageElement.nativeView.__navigateFromHandler = navigateFromHandler
|
||||
delete oldNativeView.__navigateFromHandler
|
||||
}
|
||||
|
||||
return newPageElement
|
||||
}
|
||||
|
||||
renderError(err /* , target, anchor */) {
|
||||
// TODO fallback on TNS error handler for now... at least our error
|
||||
// is more informative
|
||||
throw err
|
||||
}
|
||||
}
|
21
node_modules/tinyglobby/LICENSE
generated
vendored
21
node_modules/tinyglobby/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Madeline Gurriarán
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user