@qwik.dev/devtools 0.0.1 → 0.0.3

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.
@@ -18,8 +18,8 @@ function qwikDevtools() {
18
18
  order: "pre",
19
19
  handler(code, id) {
20
20
  if (id.endsWith("root.tsx")) {
21
- if (!code.includes("@qwik.dev/devtools/component")) {
22
- code = `import { QwikDevtools } from '@qwik.dev/devtools/component';
21
+ if (!code.includes("@qwik.dev/devtools")) {
22
+ code = `import { QwikDevtools } from '@qwik.dev/devtools';
23
23
  ${code}`;
24
24
  }
25
25
  const match = code.match(/<body[^>]*>([\s\S]*?)<\/body>/);
@@ -16,8 +16,8 @@ function qwikDevtools() {
16
16
  order: "pre",
17
17
  handler(code, id) {
18
18
  if (id.endsWith("root.tsx")) {
19
- if (!code.includes("@qwik.dev/devtools/component")) {
20
- code = `import { QwikDevtools } from '@qwik.dev/devtools/component';
19
+ if (!code.includes("@qwik.dev/devtools")) {
20
+ code = `import { QwikDevtools } from '@qwik.dev/devtools';
21
21
  ${code}`;
22
22
  }
23
23
  const match = code.match(/<body[^>]*>([\s\S]*?)<\/body>/);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const core = require("@qwik.dev/core");
4
+ function getCurrentLocation() {
5
+ if (!core.isBrowser) return "";
6
+ if (window.location.pathname === "/") return "/";
7
+ return window.location.pathname.slice(0, -1);
8
+ }
9
+ exports.getCurrentLocation = getCurrentLocation;
@@ -0,0 +1,9 @@
1
+ import { isBrowser } from "@qwik.dev/core";
2
+ function getCurrentLocation() {
3
+ if (!isBrowser) return "";
4
+ if (window.location.pathname === "/") return "/";
5
+ return window.location.pathname.slice(0, -1);
6
+ }
7
+ export {
8
+ getCurrentLocation
9
+ };
@@ -1 +1,2 @@
1
1
  export { qwikDevtools } from './plugin';
2
+ export { QwikDevtools } from './devtools';
@@ -0,0 +1 @@
1
+ export declare function getCurrentLocation(): string;
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@qwik.dev/devtools",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Qwik devtools package",
5
5
  "main": "./lib/index.qwik.mjs",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./lib/index.qwik.mjs"
9
- },
10
- "./component": {
11
- "import": "./src/devtools.tsx"
12
9
  }
13
10
  },
14
11
  "files": [
@@ -38,7 +35,6 @@
38
35
  },
39
36
  "peerDependencies": {
40
37
  "@qwik.dev/core": "^2.0.0-alpha.4",
41
- "@qwik.dev/router": "^2.0.0-alpha.4",
42
38
  "vite": "^6.0.0"
43
39
  },
44
40
  "dependencies": {
@@ -52,8 +48,6 @@
52
48
  "vite-hot-client": "^0.2.4"
53
49
  },
54
50
  "devDependencies": {
55
- "@qwik.dev/core": "^2.0.0-alpha.4",
56
- "@qwik.dev/router": "^2.0.0-alpha.4",
57
51
  "@types/eslint": "8.56.10",
58
52
  "@types/node": "20.14.11",
59
53
  "@typescript-eslint/eslint-plugin": "7.16.1",
package/src/devtools.tsx CHANGED
@@ -23,8 +23,8 @@ import {
23
23
  type RoutesInfo,
24
24
  RouteType,
25
25
  } from './kit';
26
- // import { useLocation } from '@qwik.dev/router';
27
26
  import styles from './devtools.css?inline';
27
+ import { getCurrentLocation } from './utils/location';
28
28
  function getClientRpcFunctions() {
29
29
  return {
30
30
  healthCheck: () => true,
@@ -49,11 +49,7 @@ export const QwikDevtools = component$(() => {
49
49
  routes: undefined,
50
50
  });
51
51
  const panelRef = useSignal<HTMLDivElement>();
52
- const location = {
53
- url: {
54
- pathname: '/',
55
- },
56
- };
52
+ const location = getCurrentLocation();
57
53
 
58
54
  // eslint-disable-next-line qwik/no-use-visible-task
59
55
  useVisibleTask$(async ({ cleanup, track }) => {
@@ -90,8 +86,6 @@ export const QwikDevtools = component$(() => {
90
86
  ...directories,
91
87
  ];
92
88
 
93
- console.log(values, noSerialize(values));
94
-
95
89
  state.routes = noSerialize(values);
96
90
  });
97
91
 
@@ -377,8 +371,7 @@ export const QwikDevtools = component$(() => {
377
371
  <div class="col-route">
378
372
  <span
379
373
  class={
380
- location.url.pathname ===
381
- `/${route.relativePath}/`
374
+ location === `/${route.relativePath}`
382
375
  ? 'active-route'
383
376
  : ''
384
377
  }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { qwikDevtools } from './plugin';
2
+ export { QwikDevtools } from './devtools';
@@ -16,9 +16,9 @@ export function qwikDevtools(): Plugin {
16
16
  // Only transform the root component file
17
17
  if (id.endsWith('root.tsx')) {
18
18
  // Check if QwikDevtools import already exists
19
- if (!code.includes('@qwik.dev/devtools/component')) {
19
+ if (!code.includes('@qwik.dev/devtools')) {
20
20
  // Add import for QwikDevtools using the correct package name
21
- code = `import { QwikDevtools } from '@qwik.dev/devtools/component';\n${code}`;
21
+ code = `import { QwikDevtools } from '@qwik.dev/devtools';\n${code}`;
22
22
  }
23
23
 
24
24
  // Find the closing body tag and inject the QwikDevtools component before it
@@ -0,0 +1,9 @@
1
+ import { isBrowser } from '@qwik.dev/core';
2
+
3
+ export function getCurrentLocation() {
4
+ if (!isBrowser) return '';
5
+
6
+ if (window.location.pathname === '/') return '/';
7
+
8
+ return window.location.pathname.slice(0, -1);
9
+ }