@graffy/explore 0.15.25-alpha.1 → 0.15.25-alpha.2
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/index.cjs +56 -82
- package/index.mjs +26 -46
- package/package.json +6 -6
package/index.cjs
CHANGED
|
@@ -1,74 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (__hasOwnProp.call(b, prop))
|
|
10
|
-
__defNormalProp(a, prop, b[prop]);
|
|
11
|
-
if (__getOwnPropSymbols)
|
|
12
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
-
if (__propIsEnum.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
}
|
|
16
|
-
return a;
|
|
17
|
-
};
|
|
18
|
-
var __objRest = (source, exclude) => {
|
|
19
|
-
var target = {};
|
|
20
|
-
for (var prop in source)
|
|
21
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
22
|
-
target[prop] = source[prop];
|
|
23
|
-
if (source != null && __getOwnPropSymbols)
|
|
24
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
25
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
}
|
|
28
|
-
return target;
|
|
29
|
-
};
|
|
30
|
-
var React = require("react");
|
|
31
|
-
var Graffy = require("@graffy/core");
|
|
32
|
-
var GraffyFill = require("@graffy/fill");
|
|
33
|
-
var GraffyClient = require("@graffy/client");
|
|
34
|
-
var react = require("@graffy/react");
|
|
35
|
-
var common = require("@graffy/common");
|
|
36
|
-
function _interopDefaultLegacy(e) {
|
|
37
|
-
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
38
|
-
}
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const Graffy = require("@graffy/core");
|
|
4
|
+
const GraffyFill = require("@graffy/fill");
|
|
5
|
+
const GraffyClient = require("@graffy/client");
|
|
6
|
+
const react = require("@graffy/react");
|
|
7
|
+
const common = require("@graffy/common");
|
|
8
|
+
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
39
9
|
function _interopNamespace(e) {
|
|
40
10
|
if (e && e.__esModule)
|
|
41
11
|
return e;
|
|
42
|
-
|
|
12
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
43
13
|
if (e) {
|
|
44
|
-
|
|
14
|
+
for (const k in e) {
|
|
45
15
|
if (k !== "default") {
|
|
46
|
-
|
|
16
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
47
17
|
Object.defineProperty(n, k, d.get ? d : {
|
|
48
18
|
enumerable: true,
|
|
49
|
-
get:
|
|
50
|
-
return e[k];
|
|
51
|
-
}
|
|
19
|
+
get: () => e[k]
|
|
52
20
|
});
|
|
53
21
|
}
|
|
54
|
-
}
|
|
22
|
+
}
|
|
55
23
|
}
|
|
56
|
-
n
|
|
24
|
+
n.default = e;
|
|
57
25
|
return Object.freeze(n);
|
|
58
26
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
27
|
+
const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
|
|
28
|
+
const Graffy__default = /* @__PURE__ */ _interopDefaultLegacy(Graffy);
|
|
29
|
+
const GraffyFill__default = /* @__PURE__ */ _interopDefaultLegacy(GraffyFill);
|
|
30
|
+
const GraffyClient__default = /* @__PURE__ */ _interopDefaultLegacy(GraffyClient);
|
|
31
|
+
const common__namespace = /* @__PURE__ */ _interopNamespace(common);
|
|
64
32
|
function Result({ result, loading, error }) {
|
|
65
|
-
return /* @__PURE__ */ React__default
|
|
33
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, loading ? /* @__PURE__ */ React__default.default.createElement("div", {
|
|
66
34
|
className: "status"
|
|
67
|
-
}, "Loading...") : error ? /* @__PURE__ */ React__default
|
|
35
|
+
}, "Loading...") : error ? /* @__PURE__ */ React__default.default.createElement("div", {
|
|
68
36
|
className: "error"
|
|
69
|
-
}, error.toString()) : result ? /* @__PURE__ */ React__default
|
|
37
|
+
}, error.toString()) : result ? /* @__PURE__ */ React__default.default.createElement("pre", null, JSON.stringify(result, null, 2)) : /* @__PURE__ */ React__default.default.createElement("div", {
|
|
70
38
|
className: "status"
|
|
71
|
-
}, "No results"), /* @__PURE__ */ React__default
|
|
39
|
+
}, "No results"), /* @__PURE__ */ React__default.default.createElement("style", {
|
|
72
40
|
jsx: true
|
|
73
41
|
}, `
|
|
74
42
|
.error {
|
|
@@ -93,13 +61,16 @@ function Explore(options) {
|
|
|
93
61
|
const [result, setResult] = React.useState(null);
|
|
94
62
|
const [watching, setWatching] = React.useState(null);
|
|
95
63
|
const store = react.useStore();
|
|
96
|
-
const onInputEnd = React.useCallback(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
64
|
+
const onInputEnd = React.useCallback(
|
|
65
|
+
(event) => {
|
|
66
|
+
try {
|
|
67
|
+
setInput(evaluate(event.target.textContent));
|
|
68
|
+
} catch (e) {
|
|
69
|
+
setError(e.message);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[setInput, setError]
|
|
73
|
+
);
|
|
103
74
|
const onInputStart = React.useCallback(() => setError(null), [setError]);
|
|
104
75
|
const onReadClick = async () => {
|
|
105
76
|
setWatching(false);
|
|
@@ -128,31 +99,35 @@ function Explore(options) {
|
|
|
128
99
|
setLoading(false);
|
|
129
100
|
setWatching((w) => !w);
|
|
130
101
|
};
|
|
131
|
-
return /* @__PURE__ */ React__default
|
|
102
|
+
return /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement("pre", {
|
|
132
103
|
className: "editor",
|
|
133
104
|
contentEditable: true,
|
|
134
105
|
onFocus: onInputStart,
|
|
135
106
|
onBlur: onInputEnd
|
|
136
|
-
}), /* @__PURE__ */ React__default
|
|
107
|
+
}), /* @__PURE__ */ React__default.default.createElement("div", {
|
|
137
108
|
className: "opbar"
|
|
138
|
-
}, /* @__PURE__ */ React__default
|
|
109
|
+
}, /* @__PURE__ */ React__default.default.createElement("button", {
|
|
139
110
|
className: "opbtn",
|
|
140
111
|
disabled: watching,
|
|
141
112
|
onClick: onReadClick
|
|
142
|
-
}, "read()"), /* @__PURE__ */ React__default
|
|
113
|
+
}, "read()"), /* @__PURE__ */ React__default.default.createElement("button", {
|
|
143
114
|
className: "opbtn",
|
|
144
115
|
disabled: watching,
|
|
145
116
|
onClick: onWriteClick
|
|
146
|
-
}, "write()"), /* @__PURE__ */ React__default
|
|
117
|
+
}, "write()"), /* @__PURE__ */ React__default.default.createElement("button", {
|
|
147
118
|
className: "opbtn",
|
|
148
119
|
"data-active": watching,
|
|
149
120
|
onClick: onWatchClick
|
|
150
|
-
}, "watch()")), error ? /* @__PURE__ */ React__default
|
|
121
|
+
}, "watch()")), error ? /* @__PURE__ */ React__default.default.createElement("div", {
|
|
151
122
|
className: "error"
|
|
152
|
-
}, error) : watching ? /* @__PURE__ */ React__default
|
|
123
|
+
}, error) : watching ? /* @__PURE__ */ React__default.default.createElement(react.Query, {
|
|
153
124
|
query: input,
|
|
154
125
|
options
|
|
155
|
-
}, (props) => /* @__PURE__ */ React__default
|
|
126
|
+
}, (props) => /* @__PURE__ */ React__default.default.createElement(Result, {
|
|
127
|
+
...props
|
|
128
|
+
})) : /* @__PURE__ */ React__default.default.createElement(Result, {
|
|
129
|
+
...{ result, loading, error }
|
|
130
|
+
}), /* @__PURE__ */ React__default.default.createElement("style", {
|
|
156
131
|
jsx: true
|
|
157
132
|
}, `
|
|
158
133
|
.error {
|
|
@@ -195,25 +170,24 @@ function Explore(options) {
|
|
|
195
170
|
}
|
|
196
171
|
`));
|
|
197
172
|
}
|
|
198
|
-
function ExploreContainer(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"baseUrl",
|
|
204
|
-
"getOptions"
|
|
205
|
-
]);
|
|
173
|
+
function ExploreContainer({
|
|
174
|
+
baseUrl = "/",
|
|
175
|
+
getOptions,
|
|
176
|
+
...options
|
|
177
|
+
}) {
|
|
206
178
|
const [store, setStore] = React.useState();
|
|
207
179
|
React.useEffect(() => {
|
|
208
|
-
const store2 = new Graffy__default
|
|
209
|
-
store2.use(GraffyFill__default
|
|
210
|
-
store2.use(GraffyClient__default
|
|
180
|
+
const store2 = new Graffy__default.default();
|
|
181
|
+
store2.use(GraffyFill__default.default());
|
|
182
|
+
store2.use(GraffyClient__default.default(baseUrl, { getOptions }));
|
|
211
183
|
setStore(store2);
|
|
212
184
|
window.store = store2;
|
|
213
185
|
window.graffy = common__namespace;
|
|
214
186
|
}, [baseUrl]);
|
|
215
|
-
return store ? /* @__PURE__ */ React__default
|
|
187
|
+
return store ? /* @__PURE__ */ React__default.default.createElement(react.GraffyProvider, {
|
|
216
188
|
store
|
|
217
|
-
}, /* @__PURE__ */ React__default
|
|
189
|
+
}, /* @__PURE__ */ React__default.default.createElement(Explore, {
|
|
190
|
+
...options
|
|
191
|
+
})) : null;
|
|
218
192
|
}
|
|
219
193
|
module.exports = ExploreContainer;
|
package/index.mjs
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
var __objRest = (source, exclude) => {
|
|
18
|
-
var target = {};
|
|
19
|
-
for (var prop in source)
|
|
20
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
-
target[prop] = source[prop];
|
|
22
|
-
if (source != null && __getOwnPropSymbols)
|
|
23
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
1
|
import React, { useState, useCallback, useEffect } from "react";
|
|
30
2
|
import Graffy from "@graffy/core";
|
|
31
3
|
import GraffyFill from "@graffy/fill";
|
|
@@ -64,13 +36,16 @@ function Explore(options) {
|
|
|
64
36
|
const [result, setResult] = useState(null);
|
|
65
37
|
const [watching, setWatching] = useState(null);
|
|
66
38
|
const store = useStore();
|
|
67
|
-
const onInputEnd = useCallback(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
const onInputEnd = useCallback(
|
|
40
|
+
(event) => {
|
|
41
|
+
try {
|
|
42
|
+
setInput(evaluate(event.target.textContent));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
setError(e.message);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[setInput, setError]
|
|
48
|
+
);
|
|
74
49
|
const onInputStart = useCallback(() => setError(null), [setError]);
|
|
75
50
|
const onReadClick = async () => {
|
|
76
51
|
setWatching(false);
|
|
@@ -123,7 +98,11 @@ function Explore(options) {
|
|
|
123
98
|
}, error) : watching ? /* @__PURE__ */ React.createElement(Query, {
|
|
124
99
|
query: input,
|
|
125
100
|
options
|
|
126
|
-
}, (props) => /* @__PURE__ */ React.createElement(Result,
|
|
101
|
+
}, (props) => /* @__PURE__ */ React.createElement(Result, {
|
|
102
|
+
...props
|
|
103
|
+
})) : /* @__PURE__ */ React.createElement(Result, {
|
|
104
|
+
...{ result, loading, error }
|
|
105
|
+
}), /* @__PURE__ */ React.createElement("style", {
|
|
127
106
|
jsx: true
|
|
128
107
|
}, `
|
|
129
108
|
.error {
|
|
@@ -166,14 +145,11 @@ function Explore(options) {
|
|
|
166
145
|
}
|
|
167
146
|
`));
|
|
168
147
|
}
|
|
169
|
-
function ExploreContainer(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"baseUrl",
|
|
175
|
-
"getOptions"
|
|
176
|
-
]);
|
|
148
|
+
function ExploreContainer({
|
|
149
|
+
baseUrl = "/",
|
|
150
|
+
getOptions,
|
|
151
|
+
...options
|
|
152
|
+
}) {
|
|
177
153
|
const [store, setStore] = useState();
|
|
178
154
|
useEffect(() => {
|
|
179
155
|
const store2 = new Graffy();
|
|
@@ -185,6 +161,10 @@ function ExploreContainer(_a) {
|
|
|
185
161
|
}, [baseUrl]);
|
|
186
162
|
return store ? /* @__PURE__ */ React.createElement(GraffyProvider, {
|
|
187
163
|
store
|
|
188
|
-
}, /* @__PURE__ */ React.createElement(Explore,
|
|
164
|
+
}, /* @__PURE__ */ React.createElement(Explore, {
|
|
165
|
+
...options
|
|
166
|
+
})) : null;
|
|
189
167
|
}
|
|
190
|
-
export {
|
|
168
|
+
export {
|
|
169
|
+
ExploreContainer as default
|
|
170
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/explore",
|
|
3
3
|
"description": "Graffy client library for the browser.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.15.25-alpha.
|
|
5
|
+
"version": "0.15.25-alpha.2",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/core": "0.15.25-alpha.
|
|
20
|
-
"@graffy/fill": "0.15.25-alpha.
|
|
21
|
-
"@graffy/client": "0.15.25-alpha.
|
|
22
|
-
"@graffy/react": "0.15.25-alpha.
|
|
23
|
-
"@graffy/common": "0.15.25-alpha.
|
|
19
|
+
"@graffy/core": "0.15.25-alpha.2",
|
|
20
|
+
"@graffy/fill": "0.15.25-alpha.2",
|
|
21
|
+
"@graffy/client": "0.15.25-alpha.2",
|
|
22
|
+
"@graffy/react": "0.15.25-alpha.2",
|
|
23
|
+
"@graffy/common": "0.15.25-alpha.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.8.0 || ^17.0.0"
|