@livestore/devtools-expo 0.3.0-dev.18 → 0.3.0-dev.21

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,7 +1,7 @@
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
4
- const { Effect_ } = require('@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');
5
5
  /**
6
6
  * Patches the Metro config to add a middleware via `config.server.enhanceMiddleware`.
7
7
  */
@@ -14,7 +14,7 @@ const addLiveStoreDevtoolsMiddleware = (config, options) => {
14
14
  const previousEnhanceMiddleware = config.server.enhanceMiddleware;
15
15
  const enhanceMiddleware = (metroMiddleware, server) => {
16
16
  const enhancedMiddleware = previousEnhanceMiddleware(metroMiddleware, server);
17
- return (req, res, next) => req.url?.startsWith('/livestore-devtools')
17
+ return (req, res, next) => req.url?.startsWith('/_livestore')
18
18
  ? viteMiddleware(req, res, () => enhancedMiddleware(req, res, next))
19
19
  : enhancedMiddleware(req, res, next);
20
20
  };
@@ -23,9 +23,9 @@ 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({ ...options, mode: { _tag: 'expo', storeId: 'default' } }).pipe(Effect_.runPromise));
26
+ const viteServerPromise = import('@livestore/adapter-node/devtools').then(({ makeViteServer }) => makeViteServer({ ...options, mode: { _tag: 'expo' } }).pipe(Effect.runPromise));
27
27
  const middleware = async (req, res, next) => {
28
- if (req.url?.startsWith('/livestore-devtools') == false) {
28
+ if (req.url?.startsWith('/_livestore') == false) {
29
29
  return next();
30
30
  }
31
31
  const viteServer = await viteServerPromise;
@@ -1 +1 @@
1
- {"version":3,"file":"metro-config.cjs","sourceRoot":"","sources":["../src/metro-config.cts"],"names":[],"mappings":";;AAEA,wFAAwF;AACxF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAMtD;;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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Ac,EAAE,EAAE,EAAE,CAC/F,cAAc,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAC/E,CAAA;IAED,MAAM,UAAU,GAAG,KAAK,EAAE,GAAyB,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"}
@@ -11,4 +11,5 @@ type MutableDeep<T> = {
11
11
  -readonly [P in keyof T]: MutableDeep<T[P]>;
12
12
  };
13
13
  export type { addLiveStoreDevtoolsMiddleware, makeLiveStoreDevtoolsMiddleware };
14
+ export type { Options } from './types.js';
14
15
  //# sourceMappingURL=metro-config.d.cts.map
@@ -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,WASxB,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"}
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,25 +1,20 @@
1
1
  {
2
2
  "name": "@livestore/devtools-expo",
3
- "version": "0.3.0-dev.18",
3
+ "version": "0.3.0-dev.21",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.cts",
6
6
  "dependencies": {
7
- "@livestore/devtools-vite": "0.3.0-dev.18",
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.18",
12
- "@livestore/utils": "0.3.0-dev.18",
13
- "@livestore/adapter-web": "0.3.0-dev.18"
7
+ "@livestore/adapter-node": "0.3.0-dev.21",
8
+ "@livestore/utils": "0.3.0-dev.21"
14
9
  },
15
10
  "devDependencies": {
16
- "@types/node": "^22.10.10",
17
- "@types/ws": "^8.5.12",
18
- "expo": "^52.0.18"
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": {
22
- "expo": "~52.0.18"
17
+ "expo": "~52.0.37"
23
18
  },
24
19
  "publishConfig": {
25
20
  "access": "public"
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,8 +1,8 @@
1
1
  import type * as http from 'node:http'
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module
4
- const { Effect_ } = require('@livestore/utils/effect')
5
- import type { Effect } from '@livestore/utils/effect' with { 'resolution-mode': 'import' }
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
+
6
6
  import type { MetroConfig } from 'expo/metro-config'
7
7
 
8
8
  import type { Middleware, Options } from './types.js'
@@ -27,7 +27,7 @@ const addLiveStoreDevtoolsMiddleware = (config: MutableDeep<MetroConfig>, option
27
27
  const enhancedMiddleware = previousEnhanceMiddleware(metroMiddleware, server)
28
28
 
29
29
  return (req, res, next) =>
30
- req.url?.startsWith('/livestore-devtools')
30
+ req.url?.startsWith('/_livestore')
31
31
  ? viteMiddleware(req, res, () => enhancedMiddleware(req, res, next))
32
32
  : enhancedMiddleware(req, res, next)
33
33
  }
@@ -39,13 +39,11 @@ 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({ ...options, mode: { _tag: 'expo', storeId: 'default' } }).pipe(
43
- Effect_.runPromise as typeof Effect.runPromise,
44
- ),
42
+ makeViteServer({ ...options, mode: { _tag: 'expo' } }).pipe(Effect.runPromise),
45
43
  )
46
44
 
47
45
  const middleware = async (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => {
48
- if (req.url?.startsWith('/livestore-devtools') == false) {
46
+ if (req.url?.startsWith('/_livestore') == false) {
49
47
  return next()
50
48
  }
51
49
 
@@ -69,3 +67,4 @@ module.exports = {
69
67
  }
70
68
 
71
69
  export type { addLiveStoreDevtoolsMiddleware, makeLiveStoreDevtoolsMiddleware }
70
+ export type { Options } from './types.js'
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-devtools/`;
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,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAI5B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,OAAgB,EAA+B,EAAE;IACpF,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAEzD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAEzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,MAAM,EAAE;YACN,cAAc,EAAE,IAAI;YACpB,GAAG,EAAE;gB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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
- }