@livestore/devtools-vite 0.3.0-dev.8 → 0.3.0

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.
@@ -1,2 +0,0 @@
1
- export * from '@livestore/devtools-react';
2
- //# sourceMappingURL=devtools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
package/dist/devtools.js DELETED
@@ -1,2 +0,0 @@
1
- export * from '@livestore/devtools-react';
2
- //# sourceMappingURL=devtools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;;OAYG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,uBAAuB,YAAa,aAAa,KAAG,MAqDhE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAqB5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAsB,EAAU,EAAE;IACxE,OAAO;QACL,IAAI,EAAE,eAAe;QAErB,qBAAqB;QACrB,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE;YAC1B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;gBACzD,GAAG,CAAC,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AI,EAAE,gBAAgB,CAAC,CAAC,CAAA;QACjG,CAAC;QAED,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE;YAChB,IAAI,EAAE,KAAK,wBAAwB,EAAE,CAAC;gBACpC,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC;QAED,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;YACX,IAAI,EAAE,KAAK,wBAAwB,EAAE,CAAC;gBACpC,OAAO,aAAa,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;YAC1D,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,EAAE,UAAU,EAA0B,EAAE,EAAE;IAC/D,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;gCAiBc,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;;;;;;mBAMrC,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW;;;;;;;EAOtE,CAAA;AACF,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA"}
package/index.css DELETED
@@ -1 +0,0 @@
1
- @import '@livestore/devtools-react/index.css'
package/src/devtools.ts DELETED
@@ -1 +0,0 @@
1
- export * from '@livestore/devtools-react'
package/src/plugin.ts DELETED
@@ -1,112 +0,0 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
-
4
- import type { Plugin } from 'vite'
5
-
6
- export type PluginOptions = {
7
- /**
8
- * The path to the schema file. Needs to be a valid ESM import and relative to the root of the project.
9
- *
10
- * Example:
11
- * ```ts
12
- * import { devtoolsVitePlugin } from '@livestore/devtools-vite'
13
- *
14
- * devtoolsVitePlugin({
15
- * schemaPath: './src/db/schema/index.js'
16
- * // ...
17
- * })
18
- * ```
19
- */
20
- schemaPath: string
21
- }
22
-
23
- export const livestoreDevtoolsPlugin = (options: PluginOptions): Plugin => {
24
- return {
25
- name: 'devtools-vite',
26
-
27
- // `vite dev` support
28
- configureServer: (server) => {
29
- server.middlewares.use('/_devtools.html', async (_, res) => {
30
- res.setHeader('Content-Type', 'text/html')
31
- const template = makeIndexHtml({ schemaPath: options.schemaPath })
32
- const html = await server.transformIndexHtml('/_devtools.html', template)
33
- res.end(html)
34
- })
35
- },
36
-
37
- // `vite build` support below
38
- config: (config) => {
39
- if (config.build === undefined) {
40
- config.build = {}
41
- }
42
-
43
- if (config.build.rollupOptions === undefined) {
44
- config.build.rollupOptions = {}
45
- }
46
-
47
- if (config.build.rollupOptions.input === undefined) {
48
- config.build.rollupOptions.input = {
49
- main: path.resolve('./index.html'),
50
- }
51
- }
52
-
53
- if (isRecord(config.build.rollupOptions.input)) {
54
- config.build.rollupOptions.input.devtools = 'virtual:_devtools.html'
55
- // config.build.rollupOptions.input.devtools = '_devtools.html'
56
- }
57
-
58
- return config
59
- },
60
- writeBundle: (_) => {
61
- fs.renameSync(path.join(_.dir!, 'virtual:_devtools.html'), path.join(_.dir!, '_devtools.html'))
62
- },
63
-
64
- resolveId: (id) => {
65
- if (id === 'virtual:_devtools.html') {
66
- return id
67
- }
68
- },
69
-
70
- load: (id) => {
71
- if (id === 'virtual:_devtools.html') {
72
- return makeIndexHtml({ schemaPath: options.schemaPath })
73
- }
74
- },
75
- }
76
- }
77
-
78
- const makeIndexHtml = ({ schemaPath }: { schemaPath: string }) => {
79
- return /*html*/ `
80
- <!doctype html>
81
- <html lang="en">
82
- <head>
83
- <meta charset="UTF-8" />
84
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
85
- <meta name="livestore-devtools" content="true" />
86
- <title>LiveStore Devtools</title>
87
- </head>
88
- <body>
89
- <div id="root"></div>
90
- <script type="module">
91
- // NOTE we need to re-export dependencies from "@livestore/devtools-react"
92
- // as it's not a direct dependency of the Vite setup of a plugin user
93
- import '@livestore/devtools-vite/index.css'
94
- import { mountDevtools } from '@livestore/devtools-vite/devtools'
95
- import sharedWorker from '@livestore/web/shared-worker?sharedworker'
96
- import { schema } from '${path.resolve(schemaPath)}'
97
-
98
- mountDevtools({
99
- schema,
100
- rootEl: document.getElementById('root'),
101
- sharedWorker,
102
- license: ${process.env.LSD_LICENSE} ? '${process.env.LSD_LICENSE}' : undefined,
103
- // Mode will be provided via URL search params
104
- mode: undefined,
105
- })
106
- </script>
107
- </body>
108
- </html>
109
- `
110
- }
111
-
112
- const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src",
6
- "tsBuildInfoFile": "./dist/.tsbuildinfo"
7
- },
8
- "include": ["./src"],
9
- "references": [
10
- { "path": "../devtools-react" },
11
- ]
12
- }