@pikku/inspector 0.12.110 → 0.12.112
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/add/add-channel.js +8 -0
- package/dist/add/add-define-contributors.d.ts +10 -0
- package/dist/add/add-define-contributors.js +98 -0
- package/dist/add/add-file-with-factory.d.ts +7 -1
- package/dist/add/add-file-with-factory.js +63 -2
- package/dist/add/add-functions.js +18 -1
- package/dist/add/add-pikku-studio.d.ts +15 -0
- package/dist/add/add-pikku-studio.js +307 -0
- package/dist/add/add-rpc-invocations.js +12 -0
- package/dist/add/add-wire-addon.js +11 -2
- package/dist/add/check-disabled-references.d.ts +27 -0
- package/dist/add/check-disabled-references.js +226 -0
- package/dist/error-codes.d.ts +14 -0
- package/dist/error-codes.js +14 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/initial-state.js +1 -0
- package/dist/inspector.js +4 -0
- package/dist/lite.d.ts +3 -0
- package/dist/lite.js +2 -0
- package/dist/types.d.ts +78 -28
- package/dist/utils/addon-dependencies.d.ts +43 -0
- package/dist/utils/addon-dependencies.js +91 -0
- package/dist/utils/find-unused-functions.d.ts +20 -0
- package/dist/utils/find-unused-functions.js +132 -0
- package/dist/utils/get-property-value.js +4 -1
- package/dist/utils/load-addon-functions-meta.d.ts +1 -8
- package/dist/utils/load-addon-functions-meta.js +87 -76
- package/dist/utils/post-process.js +31 -7
- package/dist/utils/serialize-inspector-state.d.ts +6 -3
- package/dist/utils/serialize-inspector-state.js +12 -6
- package/dist/visit.js +8 -3
- package/package.json +3 -3
- package/dist/add/add-define-screens.d.ts +0 -8
- package/dist/add/add-define-screens.js +0 -140
|
@@ -41,6 +41,9 @@ export function serializeInspectorState(state) {
|
|
|
41
41
|
files: Array.from(state.functions.files.entries()),
|
|
42
42
|
approvalDescriptions: state.functions.approvalDescriptions,
|
|
43
43
|
dynamicImportIds: Array.from(state.functions.dynamicImportIds ?? []),
|
|
44
|
+
...(Object.keys(state.functions.disabled ?? {}).length > 0
|
|
45
|
+
? { disabled: state.functions.disabled }
|
|
46
|
+
: {}),
|
|
44
47
|
},
|
|
45
48
|
http: {
|
|
46
49
|
metaInputTypes: Array.from(state.http.metaInputTypes.entries()),
|
|
@@ -191,9 +194,10 @@ export function serializeInspectorState(state) {
|
|
|
191
194
|
diagnostics: state.diagnostics,
|
|
192
195
|
addonFunctions: state.addonFunctions,
|
|
193
196
|
remoteAddonFunctions: state.remoteAddonFunctions,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
studio: state.studio,
|
|
198
|
+
addonStudio: state.addonStudio,
|
|
199
|
+
contributorsManifest: state.contributorsManifest,
|
|
200
|
+
optedInContributors: state.optedInContributors,
|
|
197
201
|
exportedContracts: state.exportedContracts,
|
|
198
202
|
};
|
|
199
203
|
}
|
|
@@ -240,6 +244,7 @@ export function deserializeInspectorState(data) {
|
|
|
240
244
|
files: new Map(data.functions.files),
|
|
241
245
|
approvalDescriptions: data.functions.approvalDescriptions || {},
|
|
242
246
|
dynamicImportIds: new Set(data.functions.dynamicImportIds ?? []),
|
|
247
|
+
disabled: data.functions.disabled ?? {},
|
|
243
248
|
},
|
|
244
249
|
http: {
|
|
245
250
|
metaInputTypes: new Map(data.http.metaInputTypes),
|
|
@@ -400,9 +405,10 @@ export function deserializeInspectorState(data) {
|
|
|
400
405
|
...(data.remoteAddonFunctions
|
|
401
406
|
? { remoteAddonFunctions: data.remoteAddonFunctions }
|
|
402
407
|
: {}),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
408
|
+
studio: data.studio,
|
|
409
|
+
addonStudio: data.addonStudio,
|
|
410
|
+
contributorsManifest: data.contributorsManifest,
|
|
411
|
+
optedInContributors: data.optedInContributors,
|
|
406
412
|
exportedContracts: data.exportedContracts || {
|
|
407
413
|
http: {},
|
|
408
414
|
cli: {},
|
package/dist/visit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { addFileWithFactory } from './add/add-file-with-factory.js';
|
|
2
|
+
import { addFileWithFactory, checkHiddenFactory, } from './add/add-file-with-factory.js';
|
|
3
3
|
import { addFileExtendsCoreType } from './add/add-file-extends-core-type.js';
|
|
4
4
|
import { addHTTPRoute } from './add/add-http-route.js';
|
|
5
5
|
import { addHTTPRoutes } from './add/add-http-routes.js';
|
|
@@ -15,7 +15,8 @@ import { addChannel } from './add/add-channel.js';
|
|
|
15
15
|
import { addGateway } from './add/add-gateway.js';
|
|
16
16
|
import { addRPCInvocations } from './add/add-rpc-invocations.js';
|
|
17
17
|
import { addWireAddon } from './add/add-wire-addon.js';
|
|
18
|
-
import {
|
|
18
|
+
import { addPikkuStudio } from './add/add-pikku-studio.js';
|
|
19
|
+
import { addDefineContributors } from './add/add-define-contributors.js';
|
|
19
20
|
import { addWireRemoteAddon } from './add/add-wire-remote-addon.js';
|
|
20
21
|
import { addMiddleware } from './add/add-middleware.js';
|
|
21
22
|
import { addPermission } from './add/add-permission.js';
|
|
@@ -36,6 +37,7 @@ import { addOutgoingWebhook } from './add/add-outgoing-webhook.js';
|
|
|
36
37
|
import { addAgentScorer } from './add/add-agent-scorer.js';
|
|
37
38
|
import { addApprovalDescription } from './add/add-approval-description.js';
|
|
38
39
|
import { checkIndirectRegistrations } from './add/check-indirect-registrations.js';
|
|
40
|
+
import { checkDisabledReferences } from './add/check-disabled-references.js';
|
|
39
41
|
export const visitSetup = (logger, checker, node, state, options) => {
|
|
40
42
|
addFileExtendsCoreType(node, checker, state.singletonServicesTypeImportMap, 'CoreSingletonServices', state);
|
|
41
43
|
addFileExtendsCoreType(node, checker, state.wireServicesTypeImportMap, 'CoreServices', state);
|
|
@@ -45,11 +47,13 @@ export const visitSetup = (logger, checker, node, state, options) => {
|
|
|
45
47
|
addFileWithFactory(node, checker, state.wireServicesFactories, 'CreateWireServices', state);
|
|
46
48
|
addFileWithFactory(node, checker, state.configFactories, 'CreateConfig');
|
|
47
49
|
addFileWithFactory(node, checker, state.serverLifecycleFactories, 'ServerLifecycle');
|
|
50
|
+
checkHiddenFactory(logger, node, state);
|
|
48
51
|
addAnalytics(logger, node, checker, state);
|
|
49
52
|
addOutgoingWebhook(logger, node, checker, state);
|
|
50
53
|
addRPCInvocations(node, state, logger);
|
|
51
54
|
addWireAddon(node, state, logger);
|
|
52
|
-
|
|
55
|
+
addPikkuStudio(node, state, logger);
|
|
56
|
+
addDefineContributors(logger, node, checker, state);
|
|
53
57
|
addWireRemoteAddon(node, state, logger);
|
|
54
58
|
addMiddleware(logger, node, checker, state, options);
|
|
55
59
|
addPermission(logger, node, checker, state, options);
|
|
@@ -100,5 +104,6 @@ export const visitRoutes = (logger, checker, node, state, options) => {
|
|
|
100
104
|
addFeature(logger, node, checker, state, nextOptions);
|
|
101
105
|
addAgent(logger, node, checker, state, nextOptions);
|
|
102
106
|
addAgentScorer(logger, node, checker, state, nextOptions);
|
|
107
|
+
checkDisabledReferences(logger, node, checker, state, nextOptions);
|
|
103
108
|
ts.forEachChild(node, (child) => visitRoutes(logger, checker, child, state, nextOptions));
|
|
104
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.112",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/pikkujs/pikku.git",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"zod": "^4.6.7"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@pikku/core": "^0.12.
|
|
73
|
+
"@pikku/core": "^0.12.148"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@pikku/core": "^0.12.
|
|
76
|
+
"@pikku/core": "^0.12.148",
|
|
77
77
|
"@types/node": "^26.6.5"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import type { InspectorState, InspectorLogger } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Detect `defineScreens({ title, icon, screens })` and record the manifest.
|
|
5
|
-
* A screen with a field that is not a literal is reported and left out: a
|
|
6
|
-
* navigation entry the host cannot read would otherwise vanish with no sign.
|
|
7
|
-
*/
|
|
8
|
-
export declare function addDefineScreens(node: ts.Node, state: InspectorState, logger: InspectorLogger): void;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import { ErrorCode } from '../error-codes.js';
|
|
3
|
-
const propName = (prop) => {
|
|
4
|
-
if (!ts.isPropertyAssignment(prop))
|
|
5
|
-
return undefined;
|
|
6
|
-
return ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name)
|
|
7
|
-
? prop.name.text
|
|
8
|
-
: undefined;
|
|
9
|
-
};
|
|
10
|
-
const stringArray = (node) => {
|
|
11
|
-
if (!ts.isArrayLiteralExpression(node))
|
|
12
|
-
return undefined;
|
|
13
|
-
const values = [];
|
|
14
|
-
for (const element of node.elements) {
|
|
15
|
-
if (!ts.isStringLiteral(element))
|
|
16
|
-
return undefined;
|
|
17
|
-
values.push(element.text);
|
|
18
|
-
}
|
|
19
|
-
return values;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The module specifier of `() => import('./screens/x')`. Anything else cannot
|
|
23
|
-
* be handed to the host's bundler as a lazy import, so it is not read.
|
|
24
|
-
*/
|
|
25
|
-
const lazyImportSpecifier = (node) => {
|
|
26
|
-
if (!ts.isArrowFunction(node))
|
|
27
|
-
return undefined;
|
|
28
|
-
const body = node.body;
|
|
29
|
-
if (!ts.isCallExpression(body) ||
|
|
30
|
-
body.expression.kind !== ts.SyntaxKind.ImportKeyword)
|
|
31
|
-
return undefined;
|
|
32
|
-
const [specifier] = body.arguments;
|
|
33
|
-
return specifier && ts.isStringLiteral(specifier) ? specifier.text : undefined;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Detect `defineScreens({ title, icon, screens })` and record the manifest.
|
|
37
|
-
* A screen with a field that is not a literal is reported and left out: a
|
|
38
|
-
* navigation entry the host cannot read would otherwise vanish with no sign.
|
|
39
|
-
*/
|
|
40
|
-
export function addDefineScreens(node, state, logger) {
|
|
41
|
-
if (!ts.isCallExpression(node))
|
|
42
|
-
return;
|
|
43
|
-
const { expression, arguments: args } = node;
|
|
44
|
-
if (!ts.isIdentifier(expression) || expression.text !== 'defineScreens')
|
|
45
|
-
return;
|
|
46
|
-
const [firstArg] = args;
|
|
47
|
-
if (!firstArg || !ts.isObjectLiteralExpression(firstArg))
|
|
48
|
-
return;
|
|
49
|
-
const fail = (message) => logger.critical(ErrorCode.ADDON_SCREENS_NOT_STATIC, message);
|
|
50
|
-
let title;
|
|
51
|
-
let icon;
|
|
52
|
-
const screens = [];
|
|
53
|
-
for (const prop of firstArg.properties) {
|
|
54
|
-
const key = propName(prop);
|
|
55
|
-
if (!key || !ts.isPropertyAssignment(prop))
|
|
56
|
-
continue;
|
|
57
|
-
if (key === 'title' && ts.isStringLiteral(prop.initializer)) {
|
|
58
|
-
title = prop.initializer.text;
|
|
59
|
-
}
|
|
60
|
-
else if (key === 'icon' && ts.isStringLiteral(prop.initializer)) {
|
|
61
|
-
icon = prop.initializer.text;
|
|
62
|
-
}
|
|
63
|
-
else if (key === 'screens') {
|
|
64
|
-
if (!ts.isArrayLiteralExpression(prop.initializer)) {
|
|
65
|
-
fail(`defineScreens's screens must be an array literal, got: ${prop.initializer.getText()}`);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
for (const element of prop.initializer.elements) {
|
|
69
|
-
if (!ts.isObjectLiteralExpression(element)) {
|
|
70
|
-
fail(`A defineScreens screen must be an object literal, got: ${element.getText()}`);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
let path;
|
|
74
|
-
let screenTitle;
|
|
75
|
-
let nav;
|
|
76
|
-
let scopes;
|
|
77
|
-
let component;
|
|
78
|
-
let app;
|
|
79
|
-
for (const field of element.properties) {
|
|
80
|
-
const fieldKey = propName(field);
|
|
81
|
-
if (!fieldKey || !ts.isPropertyAssignment(field))
|
|
82
|
-
continue;
|
|
83
|
-
const value = field.initializer;
|
|
84
|
-
if (fieldKey === 'path' && ts.isStringLiteral(value)) {
|
|
85
|
-
path = value.text;
|
|
86
|
-
}
|
|
87
|
-
else if (fieldKey === 'title' && ts.isStringLiteral(value)) {
|
|
88
|
-
screenTitle = value.text;
|
|
89
|
-
}
|
|
90
|
-
else if (fieldKey === 'nav' &&
|
|
91
|
-
(value.kind === ts.SyntaxKind.TrueKeyword ||
|
|
92
|
-
value.kind === ts.SyntaxKind.FalseKeyword)) {
|
|
93
|
-
nav = value.kind === ts.SyntaxKind.TrueKeyword;
|
|
94
|
-
}
|
|
95
|
-
else if (fieldKey === 'scopes') {
|
|
96
|
-
scopes = stringArray(value);
|
|
97
|
-
if (!scopes) {
|
|
98
|
-
fail(`A screen's scopes must be an array of string literals, got: ${value.getText()}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else if (fieldKey === 'component') {
|
|
102
|
-
component = lazyImportSpecifier(value);
|
|
103
|
-
if (!component) {
|
|
104
|
-
fail(`A screen's component must be () => import('<literal>'), got: ${value.getText()}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (fieldKey === 'app' && ts.isStringLiteral(value)) {
|
|
108
|
-
app = value.text;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (!path || !screenTitle || (!component && !app)) {
|
|
112
|
-
fail(`A defineScreens screen needs a literal path and title, and either a lazy component or an app: ${element.getText()}`);
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (component && app) {
|
|
116
|
-
fail(`Screen '${path}' sets both component and app; a screen is one or the other`);
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
screens.push({
|
|
120
|
-
path,
|
|
121
|
-
title: screenTitle,
|
|
122
|
-
...(nav !== undefined ? { nav } : {}),
|
|
123
|
-
...(scopes ? { scopes } : {}),
|
|
124
|
-
...(component ? { component } : { app: app }),
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (!title) {
|
|
130
|
-
fail(`defineScreens needs a literal title`);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
logger.debug(`• Found defineScreens: ${title} (${screens.length} screens)`);
|
|
134
|
-
state.screensManifest = {
|
|
135
|
-
title,
|
|
136
|
-
...(icon ? { icon } : {}),
|
|
137
|
-
file: node.getSourceFile().fileName,
|
|
138
|
-
screens,
|
|
139
|
-
};
|
|
140
|
-
}
|