@livestore/devtools-expo 0.3.0-dev.19 → 0.3.0-dev.22

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // eslint-disable-next-line unicorn/prefer-module
3
+ // eslint-disable-next-line unicorn/prefer-module, @typescript-eslint/no-require-imports
4
4
  module.exports = require('./metro-config.cjs');
5
5
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":";;AAAA,iDAAiD;AACjD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA"}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":";;AAAA,wFAAwF;AACxF,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, @typescript-eslint/consistent-type-imports
3
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, @typescript-eslint/consistent-type-imports, prettier/prettier
4
4
  const { Effect } = require('@livestore/utils/effect');
5
5
  /**
6
6
  * Patches the Metro config to add a middleware via `config.server.enhanceMiddleware`.
@@ -23,15 +23,7 @@ const addLiveStoreDevtoolsMiddleware = (config, options) => {
23
23
  const makeLiveStoreDevtoolsMiddleware = (options) => {
24
24
  // TODO Once Expo supports proper ESM, we can make this a static import
25
25
  // const viteServerPromise = makeViteServer(options)
26
- const viteServerPromise = import('@livestore/adapter-node/devtools').then(({ makeViteServer }) => makeViteServer({
27
- ...options,
28
- mode: {
29
- _tag: 'expo',
30
- storeId: options.storeId ?? 'default',
31
- clientId: options.clientId ?? 'expo',
32
- sessionId: options.sessionId ?? 'expo',
33
- },
34
- }).pipe(Effect.runPromise));
26
+ const viteServerPromise = import('@livestore/adapter-node/devtools').then(({ makeViteServer }) => makeViteServer({ ...options, mode: { _tag: 'expo' } }).pipe(Effect.runPromise));
35
27
  const middleware = async (req, res, next) => {
36
28
  if (req.url?.startsWith('/_livestore') == false) {
37
29
  return next();
@@ -1 +1 @@
1
- {"version":3,"file":"metro-config.cjs","sourceRoot":"","sources":["../src/metro-config.cts"],"names":[],"mappings":";;AAEA,oIAAoI;AACpI,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAA6C,CAAA;AAMjG;;GAEG;AACH,MAAM,8BAA8B,GAAG,CAAC,MAAgC,EAAE,OAAgB,EAAE,EAAE;IAC5F,kCAAkC;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5C,OAAM;IACR,CAAC;IAED,MAAM,cAAc,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAA;IAE/D,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,iBAGjC,CAAA;IAEf,MAAM,iBAAiB,GAAG,CAAC,eAA2B,EAAE,MAAW,EAAc,EAAE;QACjF,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;QAE7E,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CACxB,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC;YAChC,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACpE,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CA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,EAAE,GAAwB,EAAE,IAAgB,EAAE,EAAE;QACjG,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;YAChD,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAA;QAE1C,OAAO,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC,CAAA;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAOD,iDAAiD;AACjD,MAAM,CAAC,OAAO,GAAG;IACf,8BAA8B;IAC9B,+BAA+B;CAChC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"metro-config.d.cts","sourceRoot":"","sources":["../src/metro-config.cts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AAKtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,YAAY,CAAA;AAErD;;GAEG;AACH,QAAA,MAAM,8BAA8B,GAAI,QAAQ,WAAW,CAAC,WAAW,CAAC,EAAE,SAAS,OAAO,SAuBzF,CAAA;AAED,QAAA,MAAM,+BAA+B,GAAI,SAAS,OAAO,WAexB,IAAI,CAAC,eAAe,OAAO,IAAI,CAAC,cAAc,QAAQ,MAAM,IAAI,kBAWhG,CAAA;AAED,0CAA0C;AAC1C,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5C,CAAA;AAQD,YAAY,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,CAAA;AAC/E,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"metro-config.d.cts","sourceRoot":"","sources":["../src/metro-config.cts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AAKtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,YAAY,CAAA;AAErD;;GAEG;AACH,QAAA,MAAM,8BAA8B,GAAI,QAAQ,WAAW,CAAC,WAAW,CAAC,EAAE,SAAS,OAAO,SAuBzF,CAAA;AAED,QAAA,MAAM,+BAA+B,GAAI,SAAS,OAAO,WAOxB,IAAI,CAAC,eAAe,OAAO,IAAI,CAAC,cAAc,QAAQ,MAAM,IAAI,kBAWhG,CAAA;AAED,0CAA0C;AAC1C,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5C,CAAA;AAQD,YAAY,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,CAAA;AAC/E,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,21 +1,16 @@
1
1
  {
2
2
  "name": "@livestore/devtools-expo",
3
- "version": "0.3.0-dev.19",
3
+ "version": "0.3.0-dev.22",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.cts",
6
6
  "dependencies": {
7
- "@livestore/devtools-vite": "0.3.0-dev.19",
8
- "@livestore/wa-sqlite": "1.0.5-dev.2",
9
- "vite": "6.1.0",
10
- "ws": "8.18.0",
11
- "@livestore/adapter-node": "0.3.0-dev.19",
12
- "@livestore/adapter-web": "0.3.0-dev.19",
13
- "@livestore/utils": "0.3.0-dev.19"
7
+ "@livestore/utils": "0.3.0-dev.22",
8
+ "@livestore/adapter-node": "0.3.0-dev.22"
14
9
  },
15
10
  "devDependencies": {
16
- "@types/node": "^22.10.10",
17
- "@types/ws": "^8.5.12",
18
- "expo": "^52.0.37"
11
+ "@types/node": "^22.13.10",
12
+ "expo": "^52.0.37",
13
+ "vite": "^6.2.1"
19
14
  },
20
15
  "main": "./dist/index.cjs",
21
16
  "peerDependencies": {
package/src/index.cts CHANGED
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line unicorn/prefer-module
1
+ // eslint-disable-next-line unicorn/prefer-module, @typescript-eslint/no-require-imports
2
2
  module.exports = require('./metro-config.cjs')
3
3
 
4
4
  export type * from './metro-config.cts'
@@ -1,7 +1,7 @@
1
1
  import type * as http from 'node:http'
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, @typescript-eslint/consistent-type-imports
4
- const { Effect } = require('@livestore/utils/effect') as typeof import('@livestore/utils/effect')
3
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, @typescript-eslint/consistent-type-imports, prettier/prettier
4
+ const { Effect } = require('@livestore/utils/effect') as typeof import('@livestore/utils/effect', { with: { "resolution-mode": "import" } })
5
5
 
6
6
  import type { MetroConfig } from 'expo/metro-config'
7
7
 
@@ -39,15 +39,7 @@ const makeLiveStoreDevtoolsMiddleware = (options: Options) => {
39
39
  // TODO Once Expo supports proper ESM, we can make this a static import
40
40
  // const viteServerPromise = makeViteServer(options)
41
41
  const viteServerPromise = import('@livestore/adapter-node/devtools').then(({ makeViteServer }) =>
42
- makeViteServer({
43
- ...options,
44
- mode: {
45
- _tag: 'expo',
46
- storeId: options.storeId ?? 'default',
47
- clientId: options.clientId ?? 'expo',
48
- sessionId: options.sessionId ?? 'expo',
49
- },
50
- }).pipe(Effect.runPromise),
42
+ makeViteServer({ ...options, mode: { _tag: 'expo' } }).pipe(Effect.runPromise),
51
43
  )
52
44
 
53
45
  const middleware = async (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => {
package/src/types.d.ts CHANGED
@@ -13,7 +13,4 @@ export type Options = {
13
13
  * Example: `./src/schema.ts`
14
14
  */
15
15
  schemaPath: string
16
- storeId?: string
17
- clientId?: string
18
- sessionId?: string
19
16
  }
package/webui/index.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>LiveStore DevTools Redirect</title>
7
7
  <script>
8
8
  const currentUrl = new URL(window.location.href);
9
- const redirectUrl = `http://localhost:${currentUrl.port}/_livestore`;
9
+ const redirectUrl = `http://localhost:${currentUrl.port}/_livestore/expo?autoconnect`;
10
10
  window.location.href = redirectUrl;
11
11
  </script>
12
12
  </head>
@@ -1,4 +0,0 @@
1
- import * as Vite from 'vite';
2
- import type { Options } from './types.js';
3
- export declare const makeViteServer: (options: Options) => Promise<Vite.ViteDevServer>;
4
- //# sourceMappingURL=unused-vite-dev-server.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unused-vite-dev-server.d.mts","sourceRoot":"","sources":["../src/unused-vite-dev-server.mts"],"names":[],"mappings":"AAKA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAIzC,eAAO,MAAM,cAAc,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAoCjF,CAAA"}
@@ -1,79 +0,0 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { Effect } from '@livestore/utils/effect';
4
- import { getFreePort } from '@livestore/utils/node';
5
- import * as Vite from 'vite';
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- export const makeViteServer = async (options) => {
8
- const hmrPort = await getFreePort.pipe(Effect.runPromise);
9
- const cwd = process.cwd();
10
- const defaultViteConfig = Vite.defineConfig({
11
- server: {
12
- middlewareMode: true,
13
- hmr: {
14
- port: hmrPort,
15
- },
16
- fs: {
17
- // Adds `node_modules` so we can import `@livestore/wa-sqlite` for WASM to work
18
- allow: [path.resolve(__dirname, '..', '..')],
19
- },
20
- },
21
- resolve: {
22
- alias: {
23
- '@schema': path.resolve(cwd, options.schemaPath),
24
- },
25
- },
26
- appType: 'spa',
27
- optimizeDeps: {
28
- // TODO remove once fixed https://github.com/vitejs/vite/issues/8427
29
- exclude: ['@livestore/wa-sqlite'],
30
- },
31
- root: __dirname,
32
- base: '/livestore-devtools/',
33
- plugins: [virtualHtmlPlugin],
34
- });
35
- const viteConfig = options.viteConfig?.(defaultViteConfig) ?? defaultViteConfig;
36
- const viteServer = Vite.createServer(viteConfig);
37
- return viteServer;
38
- };
39
- const virtualHtmlPlugin = {
40
- name: 'virtual-html',
41
- configureServer: (server) => {
42
- return () => {
43
- server.middlewares.use(async (req, res, next) => {
44
- if (req.url === '/' || req.url === '' || req.url === '/index.html') {
45
- const html = `
46
- <!doctype html>
47
- <html lang="en">
48
- <head>
49
- <meta charset="UTF-8" />
50
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
51
- <meta name="livestore-devtools" content="true" />
52
- <title>LiveStore Devtools</title>
53
- </head>
54
- <body>
55
- <div id="root"></div>
56
- <script type="module">
57
- import '@livestore/devtools-react/index.css'
58
- import { mountDevtools } from '@livestore/devtools-react'
59
- import sharedWorker from '@livestore/adapter-web/shared-worker?sharedworker'
60
- import { schema } from '@schema'
61
-
62
- mountDevtools({ schema, rootEl: document.getElementById('root'), sharedWorker, mode: 'expo' })
63
- </script>
64
- </body>
65
- </html>
66
- `;
67
- const transformedHtml = await server.transformIndexHtml(req.url, html);
68
- res.statusCode = 200;
69
- res.setHeader('Content-Type', 'text/html');
70
- res.end(transformedHtml);
71
- }
72
- else {
73
- next();
74
- }
75
- });
76
- };
77
- },
78
- };
79
- //# sourceMappingURL=unused-vite-dev-server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unused-vite-dev-server.mjs","sourceRoot":"","sources":["../src/unused-vite-dev-server.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAA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AAM,EAAE,EAAE;QAC1B,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC9C,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,KAAK,aAAa,EAAE,CAAC;oBACnE,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;WAqBZ,CAAA;oBACD,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;oBACtE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAA;oBACpB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;oBAC1C,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;gBAC1B,CAAC;qBAAM,CAAC;oBACN,IAAI,EAAE,CAAA;gBACR,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -1,88 +0,0 @@
1
- import path from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- import { Effect } from '@livestore/utils/effect'
5
- import { getFreePort } from '@livestore/utils/node'
6
- import * as Vite from 'vite'
7
-
8
- import type { Options } from './types.js'
9
-
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
-
12
- export const makeViteServer = async (options: Options): Promise<Vite.ViteDevServer> => {
13
- const hmrPort = await getFreePort.pipe(Effect.runPromise)
14
-
15
- const cwd = process.cwd()
16
-
17
- const defaultViteConfig = Vite.defineConfig({
18
- server: {
19
- middlewareMode: true,
20
- hmr: {
21
- port: hmrPort,
22
- },
23
- fs: {
24
- // Adds `node_modules` so we can import `@livestore/wa-sqlite` for WASM to work
25
- allow: [path.resolve(__dirname, '..', '..')],
26
- },
27
- },
28
- resolve: {
29
- alias: {
30
- '@schema': path.resolve(cwd, options.schemaPath),
31
- },
32
- },
33
- appType: 'spa',
34
- optimizeDeps: {
35
- // TODO remove once fixed https://github.com/vitejs/vite/issues/8427
36
- exclude: ['@livestore/wa-sqlite'],
37
- },
38
- root: __dirname,
39
- base: '/livestore-devtools/',
40
- plugins: [virtualHtmlPlugin],
41
- })
42
-
43
- const viteConfig = options.viteConfig?.(defaultViteConfig) ?? defaultViteConfig
44
-
45
- const viteServer = Vite.createServer(viteConfig)
46
-
47
- return viteServer
48
- }
49
-
50
- const virtualHtmlPlugin: Vite.Plugin = {
51
- name: 'virtual-html',
52
- configureServer: (server) => {
53
- return () => {
54
- server.middlewares.use(async (req, res, next) => {
55
- if (req.url === '/' || req.url === '' || req.url === '/index.html') {
56
- const html = `
57
- <!doctype html>
58
- <html lang="en">
59
- <head>
60
- <meta charset="UTF-8" />
61
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
62
- <meta name="livestore-devtools" content="true" />
63
- <title>LiveStore Devtools</title>
64
- </head>
65
- <body>
66
- <div id="root"></div>
67
- <script type="module">
68
- import '@livestore/devtools-react/index.css'
69
- import { mountDevtools } from '@livestore/devtools-react'
70
- import sharedWorker from '@livestore/adapter-web/shared-worker?sharedworker'
71
- import { schema } from '@schema'
72
-
73
- mountDevtools({ schema, rootEl: document.getElementById('root'), sharedWorker, mode: 'expo' })
74
- </script>
75
- </body>
76
- </html>
77
- `
78
- const transformedHtml = await server.transformIndexHtml(req.url, html)
79
- res.statusCode = 200
80
- res.setHeader('Content-Type', 'text/html')
81
- res.end(transformedHtml)
82
- } else {
83
- next()
84
- }
85
- })
86
- }
87
- },
88
- }