@livestore/devtools-vite 0.3.0-dev.12 → 0.3.0-dev.14
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/README.md +17 -0
- package/dist/devtools-bundle/data-grid-overlay-editor-C7Qx54cC.js +103 -0
- package/dist/devtools-bundle/devtools-react-bundle-fG42JXr6.js +113868 -0
- package/dist/devtools-bundle/devtools-vite.css +1 -0
- package/dist/devtools-bundle/index-BDuhdLn5.js +44 -0
- package/dist/devtools-bundle/index.js +4 -0
- package/dist/devtools-bundle/mod-2ScWT2NO.js +368 -0
- package/dist/devtools-bundle/number-overlay-editor-D4wzldRK.js +596 -0
- package/dist/plugin.js +64 -41
- package/package.json +2 -22
- package/dist/.tsbuildinfo +0 -1
- package/dist/devtools.d.ts +0 -2
- package/dist/devtools.d.ts.map +0 -1
- package/dist/devtools.js.map +0 -1
- package/dist/plugin.d.ts +0 -19
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/index.css +0 -1
- package/src/devtools.ts +0 -1
- package/src/plugin.ts +0 -112
- package/tsconfig.json +0 -12
package/dist/plugin.js
CHANGED
|
@@ -1,52 +1,76 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
export const livestoreDevtoolsPlugin = (options) => {
|
|
4
3
|
return {
|
|
5
|
-
name: 'devtools-vite',
|
|
4
|
+
name: '@livestore/devtools-vite',
|
|
6
5
|
// `vite dev` support
|
|
7
6
|
configureServer: (server) => {
|
|
8
|
-
server.middlewares.use('/
|
|
7
|
+
server.middlewares.use('/_livestore', async (_, res) => {
|
|
9
8
|
res.setHeader('Content-Type', 'text/html');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
9
|
+
const schemaPath = path.resolve(options.schemaPath);
|
|
10
|
+
const bundleDir = path.join(import.meta.dirname, '..', 'dist', 'devtools-bundle');
|
|
11
|
+
const bundlePath = path.resolve(bundleDir, 'index.js');
|
|
12
|
+
const cssPath = path.resolve(bundleDir, 'devtools-vite.css');
|
|
13
|
+
const template = makeIndexHtml({ schemaPath, bundlePath, cssPath });
|
|
14
|
+
const html = await server.transformIndexHtml('/_livestore', template);
|
|
15
|
+
// Remove line that contains `vinxi/runtime`
|
|
16
|
+
const trimmedHtml = html
|
|
17
|
+
.split('\n')
|
|
18
|
+
.filter((line) => !line.includes('vinxi/runtime'))
|
|
19
|
+
.join('\n');
|
|
20
|
+
res.end(trimmedHtml);
|
|
13
21
|
});
|
|
14
22
|
},
|
|
15
|
-
// `vite build` support below
|
|
16
23
|
config: (config) => {
|
|
17
|
-
if (config.
|
|
18
|
-
config.
|
|
19
|
-
}
|
|
20
|
-
if (config.build.rollupOptions === undefined) {
|
|
21
|
-
config.build.rollupOptions = {};
|
|
24
|
+
if (config.optimizeDeps === undefined) {
|
|
25
|
+
config.optimizeDeps = {};
|
|
22
26
|
}
|
|
23
|
-
if (config.
|
|
24
|
-
config.
|
|
25
|
-
main: path.resolve('./index.html'),
|
|
26
|
-
};
|
|
27
|
+
if (config.optimizeDeps.exclude === undefined) {
|
|
28
|
+
config.optimizeDeps.exclude = [];
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const toAdd = ['@livestore/devtools-vite', '@livestore/wa-sqlite'];
|
|
31
|
+
for (const dep of toAdd) {
|
|
32
|
+
if (!config.optimizeDeps.exclude.includes(dep)) {
|
|
33
|
+
config.optimizeDeps.exclude.push(dep);
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
return config;
|
|
33
37
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
38
|
+
// `vite build` support below
|
|
39
|
+
// TODO maybe bring back at some point
|
|
40
|
+
// config: (config) => {
|
|
41
|
+
// if (config.build === undefined) {
|
|
42
|
+
// config.build = {}
|
|
43
|
+
// }
|
|
44
|
+
// if (config.build.rollupOptions === undefined) {
|
|
45
|
+
// config.build.rollupOptions = {}
|
|
46
|
+
// }
|
|
47
|
+
// if (config.build.rollupOptions.input === undefined) {
|
|
48
|
+
// config.build.rollupOptions.input = {
|
|
49
|
+
// main: path.resolve('./index.html'),
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
|
+
// if (isRecord(config.build.rollupOptions.input)) {
|
|
53
|
+
// config.build.rollupOptions.input.devtools = 'virtual:_devtools.html'
|
|
54
|
+
// // config.build.rollupOptions.input.devtools = '_devtools.html'
|
|
55
|
+
// }
|
|
56
|
+
// return config
|
|
57
|
+
// },
|
|
58
|
+
// writeBundle: (_) => {
|
|
59
|
+
// fs.renameSync(path.join(_.dir!, 'virtual:_devtools.html'), path.join(_.dir!, '_devtools.html'))
|
|
60
|
+
// },
|
|
61
|
+
// resolveId: (id) => {
|
|
62
|
+
// if (id === 'virtual:_devtools.html') {
|
|
63
|
+
// return id
|
|
64
|
+
// }
|
|
65
|
+
// },
|
|
66
|
+
// load: (id) => {
|
|
67
|
+
// if (id === 'virtual:_devtools.html') {
|
|
68
|
+
// return makeIndexHtml({ schemaPath: options.schemaPath })
|
|
69
|
+
// }
|
|
70
|
+
// },
|
|
47
71
|
};
|
|
48
72
|
};
|
|
49
|
-
const makeIndexHtml = ({ schemaPath }) => {
|
|
73
|
+
const makeIndexHtml = ({ schemaPath, bundlePath, cssPath, }) => {
|
|
50
74
|
return /*html*/ `
|
|
51
75
|
<!doctype html>
|
|
52
76
|
<html lang="en">
|
|
@@ -59,25 +83,24 @@ const makeIndexHtml = ({ schemaPath }) => {
|
|
|
59
83
|
<body>
|
|
60
84
|
<div id="root"></div>
|
|
61
85
|
<script type="module">
|
|
86
|
+
import '${cssPath}'
|
|
62
87
|
// NOTE we need to re-export dependencies from "@livestore/devtools-react"
|
|
63
88
|
// as it's not a direct dependency of the Vite setup of a plugin user
|
|
64
|
-
import '
|
|
65
|
-
import {
|
|
66
|
-
import sharedWorker from '@livestore/web/shared-worker?sharedworker'
|
|
67
|
-
import { schema } from '${path.resolve(schemaPath)}'
|
|
89
|
+
import { run } from '${bundlePath}'
|
|
90
|
+
import { schema } from '${schemaPath}'
|
|
91
|
+
import sharedWorker from '@livestore/adapter-web/shared-worker?sharedworker'
|
|
68
92
|
|
|
69
|
-
|
|
93
|
+
run({
|
|
70
94
|
schema,
|
|
71
|
-
rootEl: document.getElementById('root'),
|
|
72
|
-
sharedWorker,
|
|
73
95
|
license: ${process.env.LSD_LICENSE} ? '${process.env.LSD_LICENSE}' : undefined,
|
|
74
96
|
// Mode will be provided via URL search params
|
|
75
97
|
mode: undefined,
|
|
98
|
+
sharedWorker,
|
|
76
99
|
})
|
|
77
100
|
</script>
|
|
78
101
|
</body>
|
|
79
102
|
</html>
|
|
80
103
|
`;
|
|
81
104
|
};
|
|
82
|
-
const isRecord = (value) => typeof value === 'object' && value !== null
|
|
105
|
+
// const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null
|
|
83
106
|
//# sourceMappingURL=plugin.js.map
|
package/package.json
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/devtools-vite",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/plugin.d.ts",
|
|
8
8
|
"default": "./dist/plugin.js"
|
|
9
9
|
},
|
|
10
|
-
"./
|
|
11
|
-
"types": "./dist/devtools.d.ts",
|
|
12
|
-
"default": "./dist/devtools.js"
|
|
13
|
-
},
|
|
14
|
-
"./index.css": {
|
|
15
|
-
"default": "./index.css"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@livestore/devtools-react": "0.3.0-dev.12",
|
|
20
|
-
"@livestore/web": "0.3.0-dev.12"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"vite": "^6.0.11"
|
|
24
|
-
},
|
|
25
|
-
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "vite build",
|
|
30
|
-
"dev": "vite build --watch"
|
|
10
|
+
"./build": "./build.ts"
|
|
31
11
|
}
|
|
32
12
|
}
|