rescript-relay 0.0.0-autocodesplit-09ee6f6c

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +942 -0
  2. package/README.md +111 -0
  3. package/cli/cli.js +472 -0
  4. package/compiler.js +11 -0
  5. package/package.json +65 -0
  6. package/postinstall.js +189 -0
  7. package/ppx-linux +0 -0
  8. package/ppx-macos-arm64 +0 -0
  9. package/ppx-macos-latest +0 -0
  10. package/ppx-windows-latest +0 -0
  11. package/relay-compiler-linux-musl/relay +0 -0
  12. package/relay-compiler-linux-x64/relay +0 -0
  13. package/relay-compiler-macos-arm64/relay +0 -0
  14. package/relay-compiler-macos-x64/relay +0 -0
  15. package/relay-compiler-win-x64/relay.exe +0 -0
  16. package/rescript.json +19 -0
  17. package/src/ReactDOMExperimental.bs.js +23 -0
  18. package/src/ReactDOMExperimental.res +16 -0
  19. package/src/ReactExperimental.bs.js +23 -0
  20. package/src/ReactExperimental.res +21 -0
  21. package/src/ReactExperimental.resi +18 -0
  22. package/src/RescriptRelay.bs.js +329 -0
  23. package/src/RescriptRelay.res +858 -0
  24. package/src/RescriptRelay.resi +897 -0
  25. package/src/RescriptRelayUtils.bs.js +76 -0
  26. package/src/RescriptRelayUtils.res +89 -0
  27. package/src/RescriptRelayUtils.resi +36 -0
  28. package/src/RescriptRelay_Fragment.bs.js +122 -0
  29. package/src/RescriptRelay_Fragment.res +243 -0
  30. package/src/RescriptRelay_Fragment.resi +85 -0
  31. package/src/RescriptRelay_Internal.bs.js +102 -0
  32. package/src/RescriptRelay_Internal.res +71 -0
  33. package/src/RescriptRelay_Internal.resi +20 -0
  34. package/src/RescriptRelay_Mutation.bs.js +57 -0
  35. package/src/RescriptRelay_Mutation.res +144 -0
  36. package/src/RescriptRelay_Mutation.resi +52 -0
  37. package/src/RescriptRelay_Query.bs.js +101 -0
  38. package/src/RescriptRelay_Query.res +177 -0
  39. package/src/RescriptRelay_Query.resi +62 -0
  40. package/src/RescriptRelay_RelayResolvers.bs.js +13 -0
  41. package/src/RescriptRelay_RelayResolvers.res +21 -0
  42. package/src/RescriptRelay_RelayResolvers.resi +10 -0
  43. package/src/RescriptRelay_Subscriptions.bs.js +24 -0
  44. package/src/RescriptRelay_Subscriptions.res +50 -0
  45. package/src/RescriptRelay_Subscriptions.resi +14 -0
  46. package/src/utils.js +418 -0
  47. package/src/utils.mjs +418 -0
package/compiler.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var spawn = require("child_process").spawn;
5
+ var path = require("path");
6
+
7
+ var input = process.argv.slice(2);
8
+
9
+ spawn(path.join(__dirname, "rescript-relay-compiler.exe"), input, {
10
+ stdio: "inherit",
11
+ }).on("exit", process.exit);
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "rescript-relay",
3
+ "version": "0.0.0-autocodesplit-09ee6f6c",
4
+ "main": "src/RescriptRelay.res",
5
+ "license": "MIT",
6
+ "author": "Gabriel Nordeborn",
7
+ "sideEffects": false,
8
+ "repository": "https://github.com/zth/rescript-relay",
9
+ "description": "Use Relay with ReScript.",
10
+ "publishConfig": {
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "keywords": [
14
+ "graphql",
15
+ "relay",
16
+ "relaymodern",
17
+ "react",
18
+ "reason",
19
+ "reasonml",
20
+ "rescript"
21
+ ],
22
+ "exports": {
23
+ "./src/utils": {
24
+ "require": "./src/utils.js",
25
+ "import": "./src/utils.mjs"
26
+ },
27
+ "./src/*": "./src/*",
28
+ "./package.json": "./package.json"
29
+ },
30
+ "bin": {
31
+ "rescript-relay-compiler": "compiler.js",
32
+ "rescript-relay-cli": "cli/cli.js"
33
+ },
34
+ "scripts": {
35
+ "build": "rescript",
36
+ "build:test": "./build-compiler-dev.sh && ./rescript-relay-compiler",
37
+ "postinstall": "node postinstall.js",
38
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
39
+ "test:ci": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --ci --runInBand"
40
+ },
41
+ "devDependencies": {
42
+ "@glennsl/rescript-fetch": "^0.2.0",
43
+ "@rescript/react": "0.12.2",
44
+ "@testing-library/jest-dom": "^5.16.3",
45
+ "@testing-library/react": "^13.0.0-alpha.6",
46
+ "graphql-query-test-mock": "^0.12.1",
47
+ "jest": "^27.2.4",
48
+ "nock": "^11.7.0",
49
+ "node-fetch": "^2.6.0",
50
+ "react": "18.2.0",
51
+ "react-dom": "18.2.0",
52
+ "react-relay": "17.0.0",
53
+ "relay-runtime": "17.0.0",
54
+ "rescript": "11.1.1"
55
+ },
56
+ "peerDependencies": {
57
+ "@rescript/react": "^0.12.1",
58
+ "react-relay": "17.0.0",
59
+ "relay-runtime": "17.0.0",
60
+ "rescript": "^11.0.0"
61
+ },
62
+ "dependencies": {
63
+ "detect-libc": "^2.0.1"
64
+ }
65
+ }
package/postinstall.js ADDED
@@ -0,0 +1,189 @@
1
+ /**
2
+ * release-postinstall.js
3
+ *
4
+ * This script is bundled with the `npm` package and executed on release.
5
+ * Since we have a 'fat' NPM package (with all platform binaries bundled),
6
+ * this postinstall script extracts them and puts the current platform's
7
+ * bits in the right place.
8
+ */
9
+
10
+ var path = require("path");
11
+ var cp = require("child_process");
12
+ var fs = require("fs");
13
+ var { isNonGlibcLinux } = require("detect-libc");
14
+ var platform = process.platform;
15
+
16
+ function getRelayCompilerPlatformSuffix() {
17
+ if (process.platform === "win32") {
18
+ return "win-x64";
19
+ } else if (process.platform === "darwin" && process.arch === "x64") {
20
+ return "macos-x64";
21
+ } else if (process.platform === "darwin" && process.arch === "arm64") {
22
+ return "macos-arm64";
23
+ } else if (process.platform === "linux" && isNonGlibcLinux) {
24
+ return "linux-musl";
25
+ } else if (process.platform === "linux" && process.arch === "x64") {
26
+ return "linux-x64";
27
+ }
28
+
29
+ return "linux-x64";
30
+ }
31
+
32
+ /**
33
+ * Since os.arch returns node binary's target arch, not
34
+ * the system arch.
35
+ * Credits: https://github.com/feross/arch/blob/af080ff61346315559451715c5393d8e86a6d33c/index.js#L10-L58
36
+ */
37
+
38
+ function ppxArch() {
39
+ if (platform === "darwin" && process.arch === "arm64") {
40
+ return "arm64";
41
+ }
42
+
43
+ /**
44
+ * The running binary is 64-bit, so the OS is clearly 64-bit.
45
+ */
46
+ if (process.arch === "x64") {
47
+ return "x64";
48
+ }
49
+
50
+ /**
51
+ * All recent versions of Mac OS are 64-bit.
52
+ */
53
+ if (process.platform === "darwin") {
54
+ return "x64";
55
+ }
56
+
57
+ /**
58
+ * On Windows, the most reliable way to detect a 64-bit OS from within a 32-bit
59
+ * app is based on the presence of a WOW64 file: %SystemRoot%\SysNative.
60
+ * See: https://twitter.com/feross/status/776949077208510464
61
+ */
62
+ if (process.platform === "win32") {
63
+ var useEnv = false;
64
+ try {
65
+ useEnv = !!(
66
+ process.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT)
67
+ );
68
+ } catch (err) {}
69
+
70
+ var sysRoot = useEnv ? process.env.SYSTEMROOT : "C:\\Windows";
71
+
72
+ // If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application.
73
+ var isWOW64 = false;
74
+ try {
75
+ isWOW64 = !!fs.statSync(path.join(sysRoot, "sysnative"));
76
+ } catch (err) {}
77
+
78
+ return isWOW64 ? "x64" : "x86";
79
+ }
80
+
81
+ /**
82
+ * On Linux, use the `getconf` command to get the architecture.
83
+ */
84
+ if (process.platform === "linux") {
85
+ var output = cp.execSync("getconf LONG_BIT", { encoding: "utf8" });
86
+ return output === "64\n" ? "x64" : "x86";
87
+ }
88
+
89
+ /**
90
+ * If none of the above, assume the architecture is 32-bit.
91
+ */
92
+ return "x86";
93
+ }
94
+
95
+ function copyPlatformBinaries(platform) {
96
+ /**
97
+ * Copy the PPX
98
+ */
99
+ const ppxFinalFilename = platform === "windows-latest" ? "ppx.exe" : "ppx";
100
+ const ppxFinalPath = path.join(__dirname, ppxFinalFilename);
101
+
102
+ if (!fs.existsSync(ppxFinalPath)) {
103
+ fs.copyFileSync(path.join(__dirname, "ppx-" + platform), ppxFinalPath);
104
+ }
105
+ fs.chmodSync(ppxFinalPath, 0o777);
106
+
107
+ /**
108
+ * Copy the Relay compiler
109
+ */
110
+
111
+ var platformSuffix = getRelayCompilerPlatformSuffix();
112
+
113
+ const rescriptRelayCompilerFinalPath = path.join(
114
+ __dirname,
115
+ "rescript-relay-compiler.exe"
116
+ );
117
+
118
+ if (!fs.existsSync(rescriptRelayCompilerFinalPath)) {
119
+ fs.copyFileSync(
120
+ path.join(
121
+ __dirname,
122
+ "relay-compiler-" + platformSuffix,
123
+ platformSuffix === "win-x64" ? "relay.exe" : "relay"
124
+ ),
125
+ rescriptRelayCompilerFinalPath
126
+ );
127
+ }
128
+ fs.chmodSync(rescriptRelayCompilerFinalPath, 0o777);
129
+ }
130
+
131
+ function unlinkIfNotExistsSync(path) {
132
+ if (fs.existsSync(path)) {
133
+ fs.unlinkSync(path);
134
+ }
135
+ }
136
+
137
+ function removeInitialBinaries() {
138
+ unlinkIfNotExistsSync(path.join(__dirname, "ppx-macos-arm64"));
139
+ unlinkIfNotExistsSync(path.join(__dirname, "ppx-macos-latest"));
140
+ unlinkIfNotExistsSync(path.join(__dirname, "ppx-windows-latest"));
141
+ unlinkIfNotExistsSync(path.join(__dirname, "ppx-linux"));
142
+ fs.rmSync(path.join(__dirname, "relay-compiler-linux-x64"), {
143
+ recursive: true,
144
+ force: true,
145
+ });
146
+ fs.rmSync(path.join(__dirname, "relay-compiler-macos-x64"), {
147
+ recursive: true,
148
+ force: true,
149
+ });
150
+ fs.rmSync(path.join(__dirname, "relay-compiler-macos-arm64"), {
151
+ recursive: true,
152
+ force: true,
153
+ });
154
+ fs.rmSync(path.join(__dirname, "relay-compiler-linux-musl"), {
155
+ recursive: true,
156
+ force: true,
157
+ });
158
+ fs.rmSync(path.join(__dirname, "relay-compiler-win-x64"), {
159
+ recursive: true,
160
+ force: true,
161
+ });
162
+ }
163
+
164
+ switch (platform) {
165
+ case "win32": {
166
+ if (ppxArch() !== "x64") {
167
+ console.warn("error: x86 is currently not supported on Windows");
168
+ process.exit(1);
169
+ }
170
+ copyPlatformBinaries("windows-latest");
171
+ break;
172
+ }
173
+ case "linux":
174
+ copyPlatformBinaries(platform);
175
+ break;
176
+ case "darwin": {
177
+ if (ppxArch() === "arm64") {
178
+ copyPlatformBinaries("macos-arm64");
179
+ } else {
180
+ copyPlatformBinaries("macos-latest");
181
+ }
182
+ break;
183
+ }
184
+ default:
185
+ console.warn("error: no release built for the " + platform + " platform");
186
+ process.exit(1);
187
+ }
188
+
189
+ removeInitialBinaries();
package/ppx-linux ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/rescript.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "rescript-relay",
3
+ "version": "0.1.0",
4
+ "namespace": false,
5
+ "sources": [
6
+ {
7
+ "dir": "src"
8
+ }
9
+ ],
10
+ "package-specs": {
11
+ "module": "commonjs",
12
+ "in-source": true
13
+ },
14
+ "bs-dependencies": ["@rescript/react"],
15
+ "suffix": ".bs.js",
16
+ "warnings": {
17
+ "error": "+101"
18
+ }
19
+ }
@@ -0,0 +1,23 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var ReactDOM = require("@rescript/react/src/ReactDOM.bs.js");
5
+ var Client = require("react-dom/client");
6
+
7
+ function renderConcurrentRootAtElementWithId(content, id) {
8
+ var element = document.getElementById(id);
9
+ if (element == null) {
10
+ throw {
11
+ RE_EXN_ID: "Invalid_argument",
12
+ _1: "ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " + id + " found in the HTML.",
13
+ Error: new Error()
14
+ };
15
+ }
16
+ Client.createRoot(element).render(content);
17
+ }
18
+
19
+ var Root = ReactDOM.Client.Root;
20
+
21
+ exports.Root = Root;
22
+ exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
23
+ /* react-dom/client Not a pure module */
@@ -0,0 +1,16 @@
1
+ include ReactDOM.Client
2
+
3
+ @val @return(nullable)
4
+ external getElementById: string => option<Dom.element> = "document.getElementById"
5
+
6
+ let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (content, id) =>
7
+ switch getElementById(id) {
8
+ | None =>
9
+ raise(
10
+ Invalid_argument(
11
+ "ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " ++
12
+ id ++ " found in the HTML.",
13
+ ),
14
+ )
15
+ | Some(element) => createRoot(element)->Root.render(content)
16
+ }
@@ -0,0 +1,23 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var React = require("react");
5
+
6
+ function useTransition() {
7
+ var match = React.useTransition();
8
+ var startTransition = match[1];
9
+ return [
10
+ match[0],
11
+ React.useMemo((function () {
12
+ return function (cb) {
13
+ startTransition(cb, undefined);
14
+ };
15
+ }), [startTransition])
16
+ ];
17
+ }
18
+
19
+ var SuspenseList = {};
20
+
21
+ exports.useTransition = useTransition;
22
+ exports.SuspenseList = SuspenseList;
23
+ /* react Not a pure module */
@@ -0,0 +1,21 @@
1
+ @module("react")
2
+ external useDeferredValue: 'value => 'value = "useDeferredValue"
3
+
4
+ @module("react")
5
+ external useTransitionWithOptions: unit => (
6
+ bool,
7
+ (unit => unit, option<{"name": option<string>}>) => unit,
8
+ ) = "useTransition"
9
+
10
+ let useTransition = () => {
11
+ let (isPending, startTransition) = useTransitionWithOptions()
12
+ (isPending, React.useMemo1(() => cb => startTransition(cb, None), [startTransition]))
13
+ }
14
+
15
+ module SuspenseList = {
16
+ @module("react") @react.component
17
+ external make: (
18
+ ~children: React.element,
19
+ ~revealOrder: [#forwards | #backwards | #together]=?,
20
+ ) => React.element = "SuspenseList"
21
+ }
@@ -0,0 +1,18 @@
1
+ @module("react")
2
+ external useDeferredValue: 'value => 'value = "useDeferredValue"
3
+
4
+ @module("react")
5
+ external useTransitionWithOptions: unit => (
6
+ bool,
7
+ (unit => unit, option<{"name": option<string>}>) => unit,
8
+ ) = "useTransition"
9
+
10
+ let useTransition: unit => (bool, (unit => unit) => unit)
11
+
12
+ module SuspenseList: {
13
+ @module("react") @react.component
14
+ external make: (
15
+ ~children: React.element,
16
+ ~revealOrder: [#forwards | #backwards | #together]=?,
17
+ ) => React.element = "SuspenseList"
18
+ }