@livestore/devtools-vite 0.3.0-dev.15 → 0.3.0-dev.16
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 +1 -1
- package/dist/devtools-bundle/{data-grid-overlay-editor-DESyH_1M.js → data-grid-overlay-editor-P_YMgIJP.js} +1 -1
- package/dist/devtools-bundle/{devtools-react-bundle-BZklamRx.js → devtools-react-bundle-DfXMfS_c.js} +10869 -10821
- package/dist/devtools-bundle/{index-BQkqHAaL.js → index-BjzW88EM.js} +1 -1
- package/dist/devtools-bundle/index.js +1 -1
- package/dist/devtools-bundle/{number-overlay-editor-9KG8yQED.js → number-overlay-editor-BRPu_KOP.js} +1 -1
- package/dist/devtools.d.ts +2 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/devtools.js.map +1 -0
- package/dist/plugin.d.ts +50 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +39 -16
- package/dist/plugin.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Devtools } from '@livestore/common';
|
|
2
|
+
import { Schema } from '@livestore/utils/effect';
|
|
3
|
+
import type { Plugin } from 'vite';
|
|
4
|
+
export type PluginOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The path to the schema file. Needs to be a valid ESM import and relative to the root of the project.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { devtoolsVitePlugin } from '@livestore/devtools-vite'
|
|
11
|
+
*
|
|
12
|
+
* devtoolsVitePlugin({
|
|
13
|
+
* schemaPath: './src/db/schema/index.js'
|
|
14
|
+
* // ...
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
schemaPath: string;
|
|
19
|
+
license?: string;
|
|
20
|
+
mode?: Devtools.DevtoolsMode;
|
|
21
|
+
/**
|
|
22
|
+
* Where to serve the devtools UI.
|
|
23
|
+
*
|
|
24
|
+
* @default '/_livestore'
|
|
25
|
+
*/
|
|
26
|
+
path?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const PluginOptions: Schema.Struct<{
|
|
29
|
+
schemaPath: typeof Schema.String;
|
|
30
|
+
license: Schema.optional<typeof Schema.String>;
|
|
31
|
+
mode: Schema.optional<Schema.Union<[Schema.TaggedStruct<"from-search-params", {}>, Schema.TaggedStruct<"expo", {
|
|
32
|
+
storeId: typeof Schema.String;
|
|
33
|
+
}>, Schema.TaggedStruct<"node", {
|
|
34
|
+
storeId: typeof Schema.String;
|
|
35
|
+
clientId: typeof Schema.String;
|
|
36
|
+
sessionId: typeof Schema.String;
|
|
37
|
+
url: typeof Schema.String;
|
|
38
|
+
}>, Schema.TaggedStruct<"web", {
|
|
39
|
+
storeId: typeof Schema.String;
|
|
40
|
+
clientId: typeof Schema.String;
|
|
41
|
+
sessionId: typeof Schema.String;
|
|
42
|
+
}>, Schema.TaggedStruct<"browser-extension", {
|
|
43
|
+
storeId: typeof Schema.String;
|
|
44
|
+
clientId: typeof Schema.String;
|
|
45
|
+
sessionId: typeof Schema.String;
|
|
46
|
+
}>]>>;
|
|
47
|
+
path: Schema.optional<typeof Schema.String>;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const livestoreDevtoolsPlugin: (options: PluginOptions) => Plugin;
|
|
50
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;;OAYG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAA;IAC5B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,aAAa;;;;wBAuCgB,OAAQ,MAAM;;wBAChB,OAAQ,MAAM;yBAAsB,OAAQ,MAAM;0BAC1E,OAAO,MAAM;oBAAiB,OAAQ,MAAM;;wBAEvB,OAAQ,MAAM;yBACjC,OAAQ,MAAM;0BACZ,OACR,MAAH;;wBACK,OAAQ,MAEnB;yBAAsB,OACjB,MAAA;0BACM,OACN,MACP;;;EAhDC,CAAA;AAEF,eAAO,MAAM,uBAAuB,YAAa,aAAa,KAAG,MA6GhE,CAAA"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { Devtools } from '@livestore/common';
|
|
3
|
+
import { Schema } from '@livestore/utils/effect';
|
|
4
|
+
export const PluginOptions = Schema.Struct({
|
|
5
|
+
schemaPath: Schema.String,
|
|
6
|
+
license: Schema.optional(Schema.String),
|
|
7
|
+
mode: Schema.optional(Devtools.DevtoolsMode),
|
|
8
|
+
path: Schema.optional(Schema.String),
|
|
9
|
+
});
|
|
2
10
|
export const livestoreDevtoolsPlugin = (options) => {
|
|
11
|
+
Schema.validateSync(PluginOptions)(options);
|
|
12
|
+
const mountPath = options.path ?? '/_livestore';
|
|
3
13
|
return {
|
|
4
14
|
name: '@livestore/devtools-vite',
|
|
5
15
|
// `vite dev` support
|
|
6
16
|
configureServer: (server) => {
|
|
7
|
-
server.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
.join('
|
|
20
|
-
|
|
17
|
+
const basedMountPath = path.join(server.config.base, mountPath);
|
|
18
|
+
// console.log('basedMountPath', basedMountPath)
|
|
19
|
+
server.middlewares.use(basedMountPath, async (req, res, next) => {
|
|
20
|
+
if (req.url === undefined) {
|
|
21
|
+
next();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const url = new URL(req.url, typeof server.config.server.host === 'string' ? server.config.server.host : 'http://localhost');
|
|
25
|
+
// console.log('livestore-devtools-vite:req', url)
|
|
26
|
+
if (url.pathname === '/') {
|
|
27
|
+
res.setHeader('Content-Type', 'text/html');
|
|
28
|
+
const schemaPath = path.resolve(options.schemaPath);
|
|
29
|
+
const bundleDir = path.join(import.meta.dirname, '..', 'dist', 'devtools-bundle');
|
|
30
|
+
const bundlePath = path.resolve(bundleDir, 'index.js');
|
|
31
|
+
const cssPath = path.resolve(bundleDir, 'devtools-vite.css');
|
|
32
|
+
const template = makeIndexHtml({ schemaPath, bundlePath, cssPath, mode: options.mode });
|
|
33
|
+
const html = await server.transformIndexHtml(mountPath, template);
|
|
34
|
+
// Remove line that contains `vinxi/runtime`
|
|
35
|
+
const trimmedHtml = html
|
|
36
|
+
.split('\n')
|
|
37
|
+
.filter((line) => !line.includes('vinxi/runtime'))
|
|
38
|
+
.join('\n');
|
|
39
|
+
res.end(trimmedHtml);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
next();
|
|
43
|
+
}
|
|
21
44
|
});
|
|
22
45
|
},
|
|
23
46
|
config: (config) => {
|
|
@@ -70,7 +93,7 @@ export const livestoreDevtoolsPlugin = (options) => {
|
|
|
70
93
|
// },
|
|
71
94
|
};
|
|
72
95
|
};
|
|
73
|
-
const makeIndexHtml = ({ schemaPath, bundlePath, cssPath, }) => {
|
|
96
|
+
const makeIndexHtml = ({ schemaPath, bundlePath, cssPath, mode, }) => {
|
|
74
97
|
return /*html*/ `
|
|
75
98
|
<!doctype html>
|
|
76
99
|
<html lang="en">
|
|
@@ -94,7 +117,7 @@ const makeIndexHtml = ({ schemaPath, bundlePath, cssPath, }) => {
|
|
|
94
117
|
schema,
|
|
95
118
|
license: ${process.env.LSD_LICENSE} ? '${process.env.LSD_LICENSE}' : undefined,
|
|
96
119
|
// Mode will be provided via URL search params
|
|
97
|
-
mode: undefined,
|
|
120
|
+
mode: ${mode ? Schema.encodeSync(Schema.parseJson(Devtools.DevtoolsMode))(mode) : undefined},
|
|
98
121
|
sharedWorker,
|
|
99
122
|
})
|
|
100
123
|
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AA4BhD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACrC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAsB,EAAU,EAAE;IACxE,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA;IAE3C,MAAM,SAAS,GAAG,OAAO,CAA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