@copilotkit/react-core 0.8.0-alpha.3 → 0.8.0-alpha.5
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/.turbo/turbo-build.log +49 -45
- package/CHANGELOG.md +12 -0
- package/dist/components/copilot-provider.d.ts +7 -1
- package/dist/components/copilot-provider.mjs +340 -5
- package/dist/components/copilot-provider.mjs.map +1 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.mjs +340 -6
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/copilot-context.d.ts +8 -1
- package/dist/context/copilot-context.mjs +63 -3
- package/dist/context/copilot-context.mjs.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.mjs +63 -4
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.mjs +199 -7
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +155 -4
- package/dist/hooks/use-copilot-chat.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-actionable.mjs +84 -4
- package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-readable.mjs +73 -4
- package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
- package/dist/hooks/use-tree.mjs +159 -3
- package/dist/hooks/use-tree.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +470 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/annotated-function.mjs +0 -2
- package/dist/types/annotated-function.mjs.map +1 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/utils.mjs +0 -2
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.test.mjs +0 -1
- package/dist/utils/utils.test.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/copilot-provider.tsx +5 -1
- package/src/context/copilot-context.tsx +23 -0
- package/src/context/index.ts +2 -0
- package/src/hooks/use-copilot-chat.ts +4 -4
- package/dist/chunk-3BOHSSKR.mjs +0 -141
- package/dist/chunk-3BOHSSKR.mjs.map +0 -1
- package/dist/chunk-547TMALJ.mjs +0 -80
- package/dist/chunk-547TMALJ.mjs.map +0 -1
- package/dist/chunk-6CBAEPMO.mjs +0 -26
- package/dist/chunk-6CBAEPMO.mjs.map +0 -1
- package/dist/chunk-BVQRDAR7.mjs +0 -3
- package/dist/chunk-BVQRDAR7.mjs.map +0 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -3
- package/dist/chunk-EFZPSZWO.mjs.map +0 -1
- package/dist/chunk-FCFGH4M4.mjs +0 -118
- package/dist/chunk-FCFGH4M4.mjs.map +0 -1
- package/dist/chunk-H23NBUJ7.mjs +0 -30
- package/dist/chunk-H23NBUJ7.mjs.map +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -3
- package/dist/chunk-JD7BAH7U.mjs.map +0 -1
- package/dist/chunk-KQACBBGH.mjs +0 -19
- package/dist/chunk-KQACBBGH.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-VNRDQJXW.mjs +0 -3
- package/dist/chunk-VNRDQJXW.mjs.map +0 -1
package/dist/chunk-FCFGH4M4.mjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { use_tree_default } from './chunk-3BOHSSKR.mjs';
|
|
2
|
-
import { CopilotContext } from './chunk-6CBAEPMO.mjs';
|
|
3
|
-
import { __spreadProps, __spreadValues, __async, __objRest } from './chunk-MRXNTQOX.mjs';
|
|
4
|
-
import { useState, useCallback } from 'react';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
function CopilotProvider({
|
|
8
|
-
children
|
|
9
|
-
}) {
|
|
10
|
-
const [entryPoints, setEntryPoints] = useState({});
|
|
11
|
-
const { addElement, removeElement, printTree } = use_tree_default();
|
|
12
|
-
const setEntryPoint = useCallback(
|
|
13
|
-
(id, entryPoint) => {
|
|
14
|
-
setEntryPoints((prevPoints) => {
|
|
15
|
-
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
16
|
-
[id]: entryPoint
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
[]
|
|
21
|
-
);
|
|
22
|
-
const removeEntryPoint = useCallback((id) => {
|
|
23
|
-
setEntryPoints((prevPoints) => {
|
|
24
|
-
const newPoints = __spreadValues({}, prevPoints);
|
|
25
|
-
delete newPoints[id];
|
|
26
|
-
return newPoints;
|
|
27
|
-
});
|
|
28
|
-
}, []);
|
|
29
|
-
const getContextString = useCallback(
|
|
30
|
-
(categories = ["global"]) => {
|
|
31
|
-
return printTree(categories);
|
|
32
|
-
},
|
|
33
|
-
[printTree]
|
|
34
|
-
);
|
|
35
|
-
const addContext = useCallback(
|
|
36
|
-
(context, parentId, categories = ["global"]) => {
|
|
37
|
-
return addElement(context, categories, parentId);
|
|
38
|
-
},
|
|
39
|
-
[addElement]
|
|
40
|
-
);
|
|
41
|
-
const removeContext = useCallback(
|
|
42
|
-
(id) => {
|
|
43
|
-
removeElement(id);
|
|
44
|
-
},
|
|
45
|
-
[removeElement]
|
|
46
|
-
);
|
|
47
|
-
const getChatCompletionFunctionDescriptions = useCallback(() => {
|
|
48
|
-
return entryPointsToChatCompletionFunctions(Object.values(entryPoints));
|
|
49
|
-
}, [entryPoints]);
|
|
50
|
-
const getFunctionCallHandler = useCallback(() => {
|
|
51
|
-
return entryPointsToFunctionCallHandler(Object.values(entryPoints));
|
|
52
|
-
}, [entryPoints]);
|
|
53
|
-
return /* @__PURE__ */ jsx(CopilotContext.Provider, {
|
|
54
|
-
value: {
|
|
55
|
-
entryPoints,
|
|
56
|
-
getChatCompletionFunctionDescriptions,
|
|
57
|
-
getFunctionCallHandler,
|
|
58
|
-
setEntryPoint,
|
|
59
|
-
removeEntryPoint,
|
|
60
|
-
getContextString,
|
|
61
|
-
addContext,
|
|
62
|
-
removeContext
|
|
63
|
-
},
|
|
64
|
-
children
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
function entryPointsToFunctionCallHandler(entryPoints) {
|
|
68
|
-
return (chatMessages, functionCall) => __async(this, null, function* () {
|
|
69
|
-
let entrypointsByFunctionName = {};
|
|
70
|
-
for (let entryPoint of entryPoints) {
|
|
71
|
-
entrypointsByFunctionName[entryPoint.name] = entryPoint;
|
|
72
|
-
}
|
|
73
|
-
const entryPointFunction = entrypointsByFunctionName[functionCall.name || ""];
|
|
74
|
-
if (entryPointFunction) {
|
|
75
|
-
let parsedFunctionCallArguments = [];
|
|
76
|
-
if (functionCall.arguments) {
|
|
77
|
-
parsedFunctionCallArguments = JSON.parse(functionCall.arguments);
|
|
78
|
-
}
|
|
79
|
-
const paramsInCorrectOrder = [];
|
|
80
|
-
for (let arg of entryPointFunction.argumentAnnotations) {
|
|
81
|
-
paramsInCorrectOrder.push(
|
|
82
|
-
parsedFunctionCallArguments[arg.name]
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
yield entryPointFunction.implementation(...paramsInCorrectOrder);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function entryPointsToChatCompletionFunctions(entryPoints) {
|
|
90
|
-
return entryPoints.map(annotatedFunctionToChatCompletionFunction);
|
|
91
|
-
}
|
|
92
|
-
function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
93
|
-
let parameters = {};
|
|
94
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
95
|
-
let _a = arg, forwardedArgs = __objRest(_a, ["name", "required"]);
|
|
96
|
-
parameters[arg.name] = forwardedArgs;
|
|
97
|
-
}
|
|
98
|
-
let requiredParameterNames = [];
|
|
99
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
100
|
-
if (arg.required) {
|
|
101
|
-
requiredParameterNames.push(arg.name);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
let chatCompletionFunction = {
|
|
105
|
-
name: annotatedFunction.name,
|
|
106
|
-
description: annotatedFunction.description,
|
|
107
|
-
parameters: {
|
|
108
|
-
type: "object",
|
|
109
|
-
properties: parameters,
|
|
110
|
-
required: requiredParameterNames
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
return chatCompletionFunction;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { CopilotProvider };
|
|
117
|
-
//# sourceMappingURL=out.js.map
|
|
118
|
-
//# sourceMappingURL=chunk-FCFGH4M4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/copilot-provider.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\nimport { FunctionCallHandler } from \"ai\";\nimport { ReactNode, useCallback, useState } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport useTree from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport function CopilotProvider({\n children,\n}: {\n children: ReactNode;\n}): JSX.Element {\n const [entryPoints, setEntryPoints] = useState<\n Record<string, AnnotatedFunction<any[]>>\n >({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const setEntryPoint = useCallback(\n (id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n },\n []\n );\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (categories: string[] = [\"global\"]) => {\n return printTree(categories);\n },\n [printTree]\n );\n\n const addContext = useCallback(\n (context: string, parentId?: string, categories: string[] = [\"global\"]) => {\n return addElement(context, categories, parentId);\n },\n [addElement]\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement]\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[]\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<\n string,\n AnnotatedFunction<any[]>\n > = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction =\n entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let parsedFunctionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n parsedFunctionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n parsedFunctionCallArguments[\n arg.name as keyof typeof parsedFunctionCallArguments\n ]\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(\n entryPoints: AnnotatedFunction<any[]>[]\n): ChatCompletionCreateParams.Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n\nfunction annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>\n): ChatCompletionCreateParams.Function {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ChatCompletionCreateParams.Function = {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n };\n\n return chatCompletionFunction;\n}\n"]}
|
package/dist/chunk-H23NBUJ7.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-6CBAEPMO.mjs';
|
|
2
|
-
import { useRef, useContext, useMemo, useEffect } from 'react';
|
|
3
|
-
import { nanoid } from 'nanoid';
|
|
4
|
-
|
|
5
|
-
function useMakeCopilotActionable(annotatedFunction, dependencies) {
|
|
6
|
-
const idRef = useRef(nanoid());
|
|
7
|
-
const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);
|
|
8
|
-
const memoizedAnnotatedFunction = useMemo(
|
|
9
|
-
() => ({
|
|
10
|
-
name: annotatedFunction.name,
|
|
11
|
-
description: annotatedFunction.description,
|
|
12
|
-
argumentAnnotations: annotatedFunction.argumentAnnotations,
|
|
13
|
-
implementation: annotatedFunction.implementation
|
|
14
|
-
}),
|
|
15
|
-
dependencies
|
|
16
|
-
);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
setEntryPoint(
|
|
19
|
-
idRef.current,
|
|
20
|
-
memoizedAnnotatedFunction
|
|
21
|
-
);
|
|
22
|
-
return () => {
|
|
23
|
-
removeEntryPoint(idRef.current);
|
|
24
|
-
};
|
|
25
|
-
}, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { useMakeCopilotActionable };
|
|
29
|
-
//# sourceMappingURL=out.js.map
|
|
30
|
-
//# sourceMappingURL=chunk-H23NBUJ7.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-make-copilot-actionable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,QAAQ,YAAY,WAAW,eAAe;AAGvD,SAAS,cAAc;AALvB;AAOO,SAAS,yBACd,mBACA,cACA;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,cAAc;AAErE,QAAM,4BAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd;AAAA,MACE,MAAM;AAAA,MACN;AAAA,IACF;AAEA,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE","sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[]\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies\n );\n\n useEffect(() => {\n setEntryPoint(\n idRef.current,\n memoizedAnnotatedFunction as AnnotatedFunction<any[]>\n );\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n"]}
|
package/dist/chunk-JD7BAH7U.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-KQACBBGH.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-6CBAEPMO.mjs';
|
|
2
|
-
import { useContext, useRef, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function useMakeCopilotReadable(information, parentId, categories) {
|
|
5
|
-
const { addContext, removeContext } = useContext(CopilotContext);
|
|
6
|
-
const idRef = useRef();
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const id = addContext(information, parentId, categories);
|
|
9
|
-
idRef.current = id;
|
|
10
|
-
return () => {
|
|
11
|
-
removeContext(id);
|
|
12
|
-
};
|
|
13
|
-
}, [information, parentId, addContext, removeContext]);
|
|
14
|
-
return idRef.current;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { useMakeCopilotReadable };
|
|
18
|
-
//# sourceMappingURL=out.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-KQACBBGH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-make-copilot-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAF9C;AAYO,SAAS,uBACd,aACA,UACA,YACoB;AACpB,QAAM,EAAE,YAAY,cAAc,IAAI,WAAW,cAAc;AAC/D,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,WAAW,aAAa,UAAU,UAAU;AACvD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,oBAAc,EAAE;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,YAAY,aAAa,CAAC;AAErD,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n * @param information - The information to be added to the Copilot context.\n * @param parentId - The ID of the parent context, if any.\n * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n * @returns The ID of the added context.\n */\nexport function useMakeCopilotReadable(\n information: string,\n parentId?: string,\n categories?: string[]\n): string | undefined {\n const { addContext, removeContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addContext(information, parentId, categories);\n idRef.current = id;\n\n return () => {\n removeContext(id);\n };\n }, [information, parentId, addContext, removeContext]);\n\n return idRef.current;\n}\n"]}
|
package/dist/chunk-MRXNTQOX.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { __async, __objRest, __spreadProps, __spreadValues };
|
|
54
|
-
//# sourceMappingURL=out.js.map
|
|
55
|
-
//# sourceMappingURL=chunk-MRXNTQOX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/dist/chunk-VNRDQJXW.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|