@ui-inspect/next 0.1.17
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/app.d.ts +5 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +16 -0
- package/dist/app.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/pages.d.ts +10 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +13 -0
- package/dist/pages.js.map +1 -0
- package/dist/script.d.ts +7 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +27 -0
- package/dist/script.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
- package/src/app.ts +18 -0
- package/src/index.ts +6 -0
- package/src/pages.ts +21 -0
- package/src/script.ts +30 -0
- package/src/types.ts +31 -0
- package/src/vendor.d.ts +23 -0
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,wBAAgB,GAAG,IAAI,QAAQ,CAU9B"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Router route handler for Diana sprite.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { getDianaAssetPath } from '@ui-inspect/browser-ui/plugin-runtime';
|
|
6
|
+
export function GET() {
|
|
7
|
+
const body = readFileSync(getDianaAssetPath());
|
|
8
|
+
return new Response(body, {
|
|
9
|
+
status: 200,
|
|
10
|
+
headers: {
|
|
11
|
+
'content-type': 'image/webp',
|
|
12
|
+
'cache-control': 'no-store',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,MAAM,UAAU,GAAG;IACjB,MAAM,IAAI,GAAG,YAAY,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAE/C,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,YAAY;YAC5B,eAAe,EAAE,UAAU;SAC5B;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/pages.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pages Router API handler for Diana sprite.
|
|
3
|
+
*/
|
|
4
|
+
export interface UiInspectPagesResponse {
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
setHeader(name: string, value: string): void;
|
|
7
|
+
end(body?: Buffer): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function dianaHandler(_req: unknown, res: UiInspectPagesResponse): void;
|
|
10
|
+
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAO7E"}
|
package/dist/pages.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pages Router API handler for Diana sprite.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { getDianaAssetPath } from '@ui-inspect/browser-ui/plugin-runtime';
|
|
6
|
+
export function dianaHandler(_req, res) {
|
|
7
|
+
const body = readFileSync(getDianaAssetPath());
|
|
8
|
+
res.statusCode = 200;
|
|
9
|
+
res.setHeader('Content-Type', 'image/webp');
|
|
10
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
11
|
+
res.end(body);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAQ1E,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,GAA2B;IACrE,MAAM,IAAI,GAAG,YAAY,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAE/C,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;IACrB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC5C,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC3C,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/script.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Script component integration for ui-inspect.
|
|
3
|
+
*/
|
|
4
|
+
import { type ReactElement } from 'react';
|
|
5
|
+
import type { UiInspectScriptProps } from './types.js';
|
|
6
|
+
export declare function UiInspectScript(options?: UiInspectScriptProps): ReactElement | null;
|
|
7
|
+
//# sourceMappingURL=script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../src/script.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAgB,eAAe,CAAC,OAAO,GAAE,oBAAyB,GAAG,YAAY,GAAG,IAAI,CAgBvF"}
|
package/dist/script.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Script component integration for ui-inspect.
|
|
3
|
+
*/
|
|
4
|
+
import { clientSource } from '@ui-inspect/browser-ui/client-source';
|
|
5
|
+
import { createElement } from 'react';
|
|
6
|
+
import Script from 'next/script';
|
|
7
|
+
const DEFAULT_DAEMON_URL = 'http://127.0.0.1:17321';
|
|
8
|
+
const DEFAULT_DIANA_SPRITE_URL = '/api/ui-inspect/diana';
|
|
9
|
+
const SCRIPT_ID = 'ui-inspect-client';
|
|
10
|
+
export function UiInspectScript(options = {}) {
|
|
11
|
+
if (options.enabled === false)
|
|
12
|
+
return null;
|
|
13
|
+
if (process.env.NODE_ENV === 'production')
|
|
14
|
+
return null;
|
|
15
|
+
const dianaSpriteUrl = options.dianaSpriteUrl ?? DEFAULT_DIANA_SPRITE_URL;
|
|
16
|
+
const source = clientSource({
|
|
17
|
+
daemonUrl: options.daemonUrl ?? DEFAULT_DAEMON_URL,
|
|
18
|
+
root: options.root ?? process.cwd(),
|
|
19
|
+
dianaSpriteUrl,
|
|
20
|
+
});
|
|
21
|
+
return createElement(Script, {
|
|
22
|
+
id: SCRIPT_ID,
|
|
23
|
+
strategy: 'afterInteractive',
|
|
24
|
+
dangerouslySetInnerHTML: { __html: source },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.js","sourceRoot":"","sources":["../src/script.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAqB,MAAM,OAAO,CAAC;AACzD,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AACpD,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AACzD,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAEtC,MAAM,UAAU,eAAe,CAAC,UAAgC,EAAE;IAChE,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC;IAEvD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,wBAAwB,CAAC;IAC1E,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,kBAAkB;QAClD,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE;QACnC,cAAc;KACf,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,MAAM,EAAE;QAC3B,EAAE,EAAE,SAAS;QACb,QAAQ,EAAE,kBAAkB;QAC5B,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;KAC5C,CAAC,CAAC;AACL,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for ui-inspect Next.js integration.
|
|
3
|
+
*/
|
|
4
|
+
export interface UiInspectNextOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Daemon URL used by the browser client.
|
|
7
|
+
* @default "http://127.0.0.1:17321"
|
|
8
|
+
*/
|
|
9
|
+
daemonUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Project root path.
|
|
12
|
+
* @default process.cwd()
|
|
13
|
+
*/
|
|
14
|
+
root?: string;
|
|
15
|
+
/**
|
|
16
|
+
* URL for the Diana sprite served by a Next route.
|
|
17
|
+
* @default "/api/ui-inspect/diana"
|
|
18
|
+
*/
|
|
19
|
+
dianaSpriteUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enable ui-inspect script injection.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type UiInspectScriptProps = UiInspectNextOptions;
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ui-inspect/next",
|
|
3
|
+
"version": "0.1.17",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./app": {
|
|
13
|
+
"types": "./dist/app.d.ts",
|
|
14
|
+
"import": "./dist/app.js"
|
|
15
|
+
},
|
|
16
|
+
"./pages": {
|
|
17
|
+
"types": "./dist/pages.d.ts",
|
|
18
|
+
"import": "./dist/pages.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"!dist/**/*.test.*",
|
|
25
|
+
"!src/**/*.test.*"
|
|
26
|
+
],
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
29
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
30
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ui-inspect/browser-ui": "0.1.17"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.6.3"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"watch": "tsc --watch"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/app.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Router route handler for Diana sprite.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { getDianaAssetPath } from '@ui-inspect/browser-ui/plugin-runtime';
|
|
7
|
+
|
|
8
|
+
export function GET(): Response {
|
|
9
|
+
const body = readFileSync(getDianaAssetPath());
|
|
10
|
+
|
|
11
|
+
return new Response(body, {
|
|
12
|
+
status: 200,
|
|
13
|
+
headers: {
|
|
14
|
+
'content-type': 'image/webp',
|
|
15
|
+
'cache-control': 'no-store',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
package/src/index.ts
ADDED
package/src/pages.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pages Router API handler for Diana sprite.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { getDianaAssetPath } from '@ui-inspect/browser-ui/plugin-runtime';
|
|
7
|
+
|
|
8
|
+
export interface UiInspectPagesResponse {
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
setHeader(name: string, value: string): void;
|
|
11
|
+
end(body?: Buffer): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function dianaHandler(_req: unknown, res: UiInspectPagesResponse): void {
|
|
15
|
+
const body = readFileSync(getDianaAssetPath());
|
|
16
|
+
|
|
17
|
+
res.statusCode = 200;
|
|
18
|
+
res.setHeader('Content-Type', 'image/webp');
|
|
19
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
20
|
+
res.end(body);
|
|
21
|
+
}
|
package/src/script.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Script component integration for ui-inspect.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { clientSource } from '@ui-inspect/browser-ui/client-source';
|
|
6
|
+
import { createElement, type ReactElement } from 'react';
|
|
7
|
+
import Script from 'next/script';
|
|
8
|
+
import type { UiInspectScriptProps } from './types.js';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DAEMON_URL = 'http://127.0.0.1:17321';
|
|
11
|
+
const DEFAULT_DIANA_SPRITE_URL = '/api/ui-inspect/diana';
|
|
12
|
+
const SCRIPT_ID = 'ui-inspect-client';
|
|
13
|
+
|
|
14
|
+
export function UiInspectScript(options: UiInspectScriptProps = {}): ReactElement | null {
|
|
15
|
+
if (options.enabled === false) return null;
|
|
16
|
+
if (process.env.NODE_ENV === 'production') return null;
|
|
17
|
+
|
|
18
|
+
const dianaSpriteUrl = options.dianaSpriteUrl ?? DEFAULT_DIANA_SPRITE_URL;
|
|
19
|
+
const source = clientSource({
|
|
20
|
+
daemonUrl: options.daemonUrl ?? DEFAULT_DAEMON_URL,
|
|
21
|
+
root: options.root ?? process.cwd(),
|
|
22
|
+
dianaSpriteUrl,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return createElement(Script, {
|
|
26
|
+
id: SCRIPT_ID,
|
|
27
|
+
strategy: 'afterInteractive',
|
|
28
|
+
dangerouslySetInnerHTML: { __html: source },
|
|
29
|
+
});
|
|
30
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for ui-inspect Next.js integration.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface UiInspectNextOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Daemon URL used by the browser client.
|
|
8
|
+
* @default "http://127.0.0.1:17321"
|
|
9
|
+
*/
|
|
10
|
+
daemonUrl?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Project root path.
|
|
14
|
+
* @default process.cwd()
|
|
15
|
+
*/
|
|
16
|
+
root?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* URL for the Diana sprite served by a Next route.
|
|
20
|
+
* @default "/api/ui-inspect/diana"
|
|
21
|
+
*/
|
|
22
|
+
dianaSpriteUrl?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Enable ui-inspect script injection.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type UiInspectScriptProps = UiInspectNextOptions;
|
package/src/vendor.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module 'react' {
|
|
2
|
+
export interface ReactElement {
|
|
3
|
+
readonly type: unknown;
|
|
4
|
+
readonly props: unknown;
|
|
5
|
+
readonly key: string | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createElement(type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]): ReactElement;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module 'next/script' {
|
|
12
|
+
import type { ReactElement } from 'react';
|
|
13
|
+
|
|
14
|
+
export interface ScriptProps {
|
|
15
|
+
id?: string;
|
|
16
|
+
strategy?: 'afterInteractive' | 'beforeInteractive' | 'lazyOnload' | 'worker';
|
|
17
|
+
dangerouslySetInnerHTML?: {
|
|
18
|
+
__html: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function Script(props: ScriptProps): ReactElement;
|
|
23
|
+
}
|