@sveltejs/vite-plugin-svelte 1.0.2 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/ui/inspector/Inspector.svelte +2 -2
- package/src/ui/inspector/plugin.ts +7 -1
- package/src/ui/inspector/utils.ts +13 -0
- package/src/utils/options.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/vite-plugin-svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"debug": "^4.3.4",
|
|
46
46
|
"deepmerge": "^4.2.2",
|
|
47
47
|
"kleur": "^4.1.5",
|
|
48
|
-
"magic-string": "^0.26.
|
|
48
|
+
"magic-string": "^0.26.3",
|
|
49
49
|
"svelte-hmr": "^0.14.12"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
"@types/debug": "^4.1.7",
|
|
63
63
|
"@types/diff-match-patch": "^1.0.32",
|
|
64
64
|
"diff-match-patch": "^1.0.5",
|
|
65
|
-
"esbuild": "^0.15.
|
|
66
|
-
"rollup": "^2.
|
|
67
|
-
"svelte": "^3.
|
|
68
|
-
"tsup": "^6.2.
|
|
69
|
-
"vite": "^3.0
|
|
65
|
+
"esbuild": "^0.15.7",
|
|
66
|
+
"rollup": "^2.79.0",
|
|
67
|
+
"svelte": "^3.50.0",
|
|
68
|
+
"tsup": "^6.2.3",
|
|
69
|
+
"vite": "^3.1.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"dev": "pnpm build:ci --sourcemap --watch src",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function keydown(event) {
|
|
102
|
-
if (event.repeat || event.key
|
|
102
|
+
if (event.repeat || event.key == null) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function keyup(event) {
|
|
115
|
-
if (event.repeat) {
|
|
115
|
+
if (event.repeat || event.key == null) {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
const k = event.key.toLowerCase();
|
|
@@ -4,6 +4,7 @@ import { InspectorOptions } from '../../utils/options';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
+
import { idToFile } from './utils';
|
|
7
8
|
|
|
8
9
|
const defaultInspectorOptions: InspectorOptions = {
|
|
9
10
|
toggleKeyCombo: process.platform === 'win32' ? 'control-shift' : 'meta-shift',
|
|
@@ -71,7 +72,12 @@ export function svelteInspector(): Plugin {
|
|
|
71
72
|
return `export default ${JSON.stringify(inspectorOptions ?? {})}`;
|
|
72
73
|
} else if (id.startsWith(inspectorPath)) {
|
|
73
74
|
// read file ourselves to avoid getting shut out by vites fs.allow check
|
|
74
|
-
|
|
75
|
+
const file = idToFile(id);
|
|
76
|
+
if (fs.existsSync(file)) {
|
|
77
|
+
return await fs.promises.readFile(file, 'utf-8');
|
|
78
|
+
} else {
|
|
79
|
+
log.error(`failed to find file for svelte-inspector: ${file}, referenced by id ${id}.`);
|
|
80
|
+
}
|
|
75
81
|
}
|
|
76
82
|
},
|
|
77
83
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const FS_PREFIX = `/@fs/`;
|
|
2
|
+
const IS_WINDOWS = process.platform === 'win32';
|
|
3
|
+
const queryRE = /\?.*$/s;
|
|
4
|
+
const hashRE = /#.*$/s;
|
|
5
|
+
|
|
6
|
+
export function idToFile(id: string): string {
|
|
7
|
+
// strip /@fs/ but keep leading / on non-windows
|
|
8
|
+
if (id.startsWith(FS_PREFIX)) {
|
|
9
|
+
id = id = id.slice(IS_WINDOWS ? FS_PREFIX.length : FS_PREFIX.length - 1);
|
|
10
|
+
}
|
|
11
|
+
// strip query and hash
|
|
12
|
+
return id.replace(hashRE, '').replace(queryRE, '');
|
|
13
|
+
}
|
package/src/utils/options.ts
CHANGED
|
@@ -138,7 +138,7 @@ export async function preResolveOptions(
|
|
|
138
138
|
isServe: viteEnv.command === 'serve',
|
|
139
139
|
isDebug: process.env.DEBUG != null
|
|
140
140
|
};
|
|
141
|
-
const merged = mergeConfigs<
|
|
141
|
+
const merged = mergeConfigs<PreResolvedOptions>(
|
|
142
142
|
defaultOptions,
|
|
143
143
|
svelteConfig,
|
|
144
144
|
inlineOptions,
|
|
@@ -152,15 +152,15 @@ export async function preResolveOptions(
|
|
|
152
152
|
return merged;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function mergeConfigs<T>(...configs: T[]):
|
|
156
|
-
let result = {};
|
|
157
|
-
for (const config of configs.filter(
|
|
158
|
-
result = deepmerge<T>(result, config
|
|
155
|
+
function mergeConfigs<T>(...configs: (Partial<T> | undefined)[]): T {
|
|
156
|
+
let result: Partial<T> = {};
|
|
157
|
+
for (const config of configs.filter((x) => x != null)) {
|
|
158
|
+
result = deepmerge<T>(result, config!, {
|
|
159
159
|
// replace arrays
|
|
160
160
|
arrayMerge: (target: any[], source: any[]) => source ?? target
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
return result as
|
|
163
|
+
return result as T;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// used in configResolved phase, merges a contextual default config, pre-resolved options, and some preprocessors.
|
|
@@ -180,7 +180,7 @@ export function resolveOptions(
|
|
|
180
180
|
root: viteConfig.root,
|
|
181
181
|
isProduction: viteConfig.isProduction
|
|
182
182
|
};
|
|
183
|
-
const merged
|
|
183
|
+
const merged = mergeConfigs<ResolvedOptions>(defaultOptions, preResolveOptions, extraOptions);
|
|
184
184
|
|
|
185
185
|
removeIgnoredOptions(merged);
|
|
186
186
|
addSvelteKitOptions(merged);
|