@apollo/client-ai-apps 0.3.2 → 0.3.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.
- package/.github/workflows/pr.yaml +52 -3
- package/.github/workflows/prep-release.yml +38 -0
- package/.github/workflows/release.yaml +8 -4
- package/.github/workflows/verify-changeset.yml +58 -0
- package/CHANGELOG.md +25 -0
- package/dist/core/ApolloClient.d.ts +3 -2
- package/dist/core/ApolloClient.d.ts.map +1 -0
- package/dist/core/ApolloClient.js +65 -0
- package/dist/core/ApolloClient.js.map +1 -0
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -278
- package/dist/index.js.map +1 -0
- package/dist/link/ToolCallLink.d.ts +1 -0
- package/dist/link/ToolCallLink.d.ts.map +1 -0
- package/dist/link/ToolCallLink.js +39 -0
- package/dist/link/ToolCallLink.js.map +1 -0
- package/dist/react/ApolloProvider.d.ts +4 -3
- package/dist/react/ApolloProvider.d.ts.map +1 -0
- package/dist/react/ApolloProvider.js +30 -0
- package/dist/react/ApolloProvider.js.map +1 -0
- package/dist/react/context/ToolUseContext.d.ts +4 -3
- package/dist/react/context/ToolUseContext.d.ts.map +1 -0
- package/dist/react/context/ToolUseContext.js +11 -0
- package/dist/react/context/ToolUseContext.js.map +1 -0
- package/dist/react/hooks/useCallTool.d.ts +4 -0
- package/dist/react/hooks/useCallTool.d.ts.map +1 -0
- package/dist/react/hooks/useCallTool.js +5 -0
- package/dist/react/hooks/useCallTool.js.map +1 -0
- package/dist/react/hooks/useOpenAiGlobal.d.ts +2 -1
- package/dist/react/hooks/useOpenAiGlobal.d.ts.map +1 -0
- package/dist/react/hooks/useOpenAiGlobal.js +20 -0
- package/dist/react/hooks/useOpenAiGlobal.js.map +1 -0
- package/dist/react/hooks/useOpenExternal.d.ts +1 -0
- package/dist/react/hooks/useOpenExternal.d.ts.map +1 -0
- package/dist/react/hooks/useOpenExternal.js +5 -0
- package/dist/react/hooks/useOpenExternal.js.map +1 -0
- package/dist/react/hooks/useRequestDisplayMode.d.ts +2 -1
- package/dist/react/hooks/useRequestDisplayMode.d.ts.map +1 -0
- package/dist/react/hooks/useRequestDisplayMode.js +6 -0
- package/dist/react/hooks/useRequestDisplayMode.js.map +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.d.ts +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.d.ts.map +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.js +8 -0
- package/dist/react/hooks/useSendFollowUpMessage.js.map +1 -0
- package/dist/react/hooks/useToolEffect.d.ts +1 -0
- package/dist/react/hooks/useToolEffect.d.ts.map +1 -0
- package/dist/react/hooks/useToolEffect.js +28 -0
- package/dist/react/hooks/useToolEffect.js.map +1 -0
- package/dist/react/hooks/useToolInput.d.ts +1 -0
- package/dist/react/hooks/useToolInput.d.ts.map +1 -0
- package/dist/react/hooks/useToolInput.js +6 -0
- package/dist/react/hooks/useToolInput.js.map +1 -0
- package/dist/react/hooks/useToolName.d.ts +1 -0
- package/dist/react/hooks/useToolName.d.ts.map +1 -0
- package/dist/react/hooks/useToolName.js +6 -0
- package/dist/react/hooks/useToolName.js.map +1 -0
- package/dist/react/hooks/useToolOutput.d.ts +2 -1
- package/dist/react/hooks/useToolOutput.d.ts.map +1 -0
- package/dist/react/hooks/useToolOutput.js +5 -0
- package/dist/react/hooks/useToolOutput.js.map +1 -0
- package/dist/react/hooks/useToolResponseMetadata.d.ts +2 -1
- package/dist/react/hooks/useToolResponseMetadata.d.ts.map +1 -0
- package/dist/react/hooks/useToolResponseMetadata.js +5 -0
- package/dist/react/hooks/useToolResponseMetadata.js.map +1 -0
- package/dist/react/hooks/useWidgetState.d.ts +3 -2
- package/dist/react/hooks/useWidgetState.d.ts.map +1 -0
- package/dist/react/hooks/useWidgetState.js +27 -0
- package/dist/react/hooks/useWidgetState.js.map +1 -0
- package/dist/types/application-manifest.d.ts +7 -0
- package/dist/types/application-manifest.d.ts.map +1 -0
- package/dist/types/application-manifest.js +2 -0
- package/dist/types/application-manifest.js.map +1 -0
- package/dist/types/openai.d.ts +1 -0
- package/dist/types/openai.d.ts.map +1 -0
- package/dist/types/openai.js +6 -0
- package/dist/types/openai.js.map +1 -0
- package/dist/vite/absolute_asset_imports_plugin.d.ts +1 -0
- package/dist/vite/absolute_asset_imports_plugin.d.ts.map +1 -0
- package/dist/vite/absolute_asset_imports_plugin.js +17 -0
- package/dist/vite/absolute_asset_imports_plugin.js.map +1 -0
- package/dist/vite/application_manifest_plugin.d.ts +2 -1
- package/dist/vite/application_manifest_plugin.d.ts.map +1 -0
- package/dist/vite/application_manifest_plugin.js +274 -0
- package/dist/vite/application_manifest_plugin.js.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +3 -307
- package/dist/vite/index.js.map +1 -0
- package/knope.toml +63 -0
- package/package.json +15 -8
- package/src/core/ApolloClient.ts +10 -5
- package/src/core/__tests__/ApolloClient.test.ts +12 -9
- package/src/index.ts +17 -17
- package/src/react/ApolloProvider.tsx +4 -3
- package/src/react/__tests__/ApolloProvider.test.tsx +3 -3
- package/src/react/context/ToolUseContext.tsx +2 -1
- package/src/react/hooks/__tests__/useCallTool.test.ts +1 -1
- package/src/react/hooks/__tests__/useOpenAiGlobal.test.ts +6 -6
- package/src/react/hooks/__tests__/useOpenExternal.test.tsx +2 -2
- package/src/react/hooks/__tests__/useRequestDisplayMode.test.ts +2 -2
- package/src/react/hooks/__tests__/useSendFollowUpMessage.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolEffect.test.tsx +2 -2
- package/src/react/hooks/__tests__/useToolInput.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolName.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolOutput.test.tsx +2 -2
- package/src/react/hooks/__tests__/useToolResponseMetadata.test.tsx +2 -2
- package/src/react/hooks/__tests__/useWidgetState.test.tsx +2 -2
- package/src/react/hooks/useOpenAiGlobal.ts +2 -5
- package/src/react/hooks/useOpenExternal.ts +1 -1
- package/src/react/hooks/useRequestDisplayMode.ts +1 -1
- package/src/react/hooks/useToolEffect.tsx +3 -3
- package/src/react/hooks/useToolInput.ts +1 -1
- package/src/react/hooks/useToolName.ts +1 -1
- package/src/react/hooks/useToolOutput.ts +1 -1
- package/src/react/hooks/useToolResponseMetadata.ts +1 -1
- package/src/react/hooks/useWidgetState.ts +4 -3
- package/src/testing/internal/index.ts +2 -2
- package/src/testing/internal/matchers/index.ts +1 -1
- package/src/testing/internal/matchers/toRerender.ts +2 -2
- package/src/testing/internal/matchers/{index.d.ts → types.ts} +1 -1
- package/src/testing/internal/openai/dispatchStateChange.ts +1 -1
- package/src/testing/internal/openai/stubOpenAiGlobals.ts +6 -2
- package/src/types/application-manifest.ts +7 -0
- package/src/vite/__tests__/absolute_asset_imports_plugin.test.ts +2 -2
- package/src/vite/__tests__/application_manifest_plugin.test.ts +299 -240
- package/src/vite/application_manifest_plugin.ts +160 -96
- package/src/vite/index.ts +2 -2
- package/tsconfig.base.build.json +13 -0
- package/tsconfig.base.json +21 -0
- package/tsconfig.config.json +9 -0
- package/tsconfig.json +10 -0
- package/tsconfig.src.build.json +14 -0
- package/tsconfig.src.json +17 -0
- package/tsconfig.test.json +20 -0
- package/tsconfig.vite.build.json +6 -0
- package/tsconfig.vite.json +16 -0
- package/scripts/build-vite.mjs +0 -18
- package/scripts/build.mjs +0 -7
- package/scripts/shared.mjs +0 -9
|
@@ -2,27 +2,32 @@ import { readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
|
2
2
|
import { glob } from "glob";
|
|
3
3
|
import { gqlPluckFromCodeStringSync } from "@graphql-tools/graphql-tag-pluck";
|
|
4
4
|
import { createHash } from "crypto";
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
6
|
ArgumentNode,
|
|
7
|
-
Kind,
|
|
8
7
|
ListTypeNode,
|
|
9
8
|
NamedTypeNode,
|
|
10
9
|
NonNullTypeNode,
|
|
11
|
-
parse,
|
|
12
|
-
print,
|
|
13
10
|
TypeNode,
|
|
14
11
|
ValueNode,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
DocumentNode,
|
|
13
|
+
OperationDefinitionNode,
|
|
14
|
+
DirectiveNode,
|
|
18
15
|
} from "graphql";
|
|
16
|
+
import { Kind, parse, print } from "graphql";
|
|
19
17
|
import { ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client";
|
|
20
|
-
import
|
|
18
|
+
import { removeDirectivesFromDocument } from "@apollo/client/utilities/internal";
|
|
19
|
+
import { of } from "rxjs";
|
|
21
20
|
import path from "path";
|
|
21
|
+
import type {
|
|
22
|
+
ApplicationManifest,
|
|
23
|
+
ManifestExtraInput,
|
|
24
|
+
ManifestTool,
|
|
25
|
+
ManifestWidgetSettings,
|
|
26
|
+
} from "../types/application-manifest.js";
|
|
22
27
|
|
|
23
28
|
const root = process.cwd();
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
function getRawValue(node: ValueNode): unknown {
|
|
26
31
|
switch (node.kind) {
|
|
27
32
|
case Kind.STRING:
|
|
28
33
|
case Kind.BOOLEAN:
|
|
@@ -39,33 +44,71 @@ const getRawValue = (node: ValueNode): any => {
|
|
|
39
44
|
`Error when parsing directive values: unexpected type '${node.kind}'`
|
|
40
45
|
);
|
|
41
46
|
}
|
|
42
|
-
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getArgumentValue(
|
|
50
|
+
argument: ArgumentNode,
|
|
51
|
+
expectedType: Kind.STRING
|
|
52
|
+
): string;
|
|
53
|
+
|
|
54
|
+
function getArgumentValue(
|
|
55
|
+
argument: ArgumentNode,
|
|
56
|
+
expectedType: Kind.BOOLEAN
|
|
57
|
+
): boolean;
|
|
58
|
+
|
|
59
|
+
function getArgumentValue(
|
|
60
|
+
argument: ArgumentNode,
|
|
61
|
+
expectedType: Kind.LIST
|
|
62
|
+
): unknown[];
|
|
43
63
|
|
|
44
|
-
|
|
64
|
+
function getArgumentValue(
|
|
65
|
+
argument: ArgumentNode,
|
|
66
|
+
expectedType: Kind.OBJECT
|
|
67
|
+
): Record<string, unknown>;
|
|
68
|
+
|
|
69
|
+
function getArgumentValue(argument: ArgumentNode, expectedType: Kind) {
|
|
70
|
+
const argumentType = argument.value.kind;
|
|
71
|
+
|
|
72
|
+
invariant(
|
|
73
|
+
argumentType === expectedType,
|
|
74
|
+
`Expected argument '${argument.name.value}' to be of type '${expectedType}' but found '${argumentType}' instead.`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return getRawValue(argument.value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface GetArgumentNodeOptions {
|
|
81
|
+
required?: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getDirectiveArgument(
|
|
45
85
|
argumentName: string,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
if (!directiveArguments || directiveArguments.length === 0) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
86
|
+
directive: DirectiveNode,
|
|
87
|
+
opts: GetArgumentNodeOptions & { required: true }
|
|
88
|
+
): ArgumentNode;
|
|
52
89
|
|
|
53
|
-
|
|
90
|
+
function getDirectiveArgument(
|
|
91
|
+
argumentName: string,
|
|
92
|
+
directive: DirectiveNode,
|
|
93
|
+
opts?: GetArgumentNodeOptions
|
|
94
|
+
): ArgumentNode | undefined;
|
|
95
|
+
|
|
96
|
+
function getDirectiveArgument(
|
|
97
|
+
argumentName: string,
|
|
98
|
+
directive: DirectiveNode,
|
|
99
|
+
{ required = false }: { required?: boolean } = {}
|
|
100
|
+
) {
|
|
101
|
+
const argument = directive.arguments?.find(
|
|
54
102
|
(directiveArgument) => directiveArgument.name.value === argumentName
|
|
55
103
|
);
|
|
56
104
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (argument.value.kind != expectedType) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Expected argument '${argumentName}' to be of type '${expectedType}' but found '${argument.value.kind}' instead.`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
105
|
+
invariant(
|
|
106
|
+
argument || !required,
|
|
107
|
+
`'${argumentName}' argument must be supplied for @tool`
|
|
108
|
+
);
|
|
66
109
|
|
|
67
|
-
return
|
|
68
|
-
}
|
|
110
|
+
return argument;
|
|
111
|
+
}
|
|
69
112
|
|
|
70
113
|
function getTypeName(type: TypeNode): string {
|
|
71
114
|
let t = type;
|
|
@@ -88,78 +131,73 @@ export const ApplicationManifestPlugin = () => {
|
|
|
88
131
|
removeClientDirective(sortTopLevelDefinitions(operation.query))
|
|
89
132
|
);
|
|
90
133
|
const name = operation.operationName;
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
134
|
+
const definition = operation.query.definitions.find(
|
|
135
|
+
(d) => d.kind === "OperationDefinition"
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Use `operation.query` so that the error reflects the end-user defined
|
|
139
|
+
// document, not our sorted one
|
|
140
|
+
invariant(
|
|
141
|
+
definition,
|
|
142
|
+
`Document does not contain an operation:\n${print(operation.query)}`
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const { directives, operation: type } = definition;
|
|
146
|
+
|
|
147
|
+
const variables = definition.variableDefinitions?.reduce(
|
|
96
148
|
(obj, varDef) => ({
|
|
97
149
|
...obj,
|
|
98
150
|
[varDef.variable.name.value]: getTypeName(varDef.type),
|
|
99
151
|
}),
|
|
100
152
|
{}
|
|
101
153
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(d) => d.kind === "OperationDefinition"
|
|
105
|
-
) as OperationDefinitionNode
|
|
106
|
-
).operation;
|
|
107
|
-
const prefetch = (
|
|
108
|
-
operation.query.definitions.find(
|
|
109
|
-
(d) => d.kind === "OperationDefinition"
|
|
110
|
-
) as OperationDefinitionNode
|
|
111
|
-
).directives?.some((d) => d.name.value === "prefetch");
|
|
154
|
+
|
|
155
|
+
const prefetch = directives?.some((d) => d.name.value === "prefetch");
|
|
112
156
|
const id = createHash("sha256").update(body).digest("hex");
|
|
113
157
|
// TODO: For now, you can only have 1 operation marked as prefetch. In the future, we'll likely support more than 1, and the "prefetchId" will be defined on the `@prefetch` itself as an argument
|
|
114
158
|
const prefetchID = prefetch ? "__anonymous" : undefined;
|
|
115
159
|
|
|
116
|
-
const tools =
|
|
117
|
-
operation.query.definitions.find(
|
|
118
|
-
(d) => d.kind === "OperationDefinition"
|
|
119
|
-
) as OperationDefinitionNode
|
|
120
|
-
).directives
|
|
160
|
+
const tools = directives
|
|
121
161
|
?.filter((d) => d.name.value === "tool")
|
|
122
162
|
.map((directive) => {
|
|
123
|
-
const name =
|
|
124
|
-
"name",
|
|
125
|
-
Kind.STRING
|
|
126
|
-
directive.arguments
|
|
127
|
-
);
|
|
128
|
-
const description = getTypedDirectiveArgument(
|
|
129
|
-
"description",
|
|
130
|
-
Kind.STRING,
|
|
131
|
-
directive.arguments
|
|
132
|
-
);
|
|
133
|
-
const extraInputs = getTypedDirectiveArgument(
|
|
134
|
-
"extraInputs",
|
|
135
|
-
Kind.LIST,
|
|
136
|
-
directive.arguments
|
|
163
|
+
const name = getArgumentValue(
|
|
164
|
+
getDirectiveArgument("name", directive, { required: true }),
|
|
165
|
+
Kind.STRING
|
|
137
166
|
);
|
|
138
167
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
invariant(
|
|
169
|
+
name.indexOf(" ") === -1,
|
|
170
|
+
`Tool with name "${name}" contains spaces which is not allowed.`
|
|
171
|
+
);
|
|
142
172
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
173
|
+
const description = getArgumentValue(
|
|
174
|
+
getDirectiveArgument("description", directive, { required: true }),
|
|
175
|
+
Kind.STRING
|
|
176
|
+
);
|
|
148
177
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
178
|
+
const extraInputsNode = getDirectiveArgument(
|
|
179
|
+
"extraInputs",
|
|
180
|
+
directive
|
|
181
|
+
);
|
|
154
182
|
|
|
155
|
-
|
|
183
|
+
const toolOptions: ManifestTool = {
|
|
156
184
|
name,
|
|
157
185
|
description,
|
|
158
|
-
extraInputs,
|
|
159
186
|
};
|
|
187
|
+
|
|
188
|
+
if (extraInputsNode) {
|
|
189
|
+
toolOptions.extraInputs = getArgumentValue(
|
|
190
|
+
extraInputsNode,
|
|
191
|
+
Kind.LIST
|
|
192
|
+
) as ManifestExtraInput[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return toolOptions;
|
|
160
196
|
});
|
|
161
197
|
|
|
162
|
-
|
|
198
|
+
// TODO: Make this object satisfy the `ManifestOperation` type. Currently
|
|
199
|
+
// it errors because we need more validation on a few of these fields
|
|
200
|
+
return of({
|
|
163
201
|
data: { id, name, type, body, variables, prefetch, prefetchID, tools },
|
|
164
202
|
});
|
|
165
203
|
}),
|
|
@@ -172,7 +210,7 @@ export const ApplicationManifestPlugin = () => {
|
|
|
172
210
|
|
|
173
211
|
const fileHash = createHash("md5").update(code).digest("hex");
|
|
174
212
|
if (cache.get("file")?.hash === fileHash) return;
|
|
175
|
-
const sources =
|
|
213
|
+
const sources = gqlPluckFromCodeStringSync(file, code, {
|
|
176
214
|
modules: [
|
|
177
215
|
{ name: "graphql-tag", identifier: "gql" },
|
|
178
216
|
{ name: "@apollo/client", identifier: "gql" },
|
|
@@ -221,11 +259,11 @@ export const ApplicationManifestPlugin = () => {
|
|
|
221
259
|
const operations = Array.from(cache.values()).flatMap(
|
|
222
260
|
(entry) => entry.operations
|
|
223
261
|
);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
262
|
+
|
|
263
|
+
invariant(
|
|
264
|
+
operations.filter((o) => o.prefetch).length <= 1,
|
|
265
|
+
"Found multiple operations marked as `@prefetch`. You can only mark 1 operation with `@prefetch`."
|
|
266
|
+
);
|
|
229
267
|
|
|
230
268
|
let resource = "";
|
|
231
269
|
if (config.command === "serve") {
|
|
@@ -245,7 +283,7 @@ export const ApplicationManifestPlugin = () => {
|
|
|
245
283
|
}
|
|
246
284
|
}
|
|
247
285
|
|
|
248
|
-
const manifest = {
|
|
286
|
+
const manifest: ApplicationManifest = {
|
|
249
287
|
format: "apollo-ai-app-manifest",
|
|
250
288
|
version: "1",
|
|
251
289
|
name: packageJson.name,
|
|
@@ -261,6 +299,32 @@ export const ApplicationManifestPlugin = () => {
|
|
|
261
299
|
},
|
|
262
300
|
};
|
|
263
301
|
|
|
302
|
+
if (
|
|
303
|
+
packageJson.widgetSettings &&
|
|
304
|
+
Object.keys(packageJson.widgetSettings).length > 0
|
|
305
|
+
) {
|
|
306
|
+
function validateWidgetSetting(
|
|
307
|
+
key: keyof ManifestWidgetSettings,
|
|
308
|
+
type: "string" | "boolean"
|
|
309
|
+
) {
|
|
310
|
+
if (key in widgetSettings) {
|
|
311
|
+
invariant(
|
|
312
|
+
typeof widgetSettings[key] === type,
|
|
313
|
+
`Expected 'widgetSettings.${key}' to be of type '${type}' but found '${typeof widgetSettings[key]}' instead.`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const widgetSettings =
|
|
319
|
+
packageJson.widgetSettings as ManifestWidgetSettings;
|
|
320
|
+
|
|
321
|
+
validateWidgetSetting("prefersBorder", "boolean");
|
|
322
|
+
validateWidgetSetting("description", "string");
|
|
323
|
+
validateWidgetSetting("domain", "string");
|
|
324
|
+
|
|
325
|
+
manifest.widgetSettings = packageJson.widgetSettings;
|
|
326
|
+
}
|
|
327
|
+
|
|
264
328
|
// Always write to build directory so the MCP server picks it up
|
|
265
329
|
const dest = path.resolve(
|
|
266
330
|
root,
|
|
@@ -366,14 +430,14 @@ export function sortTopLevelDefinitions(query: DocumentNode): DocumentNode {
|
|
|
366
430
|
}
|
|
367
431
|
|
|
368
432
|
function removeClientDirective(doc: DocumentNode) {
|
|
369
|
-
return
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
433
|
+
return removeDirectivesFromDocument(
|
|
434
|
+
[{ name: "prefetch" }, { name: "tool" }],
|
|
435
|
+
doc
|
|
436
|
+
)!;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function invariant(condition: any, message: string): asserts condition {
|
|
440
|
+
if (!condition) {
|
|
441
|
+
throw new Error(message);
|
|
442
|
+
}
|
|
379
443
|
}
|
package/src/vite/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./application_manifest_plugin";
|
|
2
|
-
export * from "./absolute_asset_imports_plugin";
|
|
1
|
+
export * from "./application_manifest_plugin.js";
|
|
2
|
+
export * from "./absolute_asset_imports_plugin.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"noEmit": false,
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"inlineSources": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"module": "nodenext",
|
|
6
|
+
"moduleResolution": "nodenext",
|
|
7
|
+
"target": "esnext",
|
|
8
|
+
"lib": ["esnext"],
|
|
9
|
+
"exactOptionalPropertyTypes": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"jsx": "react-jsx",
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"importHelpers": true,
|
|
15
|
+
"noUncheckedSideEffectImports": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"moduleDetection": "force",
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"esModuleInterop": true
|
|
20
|
+
}
|
|
21
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.build.json",
|
|
4
|
+
"include": ["./src"],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"./src/**/*.test.ts",
|
|
7
|
+
"./src/**/*.test.tsx",
|
|
8
|
+
"./src/vite/",
|
|
9
|
+
"./src/testing/internal/"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"lib": ["DOM"]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"include": ["./src"],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"./src/**/*.test.ts",
|
|
7
|
+
"./src/**/*.test.tsx",
|
|
8
|
+
"./src/vite/",
|
|
9
|
+
"./src/testing/internal/"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"rootDir": "src",
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"composite": true,
|
|
15
|
+
"lib": ["dom", "esnext"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"include": [
|
|
5
|
+
"./src/**/*.test.ts",
|
|
6
|
+
"./src/**/*.test.tsx",
|
|
7
|
+
"./src/testing/internal/"
|
|
8
|
+
],
|
|
9
|
+
"references": [
|
|
10
|
+
{ "path": "./tsconfig.src.json" },
|
|
11
|
+
{ "path": "./tsconfig.vite.json" }
|
|
12
|
+
],
|
|
13
|
+
"compilerOptions": {
|
|
14
|
+
"rootDir": "src",
|
|
15
|
+
"outDir": "dist",
|
|
16
|
+
"composite": true,
|
|
17
|
+
"lib": ["dom", "esnext"],
|
|
18
|
+
"types": ["node"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"include": ["./src/vite", "./src/types/application-manifest.ts"],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"./src/**/*.test.ts",
|
|
7
|
+
"./src/**/*.test.tsx",
|
|
8
|
+
"./src/testing/internal/"
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"rootDir": "src",
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"lib": ["esnext"],
|
|
14
|
+
"composite": true
|
|
15
|
+
}
|
|
16
|
+
}
|
package/scripts/build-vite.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as esbuild from "esbuild";
|
|
2
|
-
|
|
3
|
-
// Separately build Vite plugin
|
|
4
|
-
await esbuild.build({
|
|
5
|
-
entryPoints: ["src/vite/index.ts"],
|
|
6
|
-
bundle: true,
|
|
7
|
-
outdir: "dist/vite",
|
|
8
|
-
platform: "node",
|
|
9
|
-
format: "esm",
|
|
10
|
-
external: [
|
|
11
|
-
"glob",
|
|
12
|
-
"@graphql-tools/graphql-tag-pluck",
|
|
13
|
-
"@graphql-tools/graphql-tag-pluck",
|
|
14
|
-
"graphql",
|
|
15
|
-
"@apollo/client",
|
|
16
|
-
"rxjs",
|
|
17
|
-
],
|
|
18
|
-
});
|
package/scripts/build.mjs
DELETED