houdini-react 0.0.0-20231008055552
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/LICENSE +21 -0
- package/README.md +36 -0
- package/build/plugin/codegen/entries.d.ts +5 -0
- package/build/plugin/codegen/index.d.ts +13 -0
- package/build/plugin/codegen/manifest.d.ts +5 -0
- package/build/plugin/codegen/render.d.ts +5 -0
- package/build/plugin/codegen/router.d.ts +7 -0
- package/build/plugin/codegen/typeRoot.d.ts +6 -0
- package/build/plugin/config.d.ts +4 -0
- package/build/plugin/dedent.d.ts +1 -0
- package/build/plugin/extract.d.ts +6 -0
- package/build/plugin/index.d.ts +7 -0
- package/build/plugin/transform.d.ts +6 -0
- package/build/plugin/vite.d.ts +54 -0
- package/build/plugin-cjs/index.js +79966 -0
- package/build/plugin-cjs/package.json +1 -0
- package/build/plugin-esm/index.js +79956 -0
- package/build/plugin-esm/package.json +1 -0
- package/build/runtime/client.d.ts +3 -0
- package/build/runtime/clientPlugin.d.ts +3 -0
- package/build/runtime/hooks/index.d.ts +8 -0
- package/build/runtime/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime/hooks/useFragment.d.ts +16 -0
- package/build/runtime/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime/hooks/useMutation.d.ts +10 -0
- package/build/runtime/hooks/useQuery.d.ts +5 -0
- package/build/runtime/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime/hooks/useSubscription.d.ts +4 -0
- package/build/runtime/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime/index.d.ts +11 -0
- package/build/runtime/manifest.d.ts +3 -0
- package/build/runtime/routing/Router.d.ts +67 -0
- package/build/runtime/routing/cache.d.ts +7 -0
- package/build/runtime/routing/index.d.ts +2 -0
- package/build/runtime/server/index.d.ts +17 -0
- package/build/runtime/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime/server/renderToStream.d.ts +28 -0
- package/build/runtime/server/shared/initData.d.ts +8 -0
- package/build/runtime/server/shared/key.d.ts +4 -0
- package/build/runtime/server/shared/utils.d.ts +3 -0
- package/build/runtime/server/useStream.d.ts +9 -0
- package/build/runtime/server/utils/assert.d.ts +15 -0
- package/build/runtime/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime/server/utils/debug.d.ts +14 -0
- package/build/runtime/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime/server/utils/isCallable.d.ts +2 -0
- package/build/runtime/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime/server/utils/isPromise.d.ts +1 -0
- package/build/runtime/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime/server/utils.d.ts +4 -0
- package/build/runtime-cjs/client.d.ts +3 -0
- package/build/runtime-cjs/client.js +27 -0
- package/build/runtime-cjs/clientPlugin.d.ts +3 -0
- package/build/runtime-cjs/clientPlugin.js +39 -0
- package/build/runtime-cjs/hooks/index.d.ts +8 -0
- package/build/runtime-cjs/hooks/index.js +45 -0
- package/build/runtime-cjs/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime-cjs/hooks/useDeepCompareEffect.js +72 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.js +131 -0
- package/build/runtime-cjs/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime-cjs/hooks/useDocumentStore.js +68 -0
- package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +72 -0
- package/build/runtime-cjs/hooks/useFragment.d.ts +16 -0
- package/build/runtime-cjs/hooks/useFragment.js +97 -0
- package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime-cjs/hooks/useFragmentHandle.js +47 -0
- package/build/runtime-cjs/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime-cjs/hooks/useIsMounted.js +38 -0
- package/build/runtime-cjs/hooks/useMutation.d.ts +10 -0
- package/build/runtime-cjs/hooks/useMutation.js +50 -0
- package/build/runtime-cjs/hooks/useQuery.d.ts +5 -0
- package/build/runtime-cjs/hooks/useQuery.js +32 -0
- package/build/runtime-cjs/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime-cjs/hooks/useQueryHandle.js +125 -0
- package/build/runtime-cjs/hooks/useSubscription.d.ts +4 -0
- package/build/runtime-cjs/hooks/useSubscription.js +32 -0
- package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime-cjs/hooks/useSubscriptionHandle.js +42 -0
- package/build/runtime-cjs/index.d.ts +11 -0
- package/build/runtime-cjs/index.js +77 -0
- package/build/runtime-cjs/manifest.d.ts +3 -0
- package/build/runtime-cjs/manifest.js +27 -0
- package/build/runtime-cjs/package.json +1 -0
- package/build/runtime-cjs/routing/Router.d.ts +67 -0
- package/build/runtime-cjs/routing/Router.js +429 -0
- package/build/runtime-cjs/routing/cache.d.ts +7 -0
- package/build/runtime-cjs/routing/cache.js +58 -0
- package/build/runtime-cjs/routing/index.d.ts +2 -0
- package/build/runtime-cjs/routing/index.js +30 -0
- package/build/runtime-cjs/server/index.d.ts +17 -0
- package/build/runtime-cjs/server/index.js +28 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.js +101 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.js +90 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.js +85 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.js +51 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.js +44 -0
- package/build/runtime-cjs/server/renderToStream.d.ts +28 -0
- package/build/runtime-cjs/server/renderToStream.js +183 -0
- package/build/runtime-cjs/server/shared/initData.d.ts +8 -0
- package/build/runtime-cjs/server/shared/initData.js +28 -0
- package/build/runtime-cjs/server/shared/key.d.ts +4 -0
- package/build/runtime-cjs/server/shared/key.js +45 -0
- package/build/runtime-cjs/server/shared/utils.d.ts +3 -0
- package/build/runtime-cjs/server/shared/utils.js +20 -0
- package/build/runtime-cjs/server/useStream.d.ts +9 -0
- package/build/runtime-cjs/server/useStream.js +44 -0
- package/build/runtime-cjs/server/utils/assert.d.ts +15 -0
- package/build/runtime-cjs/server/utils/assert.js +119 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.js +62 -0
- package/build/runtime-cjs/server/utils/debug.d.ts +14 -0
- package/build/runtime-cjs/server/utils/debug.js +112 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.js +32 -0
- package/build/runtime-cjs/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isBrowser.js +30 -0
- package/build/runtime-cjs/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isCallable.js +30 -0
- package/build/runtime-cjs/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isClientSide.js +30 -0
- package/build/runtime-cjs/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-cjs/server/utils/isPromise.js +31 -0
- package/build/runtime-cjs/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isServerSide.js +31 -0
- package/build/runtime-cjs/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-cjs/server/utils/objectAssign.js +30 -0
- package/build/runtime-cjs/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-cjs/server/utils/projectInfo.js +37 -0
- package/build/runtime-cjs/server/utils.d.ts +4 -0
- package/build/runtime-cjs/server/utils.js +21 -0
- package/build/runtime-esm/client.d.ts +3 -0
- package/build/runtime-esm/client.js +5 -0
- package/build/runtime-esm/clientPlugin.d.ts +3 -0
- package/build/runtime-esm/clientPlugin.js +17 -0
- package/build/runtime-esm/hooks/index.d.ts +8 -0
- package/build/runtime-esm/hooks/index.js +16 -0
- package/build/runtime-esm/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime-esm/hooks/useDeepCompareEffect.js +41 -0
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime-esm/hooks/useDocumentHandle.js +101 -0
- package/build/runtime-esm/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime-esm/hooks/useDocumentStore.js +38 -0
- package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime-esm/hooks/useDocumentSubscription.js +42 -0
- package/build/runtime-esm/hooks/useFragment.d.ts +16 -0
- package/build/runtime-esm/hooks/useFragment.js +66 -0
- package/build/runtime-esm/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime-esm/hooks/useFragmentHandle.js +23 -0
- package/build/runtime-esm/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime-esm/hooks/useIsMounted.js +14 -0
- package/build/runtime-esm/hooks/useMutation.d.ts +10 -0
- package/build/runtime-esm/hooks/useMutation.js +26 -0
- package/build/runtime-esm/hooks/useQuery.d.ts +5 -0
- package/build/runtime-esm/hooks/useQuery.js +8 -0
- package/build/runtime-esm/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime-esm/hooks/useQueryHandle.js +95 -0
- package/build/runtime-esm/hooks/useSubscription.d.ts +4 -0
- package/build/runtime-esm/hooks/useSubscription.js +8 -0
- package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime-esm/hooks/useSubscriptionHandle.js +18 -0
- package/build/runtime-esm/index.d.ts +11 -0
- package/build/runtime-esm/index.js +45 -0
- package/build/runtime-esm/manifest.d.ts +3 -0
- package/build/runtime-esm/manifest.js +5 -0
- package/build/runtime-esm/package.json +1 -0
- package/build/runtime-esm/routing/Router.d.ts +67 -0
- package/build/runtime-esm/routing/Router.js +390 -0
- package/build/runtime-esm/routing/cache.d.ts +7 -0
- package/build/runtime-esm/routing/cache.js +33 -0
- package/build/runtime-esm/routing/index.d.ts +2 -0
- package/build/runtime-esm/routing/index.js +5 -0
- package/build/runtime-esm/server/index.d.ts +17 -0
- package/build/runtime-esm/server/index.js +4 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.js +77 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.js +66 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.js +61 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.js +20 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.js +20 -0
- package/build/runtime-esm/server/renderToStream.d.ts +28 -0
- package/build/runtime-esm/server/renderToStream.js +152 -0
- package/build/runtime-esm/server/shared/initData.d.ts +8 -0
- package/build/runtime-esm/server/shared/initData.js +4 -0
- package/build/runtime-esm/server/shared/key.d.ts +4 -0
- package/build/runtime-esm/server/shared/key.js +20 -0
- package/build/runtime-esm/server/shared/utils.d.ts +3 -0
- package/build/runtime-esm/server/shared/utils.js +3 -0
- package/build/runtime-esm/server/useStream.d.ts +9 -0
- package/build/runtime-esm/server/useStream.js +13 -0
- package/build/runtime-esm/server/utils/assert.d.ts +15 -0
- package/build/runtime-esm/server/utils/assert.js +91 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.js +38 -0
- package/build/runtime-esm/server/utils/debug.d.ts +14 -0
- package/build/runtime-esm/server/utils/debug.js +87 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.js +8 -0
- package/build/runtime-esm/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-esm/server/utils/isBrowser.js +6 -0
- package/build/runtime-esm/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-esm/server/utils/isCallable.js +6 -0
- package/build/runtime-esm/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isClientSide.js +6 -0
- package/build/runtime-esm/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-esm/server/utils/isPromise.js +7 -0
- package/build/runtime-esm/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isServerSide.js +7 -0
- package/build/runtime-esm/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-esm/server/utils/objectAssign.js +6 -0
- package/build/runtime-esm/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-esm/server/utils/projectInfo.js +13 -0
- package/build/runtime-esm/server/utils.d.ts +4 -0
- package/build/runtime-esm/server/utils.js +4 -0
- package/package.json +67 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createErrorWithCleanStackTrace } from "./createErrorWithCleanStackTrace";
|
|
2
|
+
import { projectInfo } from "./projectInfo";
|
|
3
|
+
const errorPrefix = `[${projectInfo.npmPackageName}@${projectInfo.projectVersion}]`;
|
|
4
|
+
const internalErrorPrefix = `${errorPrefix}[Bug]`;
|
|
5
|
+
const usageErrorPrefix = `${errorPrefix}[Wrong Usage]`;
|
|
6
|
+
const warningPrefix = `${errorPrefix}[Warning]`;
|
|
7
|
+
const infoPrefix = `${errorPrefix}[Info]`;
|
|
8
|
+
const numberOfStackTraceLinesToRemove = 2;
|
|
9
|
+
function assert(condition, debugInfo) {
|
|
10
|
+
if (condition) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const debugStr = (() => {
|
|
14
|
+
if (!debugInfo) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
const debugInfoSerialized = typeof debugInfo === "string" ? debugInfo : "`" + JSON.stringify(debugInfo) + "`";
|
|
18
|
+
return `Debug info (this is for the ${projectInfo.projectName} maintainers; you can ignore this): ${debugInfoSerialized}.`;
|
|
19
|
+
})();
|
|
20
|
+
const internalError = createErrorWithCleanStackTrace(
|
|
21
|
+
[
|
|
22
|
+
`${internalErrorPrefix} You stumbled upon a bug in ${projectInfo.projectName}'s source code.`,
|
|
23
|
+
`Reach out at ${projectInfo.githubRepository}/issues/new or ${projectInfo.discordInviteToolChannel} and include this error stack (the error stack is usually enough to fix the problem).`,
|
|
24
|
+
"A maintainer will fix the bug (usually under 24 hours).",
|
|
25
|
+
`Do not hesitate to reach out as it makes ${projectInfo.projectName} more robust.`,
|
|
26
|
+
debugStr
|
|
27
|
+
].join(" "),
|
|
28
|
+
numberOfStackTraceLinesToRemove
|
|
29
|
+
);
|
|
30
|
+
throw internalError;
|
|
31
|
+
}
|
|
32
|
+
function assertUsage(condition, errorMessage) {
|
|
33
|
+
if (condition) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const whiteSpace = errorMessage.startsWith("[") ? "" : " ";
|
|
37
|
+
const usageError = createErrorWithCleanStackTrace(
|
|
38
|
+
`${usageErrorPrefix}${whiteSpace}${errorMessage}`,
|
|
39
|
+
numberOfStackTraceLinesToRemove
|
|
40
|
+
);
|
|
41
|
+
throw usageError;
|
|
42
|
+
}
|
|
43
|
+
function getProjectError(errorMessage) {
|
|
44
|
+
const pluginError = createErrorWithCleanStackTrace(
|
|
45
|
+
`${errorPrefix} ${errorMessage}`,
|
|
46
|
+
numberOfStackTraceLinesToRemove
|
|
47
|
+
);
|
|
48
|
+
return pluginError;
|
|
49
|
+
}
|
|
50
|
+
let alreadyLogged = /* @__PURE__ */ new Set();
|
|
51
|
+
function assertWarning(condition, errorMessage, { onlyOnce, showStackTrace }) {
|
|
52
|
+
if (condition) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const msg = `${warningPrefix} ${errorMessage}`;
|
|
56
|
+
if (onlyOnce) {
|
|
57
|
+
const key = onlyOnce === true ? msg : onlyOnce;
|
|
58
|
+
if (alreadyLogged.has(key)) {
|
|
59
|
+
return;
|
|
60
|
+
} else {
|
|
61
|
+
alreadyLogged.add(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (showStackTrace) {
|
|
65
|
+
console.warn(new Error(msg));
|
|
66
|
+
} else {
|
|
67
|
+
console.warn(msg);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function assertInfo(condition, errorMessage, { onlyOnce }) {
|
|
71
|
+
if (condition) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const msg = `${infoPrefix} ${errorMessage}`;
|
|
75
|
+
if (onlyOnce) {
|
|
76
|
+
const key = msg;
|
|
77
|
+
if (alreadyLogged.has(key)) {
|
|
78
|
+
return;
|
|
79
|
+
} else {
|
|
80
|
+
alreadyLogged.add(key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
console.log(msg);
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
assert,
|
|
87
|
+
assertInfo,
|
|
88
|
+
assertUsage,
|
|
89
|
+
assertWarning,
|
|
90
|
+
getProjectError
|
|
91
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function createErrorWithCleanStackTrace(errorMessage, numberOfStackTraceLinesToRemove) {
|
|
2
|
+
let err;
|
|
3
|
+
{
|
|
4
|
+
var stackTraceLimit__original = Error.stackTraceLimit;
|
|
5
|
+
Error.stackTraceLimit = Infinity;
|
|
6
|
+
err = new Error(errorMessage);
|
|
7
|
+
Error.stackTraceLimit = stackTraceLimit__original;
|
|
8
|
+
}
|
|
9
|
+
err.stack = clean(err.stack, numberOfStackTraceLinesToRemove);
|
|
10
|
+
return err;
|
|
11
|
+
}
|
|
12
|
+
function clean(errStack, numberOfStackTraceLinesToRemove) {
|
|
13
|
+
if (!errStack) {
|
|
14
|
+
return errStack;
|
|
15
|
+
}
|
|
16
|
+
const stackLines = splitByLine(errStack);
|
|
17
|
+
let linesRemoved = 0;
|
|
18
|
+
const stackLine__cleaned = stackLines.filter((line) => {
|
|
19
|
+
if (line.includes(" (internal/") || line.includes(" (node:internal")) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (linesRemoved < numberOfStackTraceLinesToRemove && isStackTraceLine(line)) {
|
|
23
|
+
linesRemoved++;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}).join("\n");
|
|
28
|
+
return stackLine__cleaned;
|
|
29
|
+
}
|
|
30
|
+
function isStackTraceLine(line) {
|
|
31
|
+
return line.startsWith(" at ");
|
|
32
|
+
}
|
|
33
|
+
function splitByLine(str) {
|
|
34
|
+
return str.split(/\r?\n/);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
createErrorWithCleanStackTrace
|
|
38
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createDebugger };
|
|
2
|
+
export { isDebugEnabled };
|
|
3
|
+
export type { Debug };
|
|
4
|
+
type Debug = ReturnType<typeof createDebugger>;
|
|
5
|
+
type Options = {
|
|
6
|
+
serialization?: {
|
|
7
|
+
emptyArray?: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare function createDebugger(namespace: string, optionsGlobal?: Options): ((msg: string, info?: unknown) => void) & {
|
|
11
|
+
options: (options: Options) => (msg: string, info?: unknown) => void;
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare function isDebugEnabled(namespace: string): boolean;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { assert } from "./assert";
|
|
2
|
+
import { isBrowser } from "./isBrowser";
|
|
3
|
+
import { isCallable } from "./isCallable";
|
|
4
|
+
import { objectAssign } from "./objectAssign";
|
|
5
|
+
assert(!isBrowser(), "utils/debug.js loaded in browser");
|
|
6
|
+
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
7
|
+
function createDebugger(namespace, optionsGlobal) {
|
|
8
|
+
const debugWithOptions = (options) => {
|
|
9
|
+
return (msg, info) => {
|
|
10
|
+
if (!isDebugEnabled(namespace))
|
|
11
|
+
return;
|
|
12
|
+
if (info !== void 0) {
|
|
13
|
+
msg += strInfo(info, { ...optionsGlobal, ...options });
|
|
14
|
+
}
|
|
15
|
+
console.log("\x1B[1m%s\x1B[0m", namespace, msg);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const debug = (msg, info) => debugWithOptions({})(msg, info);
|
|
19
|
+
objectAssign(debug, { options: debugWithOptions, isEnabled: isDebugEnabled(namespace) });
|
|
20
|
+
return debug;
|
|
21
|
+
}
|
|
22
|
+
function isDebugEnabled(namespace) {
|
|
23
|
+
let DEBUG;
|
|
24
|
+
try {
|
|
25
|
+
DEBUG = process.env.DEBUG;
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
return DEBUG?.includes(namespace) ?? false;
|
|
29
|
+
}
|
|
30
|
+
function strInfo(info, options) {
|
|
31
|
+
if (info === void 0) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
let str = "\n";
|
|
35
|
+
if (typeof info === "string") {
|
|
36
|
+
str += info;
|
|
37
|
+
} else if (Array.isArray(info)) {
|
|
38
|
+
if (info.length === 0) {
|
|
39
|
+
str += options.serialization?.emptyArray ?? "[]";
|
|
40
|
+
} else {
|
|
41
|
+
str += info.map(strUnknown).join("\n");
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
str += strUnknown(info);
|
|
45
|
+
}
|
|
46
|
+
str = pad(str);
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
function pad(str) {
|
|
50
|
+
const PADDING = " ";
|
|
51
|
+
const WIDTH = process.stdout.columns;
|
|
52
|
+
const lines = [];
|
|
53
|
+
str.split("\n").forEach((line) => {
|
|
54
|
+
if (!WIDTH) {
|
|
55
|
+
lines.push(line);
|
|
56
|
+
} else {
|
|
57
|
+
chunk(line, WIDTH - PADDING.length).forEach((chunk2) => {
|
|
58
|
+
lines.push(chunk2);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return lines.join("\n" + PADDING);
|
|
63
|
+
}
|
|
64
|
+
function chunk(str, size) {
|
|
65
|
+
if (str.length <= size) {
|
|
66
|
+
return [str];
|
|
67
|
+
}
|
|
68
|
+
const chunks = str.match(new RegExp(".{1," + size + "}", "g"));
|
|
69
|
+
assert(chunks);
|
|
70
|
+
return chunks;
|
|
71
|
+
}
|
|
72
|
+
function strUnknown(thing) {
|
|
73
|
+
return typeof thing === "string" ? thing : strObj(thing);
|
|
74
|
+
}
|
|
75
|
+
function strObj(obj, newLines = false) {
|
|
76
|
+
return JSON.stringify(obj, replaceFunctionSerializer, newLines ? 2 : void 0);
|
|
77
|
+
}
|
|
78
|
+
function replaceFunctionSerializer(_key, value) {
|
|
79
|
+
if (isCallable(value)) {
|
|
80
|
+
return value.toString().split(/\s+/).join(" ");
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
createDebugger,
|
|
86
|
+
isDebugEnabled
|
|
87
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function getGlobalVariable(key, defaultValue) {
|
|
2
|
+
globalThis.__react_streaming = globalThis.__react_streaming || {};
|
|
3
|
+
globalThis.__react_streaming[key] = globalThis.__react_streaming[key] || defaultValue;
|
|
4
|
+
return globalThis.__react_streaming[key];
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
getGlobalVariable
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPromise(val: unknown): val is Promise<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const projectInfo: {
|
|
2
|
+
projectName: "react-streaming";
|
|
3
|
+
projectVersion: string;
|
|
4
|
+
npmPackageName: "react-streaming";
|
|
5
|
+
githubRepository: "https://github.com/brillout/react-streaming";
|
|
6
|
+
discordInviteToolChannel: "https://discord.com/invite/H23tjRxFvx";
|
|
7
|
+
};
|
|
8
|
+
declare global {
|
|
9
|
+
var __vite_plugin_ssr__instances: undefined | string[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const PROJECT_VERSION = "0.3.14";
|
|
2
|
+
const projectInfo = {
|
|
3
|
+
projectName: "react-streaming",
|
|
4
|
+
projectVersion: PROJECT_VERSION,
|
|
5
|
+
npmPackageName: "react-streaming",
|
|
6
|
+
githubRepository: "https://github.com/brillout/react-streaming",
|
|
7
|
+
discordInviteToolChannel: "https://discord.com/invite/H23tjRxFvx"
|
|
8
|
+
};
|
|
9
|
+
globalThis.__vite_plugin_ssr__instances = globalThis.__vite_plugin_ssr__instances || [];
|
|
10
|
+
globalThis.__vite_plugin_ssr__instances.push(projectInfo.projectVersion);
|
|
11
|
+
export {
|
|
12
|
+
projectInfo
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "houdini-react",
|
|
3
|
+
"version": "0.0.0-20231008055552",
|
|
4
|
+
"description": "The React plugin for houdini",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"react",
|
|
8
|
+
"graphql",
|
|
9
|
+
"graphql-client"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/HoudiniGraphql/houdini",
|
|
12
|
+
"funding": "https://github.com/sponsors/HoudiniGraphql",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/HoudiniGraphql/houdini.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/cookie-parser": "^1.4.3",
|
|
20
|
+
"@types/cookie-session": "^2.0.44",
|
|
21
|
+
"@types/cookies": "^0.7.7",
|
|
22
|
+
"@types/estraverse": "^5.1.2",
|
|
23
|
+
"@types/express": "^4.17.17",
|
|
24
|
+
"@types/react-dom": "^18.0.11",
|
|
25
|
+
"next": "^13.0.1",
|
|
26
|
+
"scripts": "^1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@babel/parser": "^7.19.3",
|
|
30
|
+
"@babel/types": "^7.21.4",
|
|
31
|
+
"@types/react": "^18.0.28",
|
|
32
|
+
"@whatwg-node/server": "^0.9.14",
|
|
33
|
+
"cookie-parser": "^1.4.6",
|
|
34
|
+
"cookie-session": "^2.0.0",
|
|
35
|
+
"cookies": "^0.8.0",
|
|
36
|
+
"estraverse": "^5.3.0",
|
|
37
|
+
"express": "^4.18.2",
|
|
38
|
+
"graphql": "^15.8.0",
|
|
39
|
+
"graphql-yoga": "^4.0.4",
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"react-dom": "^18.2.0",
|
|
42
|
+
"recast": "^0.23.1",
|
|
43
|
+
"rollup": "^3.7.4",
|
|
44
|
+
"use-deep-compare-effect": "^1.8.1",
|
|
45
|
+
"houdini": "^0.0.0-20231008055552"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"build"
|
|
49
|
+
],
|
|
50
|
+
"exports": {
|
|
51
|
+
"./package.json": "./package.json",
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./build/plugin/index.d.ts",
|
|
54
|
+
"import": "./build/plugin-esm/index.js",
|
|
55
|
+
"require": "./build/plugin-cjs/index.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"typesVersions": {
|
|
59
|
+
"*": {}
|
|
60
|
+
},
|
|
61
|
+
"main": "./build/plugin-cjs/index.js",
|
|
62
|
+
"types": "./build/plugin/index.d.ts",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"compile": "scripts build --plugin",
|
|
65
|
+
"typedefs": "scripts typedefs --plugin"
|
|
66
|
+
}
|
|
67
|
+
}
|