ruru 2.0.0-beta.25 → 2.0.0-beta.26
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/CHANGELOG.md +19 -0
- package/README.md +19 -244
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +17 -21
- package/dist/server.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -2
- package/ruru.html +137 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# ruru
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2629](https://github.com/graphile/crystal/pull/2629)
|
|
8
|
+
[`c5cc0ba`](https://github.com/graphile/crystal/commit/c5cc0ba6228c754bca60219d78ca1bc1b10759ca)
|
|
9
|
+
Thanks [@benjie](https://github.com/benjie)! - Fix loading worker scripts from
|
|
10
|
+
remote URLs.
|
|
11
|
+
|
|
12
|
+
- [#2631](https://github.com/graphile/crystal/pull/2631)
|
|
13
|
+
[`506b7a1`](https://github.com/graphile/crystal/commit/506b7a16bbdee72b0ac41eb3f3235775d629be6c)
|
|
14
|
+
Thanks [@benjie](https://github.com/benjie)! - Add a `ruru.html` file you can
|
|
15
|
+
self-host, and move Ruru documentation to the website for easier navigation
|
|
16
|
+
|
|
17
|
+
- [#2632](https://github.com/graphile/crystal/pull/2632)
|
|
18
|
+
[`418190a`](https://github.com/graphile/crystal/commit/418190a04169fdd01e166ae30fa764098bb34249)
|
|
19
|
+
Thanks [@benjie](https://github.com/benjie)! - Ruru loading state now matches
|
|
20
|
+
expected theme (light/dark).
|
|
21
|
+
|
|
3
22
|
## 2.0.0-beta.25
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
# ruru
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A distribution of [Graph*i*QL][graphiql] that's easy to use and embeds both the
|
|
4
|
+
popular [GraphiQL Explorer](https://github.com/onegraph/graphiql-explorer)
|
|
5
|
+
plugin and [Gra*fast*][grafast]-related tools such as viewing of plan diagrams
|
|
6
|
+
and explaining executed operations. _(Ruru can be used without Gra*fast*.)_
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
Flexible usage options
|
|
9
|
+
|
|
10
|
+
- [a CLI](https://grafast.com/ruru/cli) - temporary or installed
|
|
11
|
+
- [a Node.js middleware](https://grafast.com/ruru/server)
|
|
12
|
+
- [a static HTML file](https://grafast.com/ruru/html) - hosted or self-hosted
|
|
13
|
+
- [embedded](https://grafast.com/ruru/html#embedded) - render Ruru into your
|
|
14
|
+
existing HTML pages
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
See it in action at:
|
|
17
|
+
|
|
18
|
+
https://grafast.com/myruru/#endpoint=https://countries.trevorblades.com/graphql
|
|
11
19
|
|
|
12
20
|
If you have Node installed, you can instantly run `ruru` without permanently
|
|
13
21
|
installing it using the `npx` command. Here's an example command to explore
|
|
@@ -20,245 +28,12 @@ npx ruru -SPe https://countries.trevorblades.com/graphql
|
|
|
20
28
|
(`-S` enables subscriptions, `-P` proxies GraphQL requests; neither of these are
|
|
21
29
|
needed for Trevor's API, but you might want them for your API.)
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Install Ruru:
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
yarn add ruru
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Then you can run something like the following to automatically proxy requests
|
|
32
|
-
(bypassing CORS issues):
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
yarn ruru -SPe http://localhost:5678/graphql
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Usage:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
ruru
|
|
42
|
-
|
|
43
|
-
Run a Ruru server
|
|
44
|
-
|
|
45
|
-
Options:
|
|
46
|
-
--help Show help [boolean]
|
|
47
|
-
--version Show version number [boolean]
|
|
48
|
-
-e, --endpoint endpoint for query and mutation operations
|
|
49
|
-
[string] [default: "http://localhost:5678/graphql"]
|
|
50
|
-
-p, --port port number to run the server on [number] [default: 1337]
|
|
51
|
-
-P, --proxy Proxy requests to work around CORS issues [boolean]
|
|
52
|
-
-S, --subscriptions enable subscriptions, converting --endpoint to a ws:// URL [boolean] [default: false]
|
|
53
|
-
-s, --subscription-endpoint endpoint for subscription operations (overrides -S) [string]
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Usage - server
|
|
57
|
-
|
|
58
|
-
You can render Ruru from your own server, you should serve both the Ruru HTML
|
|
59
|
-
and the static files (JS, CSS, etc) that Ruru needs. We bundle everything you
|
|
60
|
-
need, and hooking it up should be relatively straightforward.
|
|
61
|
-
|
|
62
|
-
### Example: express
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import express from "express";
|
|
66
|
-
import { ruruHTML } from "ruru/server";
|
|
67
|
-
import { serveStatic } from "ruru/static";
|
|
68
|
-
|
|
69
|
-
const app = express();
|
|
70
|
-
|
|
71
|
-
const config = { staticPath: "/ruru-static/", endpoint: "/graphql" };
|
|
72
|
-
// Serve Ruru HTML
|
|
73
|
-
app.get("/", (req, res) => {
|
|
74
|
-
res.format({
|
|
75
|
-
html: () => res.status(200).send(ruruHTML(config)),
|
|
76
|
-
default: () => res.status(406).send("Not Acceptable"),
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
// Serve static files
|
|
80
|
-
app.use(serveStatic(config.staticPath));
|
|
81
|
-
|
|
82
|
-
// Don't forget to serve your GraphQL endpoint:
|
|
83
|
-
//
|
|
84
|
-
// app.post("/graphql", ...);
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Example: node
|
|
88
|
-
|
|
89
|
-
```ts
|
|
90
|
-
import { createServer } from "node:http";
|
|
91
|
-
import { ruruHTML } from "ruru/server";
|
|
92
|
-
import { serveStatic } from "ruru/static";
|
|
93
|
-
|
|
94
|
-
const config = {
|
|
95
|
-
staticPath: "/ruru-static/",
|
|
96
|
-
endpoint: "https://example.com/graphql", // Your endpoint
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Create the static middleware _ONCE ONLY_ for efficiency.
|
|
100
|
-
const staticMiddleware = serveStatic(config.staticPath);
|
|
101
|
-
|
|
102
|
-
// Create your HTTP server
|
|
103
|
-
const server = createServer((req, res) => {
|
|
104
|
-
if (req.url === "/") {
|
|
105
|
-
// Serve Ruru HTML
|
|
106
|
-
const html = ruruHTML(config);
|
|
107
|
-
res.writeHead(200, {
|
|
108
|
-
"content-type": "text/html",
|
|
109
|
-
"content-length": html.length,
|
|
110
|
-
});
|
|
111
|
-
res.end(html);
|
|
112
|
-
return;
|
|
113
|
-
} else {
|
|
114
|
-
// Serve static files
|
|
115
|
-
return staticMiddleware(req, res);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### `config`
|
|
121
|
-
|
|
122
|
-
No matter which server you're using you'll need a Ruru config object which
|
|
123
|
-
should contain at least the following:
|
|
124
|
-
|
|
125
|
-
- `staticPath`: the URL path on your server from which static assets should be
|
|
126
|
-
served - this must start and end with a slash
|
|
127
|
-
- `endpoint`: where to find the GraphQL endpoint - an absolute URL starting
|
|
128
|
-
either with `/` for same-domain, or `http://` / `https://`.
|
|
31
|
+
**Documentation**: https://grafast.com/ruru
|
|
129
32
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const html = ruruHTML(config);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
This function will return you the HTML to render to the user when they request
|
|
139
|
-
the Ruru endpoint; serve it as HTML as you normally would. Use it at whatever
|
|
140
|
-
URL you wish to render Ruru.
|
|
141
|
-
|
|
142
|
-
### `serveStatic(staticPath)`
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import { serveStatic } from "ruru/static";
|
|
146
|
-
|
|
147
|
-
const staticMiddleware = serveStatic(config.staticPath);
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
This will return a middleware compatible with Node, Express, Connect and similar
|
|
151
|
-
servers to serve the static files that Ruru depends on. You must pass it the
|
|
152
|
-
same `staticPath` that you passed to `ruruHTML(config)`.
|
|
153
|
-
|
|
154
|
-
### `getStaticFile(context)`
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
import { getStaticFile } from "ruru/static";
|
|
158
|
-
|
|
159
|
-
const file = await getStaticFile({
|
|
160
|
-
staticPath: config.staticPath,
|
|
161
|
-
urlPath: request.url,
|
|
162
|
-
acceptEncoding: request.headers["accept-encoding"],
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
The `serveStatic` middleware works for Express, Connect, Node and some others,
|
|
167
|
-
but if you're not using these then we give you a simple function you can use to
|
|
168
|
-
serve the required static file from _any_ Node.js based server framework.
|
|
169
|
-
|
|
170
|
-
Context is an object with the following values:
|
|
171
|
-
|
|
172
|
-
- `staticPath` - the same `staticPath` as found in `config.staticPath` passed to
|
|
173
|
-
`ruruHTML` above
|
|
174
|
-
- `urlPath` - the path the current HTTP request requested (must start with `/`,
|
|
175
|
-
can include query string)
|
|
176
|
-
- `acceptEncoding` - the value of the `Accept-Encoding` HTTP header, or
|
|
177
|
-
`undefined` if not set
|
|
178
|
-
- `disallowDevAssets` (optional) - set to `true` to forbid sending source maps
|
|
179
|
-
(reduces server memory pressure by about 10MB at the cost of debuggability)
|
|
180
|
-
|
|
181
|
-
The result is either `null` if the file isn't found, or an object containing:
|
|
182
|
-
|
|
183
|
-
- `headers` - a headers object to set on the response (Content-Type,
|
|
184
|
-
Content-Length, Content-Encoding, etc)
|
|
185
|
-
- `content` - a buffer containing the data to serve
|
|
186
|
-
|
|
187
|
-
Use your framework to serve this as appropriate:
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
// This is an **IMAGINARY** server API, adjust to fit your server.
|
|
191
|
-
|
|
192
|
-
if (file) {
|
|
193
|
-
// Found!
|
|
194
|
-
const { etag } = file.headers;
|
|
195
|
-
if (request.headers["if-none-match"] === etag) {
|
|
196
|
-
response.status(304).headers({ etag }).send(); // Don't serve; etag matched!
|
|
197
|
-
} else {
|
|
198
|
-
response.status(200).headers(file.headers).send(file.content);
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
response.status(404).send("Not Found");
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Usage - bundle
|
|
206
|
-
|
|
207
|
-
```html
|
|
208
|
-
<!-- Required below here -->
|
|
209
|
-
<div id="ruru-root"></div>
|
|
210
|
-
<script type="module">
|
|
211
|
-
const RURU_STATIC = "https://unpkg.com/ruru/static/";
|
|
212
|
-
// Setup Monaco Editor workers
|
|
213
|
-
const worker = (file) =>
|
|
214
|
-
new Worker(new URL(RURU_STATIC + file), { type: "module" });
|
|
215
|
-
globalThis.MonacoEnvironment = {
|
|
216
|
-
getWorker(_workerId, label) {
|
|
217
|
-
switch (label) {
|
|
218
|
-
case "json":
|
|
219
|
-
return worker("jsonWorker.js");
|
|
220
|
-
case "graphql":
|
|
221
|
-
return worker("graphqlWorker.js");
|
|
222
|
-
default:
|
|
223
|
-
return worker("editorWorker.js");
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// Load Ruru
|
|
229
|
-
const { React, createRoot, Ruru } = await import(RURU_STATIC + "ruru.js");
|
|
230
|
-
|
|
231
|
-
// Render
|
|
232
|
-
const tree = React.createElement(Ruru, {
|
|
233
|
-
endpoint: "/graphql",
|
|
234
|
-
});
|
|
235
|
-
const container = document.getElementById("ruru-root");
|
|
236
|
-
const root = createRoot(container);
|
|
237
|
-
root.render(tree);
|
|
238
|
-
</script>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
## Why "ruru"?
|
|
242
|
-
|
|
243
|
-
Jem and I are big fans of the late Terry Pratchett's Discworld universe. The
|
|
244
|
-
city at the centre of many a Discworld tale is the twin-city city-state of
|
|
245
|
-
Ankh-Morpork. A "morepork" is a type of New Zealand owl, known in Māori as
|
|
246
|
-
"ruru." Owls have excellent sight, and Ruru helps you to get an insight into not
|
|
247
|
-
just the inputs and outputs of your API, but also what it does internally.
|
|
248
|
-
|
|
249
|
-
RURU is also an abbreviation for checks to use when gathering information: "is
|
|
250
|
-
it Reliable, Up-to-date, Relevant, and Useful?" We hope that you'll find Ruru to
|
|
251
|
-
be all those things!
|
|
252
|
-
|
|
253
|
-
<details>
|
|
254
|
-
<summary>And this last reason is a little ru-rude...</summary>
|
|
255
|
-
|
|
256
|
-
... in the Quechua languages, the term "ruru" may refer to, among other things,
|
|
257
|
-
"testicle." So when your GraphQL operation isn't doing what you expect and
|
|
258
|
-
you're thinking to yourself "this is b\*ll\*cks," then you'll know this is a job
|
|
259
|
-
for Ruru!
|
|
260
|
-
|
|
261
|
-
</details>
|
|
33
|
+
**PRERELEASE**: this is pre-release software; use at your own risk and do not
|
|
34
|
+
embed into public-facing projects. This will likely change a lot before it's
|
|
35
|
+
ultimately released. The pre-release nature also explains the shocking lack of
|
|
36
|
+
documentation.
|
|
262
37
|
|
|
263
38
|
[GNU Terry Pratchett](http://www.gnuterrypratchett.com/)
|
|
264
39
|
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA+G9E,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAElD,uDAAuD;IACvD,WAAW,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACvC,sDAAsD;IACtD,UAAU,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IACrC,2DAA2D;IAC3D,eAAe,CAAC,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;CAChD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAkGrE;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,gBAAgB,EACxB,SAAS,gBAAwB,UAmBlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,MAAM;YACd,IAAI,CAAC,EAAE,UAAU,CAAC;SACnB;KACF;CACF"}
|
package/dist/server.js
CHANGED
|
@@ -91,6 +91,12 @@ const baseBodyScripts = html `
|
|
|
91
91
|
$(".graphiql-plugin").style.display = "none";
|
|
92
92
|
$(".graphiql-horizontal-drag-bar").style.display = "none";
|
|
93
93
|
}
|
|
94
|
+
const getSystemTheme = () =>
|
|
95
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
96
|
+
? "dark"
|
|
97
|
+
: "light";
|
|
98
|
+
const theme = localStorage.getItem("graphiql:theme") || getSystemTheme();
|
|
99
|
+
document.body.className += " graphiql-" + theme;
|
|
94
100
|
const flexes = [
|
|
95
101
|
["docExplorerFlex", ".graphiql-plugin"],
|
|
96
102
|
["editorFlex", ".graphiql-editors"],
|
|
@@ -119,21 +125,6 @@ function makeHTMLParts(config) {
|
|
|
119
125
|
const baseMetaTags = html `
|
|
120
126
|
<meta charset="utf-8" />
|
|
121
127
|
<link rel="modulepreload" href="${escapeHTML(staticPath + "ruru.js")}" />
|
|
122
|
-
<link
|
|
123
|
-
rel="modulepreload"
|
|
124
|
-
href="${escapeHTML(staticPath + "jsonWorker.js")}"
|
|
125
|
-
as="worker"
|
|
126
|
-
/>
|
|
127
|
-
<link
|
|
128
|
-
rel="modulepreload"
|
|
129
|
-
href="${escapeHTML(staticPath + "graphqlWorker.js")}"
|
|
130
|
-
as="worker"
|
|
131
|
-
/>
|
|
132
|
-
<link
|
|
133
|
-
rel="modulepreload"
|
|
134
|
-
href="${escapeHTML(staticPath + "editorWorker.js")}"
|
|
135
|
-
as="worker"
|
|
136
|
-
/>
|
|
137
128
|
`;
|
|
138
129
|
const baseStyleTags = html `
|
|
139
130
|
<link rel="stylesheet" href="${staticPath}ruru.css" />
|
|
@@ -148,16 +139,21 @@ function makeHTMLParts(config) {
|
|
|
148
139
|
`;
|
|
149
140
|
const baseConfigScript = html `
|
|
150
141
|
<script>
|
|
151
|
-
const RURU_CONFIG = ${escapeJS(JSON.stringify(clientConfig))};
|
|
142
|
+
const RURU_CONFIG = ${escapeJS(JSON.stringify(clientConfig, null, 2))};
|
|
152
143
|
</script>
|
|
153
144
|
`;
|
|
154
145
|
const baseHeaderScripts = html `
|
|
155
146
|
<script type="module">
|
|
156
|
-
const worker = (file) =>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
const worker = (file) => new Worker(${
|
|
148
|
+
/*
|
|
149
|
+
* For local paths we can load the static files directly; but for
|
|
150
|
+
* remote URLs we'll get security issues if we do, so instead we
|
|
151
|
+
* create a file that imports the remote file. I do not understand
|
|
152
|
+
* the security basis that allows this to work... but it does.
|
|
153
|
+
*/
|
|
154
|
+
staticPath.startsWith("/")
|
|
155
|
+
? `new URL(${JSON.stringify(staticPath)} + file, import.meta.url)`
|
|
156
|
+
: `URL.createObjectURL(new Blob(['import "${staticPath}' + file + '";'], {type: 'text/javascript'}))`}, { type: "module" });
|
|
161
157
|
globalThis.MonacoEnvironment = {
|
|
162
158
|
getWorker(_, label) {
|
|
163
159
|
switch (label) {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AAiIA,sCAkGC;AAED,4BAqBC;AAnPD,6CAAuC;AAGvC,MAAM,mBAAmB,GAAG,0BAA0B,oBAAO,UAAU,CAAC;AAExE,4CAA4C;AAC5C,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;IAC/B,OAAO,GAAG;SACP,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;SAC5B,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC;SACpC,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA2B;IACvC,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;CACZ,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAC;AAEhF,SAAS,IAAI,CAAC,GAAyB,EAAE,GAAG,YAAsB;IAChE,MAAM,KAAK,GAAG,GAAG;SACd,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;SAC5D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;EAClB,SAAS,CAAC,SAAS;EACnB,SAAS,CAAC,YAAY;EACtB,SAAS,CAAC,aAAa;;;EAGvB,SAAS,CAAC,WAAW;EACrB,SAAS,CAAC,WAAW;EACrB,SAAS,CAAC,cAAc;;;CAGzB,CAAC;AACF,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.0.0-beta.
|
|
1
|
+
export declare const version = "2.0.0-beta.26";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruru",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.26",
|
|
4
4
|
"description": "Grafast-flavoured GraphiQL distribution",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"webpack": "node --loader ts-node/esm \"$(yarn bin webpack-cli)\" --config webpack.config.mts",
|
|
32
32
|
"watch": "yarn webpack --watch --mode=development",
|
|
33
|
-
"
|
|
33
|
+
"make-ruru-html": "node --experimental-strip-types scripts/make-ruru-html.mts",
|
|
34
|
+
"prepack": "rm -Rf dist static tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && yarn webpack --mode=production && tsc -b tsconfig.build.json && cp src/.npmignore dist/ && chmod +x dist/cli-run.js && yarn make-ruru-html"
|
|
34
35
|
},
|
|
35
36
|
"repository": {
|
|
36
37
|
"type": "git",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
"files": [
|
|
76
|
+
"ruru.html",
|
|
75
77
|
"dist",
|
|
76
78
|
"static"
|
|
77
79
|
],
|
package/ruru.html
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="modulepreload" href="https://unpkg.com/ruru@2.0.0-beta.26/static/ruru.js" />
|
|
6
|
+
<title>Ruru - GraphQL/Grafast IDE</title>
|
|
7
|
+
<link rel="stylesheet" href="https://unpkg.com/ruru@2.0.0-beta.26/static/ruru.css" />
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
#ruru-root {
|
|
13
|
+
height: 100vh;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
<script>
|
|
17
|
+
const RURU_CONFIG = {
|
|
18
|
+
"staticPath": "https://unpkg.com/ruru@2.0.0-beta.26/static/",
|
|
19
|
+
// Replace this with your own endpoint:
|
|
20
|
+
"endpoint": "/graphql",
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<!-- DELETE THIS once you have the correct 'endpoint' in RURU_CONFIG above -->
|
|
25
|
+
<script type="module">
|
|
26
|
+
// Extract 'endpoint=...' from the hash params
|
|
27
|
+
const { hash } = window.location;
|
|
28
|
+
if (hash.startsWith('#')) {
|
|
29
|
+
const params = new URLSearchParams(window.location.hash.slice(1));
|
|
30
|
+
const endpoint = params.get('endpoint');
|
|
31
|
+
if (endpoint) RURU_CONFIG.endpoint = endpoint;
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
<!-- /DELETE THIS -->
|
|
35
|
+
|
|
36
|
+
<script type="module">
|
|
37
|
+
const worker = (file) => new Worker(URL.createObjectURL(new Blob(['import "https://unpkg.com/ruru@2.0.0-beta.26/static/' + file + '";'], {type: 'text/javascript'})), { type: "module" });
|
|
38
|
+
globalThis.MonacoEnvironment = {
|
|
39
|
+
getWorker(_, label) {
|
|
40
|
+
switch (label) {
|
|
41
|
+
case "json":
|
|
42
|
+
return worker("jsonWorker.js");
|
|
43
|
+
case "graphql":
|
|
44
|
+
return worker("graphqlWorker.js");
|
|
45
|
+
default:
|
|
46
|
+
return worker("editorWorker.js");
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
51
|
+
</head>
|
|
52
|
+
<body>
|
|
53
|
+
<div id="ruru-root">
|
|
54
|
+
<div class="graphiql-container">
|
|
55
|
+
<div class="graphiql-sidebar"></div>
|
|
56
|
+
<div class="graphiql-main">
|
|
57
|
+
<div
|
|
58
|
+
class="graphiql-plugin"
|
|
59
|
+
style="min-width: 200px; flex: 0.333333 1 0%;"
|
|
60
|
+
>
|
|
61
|
+
<div>
|
|
62
|
+
<div class="graphiql-doc-explorer-header">
|
|
63
|
+
<div class="graphiql-doc-explorer-title">Loading...</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="graphiql-doc-explorer-content">
|
|
66
|
+
<p>Ruru is loading, this should only take a moment...</p>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<div class="graphiql-horizontal-drag-bar"></div>
|
|
71
|
+
<div class="graphiql-sessions" style="flex: 1 1 0%;">
|
|
72
|
+
<div class="graphiql-session-header">
|
|
73
|
+
<ul role="tablist" class="graphiql-tabs no-scrollbar">
|
|
74
|
+
<li class="graphiql-tab graphiql-tab-active">
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
class="graphiql-un-styled graphiql-tab-button"
|
|
78
|
+
disabled
|
|
79
|
+
>
|
|
80
|
+
Loading...
|
|
81
|
+
</button>
|
|
82
|
+
</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</div>
|
|
85
|
+
<div role="tabpanel" id="graphiql-session">
|
|
86
|
+
<div class="graphiql-editors" style="flex: 1 1 0%;">
|
|
87
|
+
<section class="graphiql-query-editor" style="flex: 3 1 0%;">
|
|
88
|
+
<div class="graphiql-editor"></div>
|
|
89
|
+
<div class="graphiql-toolbar"></div>
|
|
90
|
+
</section>
|
|
91
|
+
<div class="graphiql-editor-tools">
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
class="graphiql-un-styled active"
|
|
95
|
+
disabled
|
|
96
|
+
>
|
|
97
|
+
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="graphiql-horizontal-drag-bar"></div>
|
|
102
|
+
<div class="graphiql-response" style="flex: 1 1 0%;">
|
|
103
|
+
<section class="result-window"></section>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
<script type="module">
|
|
111
|
+
const $ = (s) => document.querySelector(s);
|
|
112
|
+
if (!localStorage.getItem("graphiql:visiblePlugin")) {
|
|
113
|
+
$(".graphiql-plugin").style.display = "none";
|
|
114
|
+
$(".graphiql-horizontal-drag-bar").style.display = "none";
|
|
115
|
+
}
|
|
116
|
+
const getSystemTheme = () =>
|
|
117
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
118
|
+
? "dark"
|
|
119
|
+
: "light";
|
|
120
|
+
const theme = localStorage.getItem("graphiql:theme") || getSystemTheme();
|
|
121
|
+
document.body.className += " graphiql-" + theme;
|
|
122
|
+
const flexes = [
|
|
123
|
+
["docExplorerFlex", ".graphiql-plugin"],
|
|
124
|
+
["editorFlex", ".graphiql-editors"],
|
|
125
|
+
];
|
|
126
|
+
for (const [key, sel] of flexes) {
|
|
127
|
+
const val = localStorage.getItem("graphiql:" + key);
|
|
128
|
+
if (val) $(sel).style.flex = val + " 1 0%";
|
|
129
|
+
}
|
|
130
|
+
</script>
|
|
131
|
+
<script type="module">
|
|
132
|
+
import { React, createRoot, Ruru } from "https://unpkg.com/ruru@2.0.0-beta.26/static/ruru.js";
|
|
133
|
+
createRoot(document.getElementById("ruru-root"))
|
|
134
|
+
.render(React.createElement(Ruru, RURU_CONFIG));
|
|
135
|
+
</script>
|
|
136
|
+
</body>
|
|
137
|
+
</html>
|