@graffy/explore 0.17.8-alpha.2 → 0.17.8-alpha.3

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 (3) hide show
  1. package/index.cjs +14 -14
  2. package/index.mjs +1 -1
  3. package/package.json +6 -6
package/index.cjs CHANGED
@@ -3,8 +3,8 @@ const GraffyClient = require("@graffy/client");
3
3
  const common = require("@graffy/common");
4
4
  const Graffy = require("@graffy/core");
5
5
  const GraffyFill = require("@graffy/fill");
6
- const react = require("@graffy/react");
7
- const React = require("react");
6
+ const react$1 = require("@graffy/react");
7
+ const react = require("react");
8
8
  function _interopNamespaceDefault(e) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
10
  if (e) {
@@ -40,13 +40,13 @@ function evaluate(expression) {
40
40
  return fn(...names.map((name) => common__namespace[name]));
41
41
  }
42
42
  function Explore(options) {
43
- const [input, setInput] = React.useState({});
44
- const [error, setError] = React.useState(null);
45
- const [loading, setLoading] = React.useState(false);
46
- const [result, setResult] = React.useState(null);
47
- const [watching, setWatching] = React.useState(null);
48
- const store = react.useStore();
49
- const onInputEnd = React.useCallback(
43
+ const [input, setInput] = react.useState({});
44
+ const [error, setError] = react.useState(null);
45
+ const [loading, setLoading] = react.useState(false);
46
+ const [result, setResult] = react.useState(null);
47
+ const [watching, setWatching] = react.useState(null);
48
+ const store = react$1.useStore();
49
+ const onInputEnd = react.useCallback(
50
50
  (event) => {
51
51
  try {
52
52
  setInput(evaluate(event.target.textContent));
@@ -56,7 +56,7 @@ function Explore(options) {
56
56
  },
57
57
  [setInput, setError]
58
58
  );
59
- const onInputStart = React.useCallback(() => setError(null), [setError]);
59
+ const onInputStart = react.useCallback(() => setError(null), [setError]);
60
60
  const onReadClick = async () => {
61
61
  setWatching(false);
62
62
  setLoading(true);
@@ -92,7 +92,7 @@ function Explore(options) {
92
92
  onFocus: onInputStart,
93
93
  onBlur: onInputEnd
94
94
  }
95
- ), /* @__PURE__ */ React.createElement("div", { className: "opbar" }, /* @__PURE__ */ React.createElement("button", { className: "opbtn", disabled: watching, onClick: onReadClick }, "read()"), /* @__PURE__ */ React.createElement("button", { className: "opbtn", disabled: watching, onClick: onWriteClick }, "write()"), /* @__PURE__ */ React.createElement("button", { className: "opbtn", "data-active": watching, onClick: onWatchClick }, "watch()")), error ? /* @__PURE__ */ React.createElement("div", { className: "error" }, error) : watching ? /* @__PURE__ */ React.createElement(react.Query, { query: input, options }, (props) => /* @__PURE__ */ React.createElement(Result, { ...props })) : /* @__PURE__ */ React.createElement(Result, { ...{ result, loading, error } }), /* @__PURE__ */ React.createElement("style", { jsx: true }, `
95
+ ), /* @__PURE__ */ React.createElement("div", { className: "opbar" }, /* @__PURE__ */ React.createElement("button", { className: "opbtn", disabled: watching, onClick: onReadClick }, "read()"), /* @__PURE__ */ React.createElement("button", { className: "opbtn", disabled: watching, onClick: onWriteClick }, "write()"), /* @__PURE__ */ React.createElement("button", { className: "opbtn", "data-active": watching, onClick: onWatchClick }, "watch()")), error ? /* @__PURE__ */ React.createElement("div", { className: "error" }, error) : watching ? /* @__PURE__ */ React.createElement(react$1.Query, { query: input, options }, (props) => /* @__PURE__ */ React.createElement(Result, { ...props })) : /* @__PURE__ */ React.createElement(Result, { ...{ result, loading, error } }), /* @__PURE__ */ React.createElement("style", { jsx: true }, `
96
96
  .error {
97
97
  color: #c00;
98
98
  padding: 1rem;
@@ -138,8 +138,8 @@ function ExploreContainer({
138
138
  getOptions,
139
139
  ...options
140
140
  }) {
141
- const [store, setStore] = React.useState();
142
- React.useEffect(() => {
141
+ const [store, setStore] = react.useState();
142
+ react.useEffect(() => {
143
143
  const store2 = new Graffy();
144
144
  store2.use(GraffyFill());
145
145
  store2.use(GraffyClient(baseUrl, { getOptions }));
@@ -147,6 +147,6 @@ function ExploreContainer({
147
147
  window.store = store2;
148
148
  window.graffy = common__namespace;
149
149
  }, [baseUrl, getOptions]);
150
- return store ? /* @__PURE__ */ React.createElement(react.GraffyProvider, { store }, /* @__PURE__ */ React.createElement(Explore, { ...options })) : null;
150
+ return store ? /* @__PURE__ */ React.createElement(react$1.GraffyProvider, { store }, /* @__PURE__ */ React.createElement(Explore, { ...options })) : null;
151
151
  }
152
152
  module.exports = ExploreContainer;
package/index.mjs CHANGED
@@ -3,7 +3,7 @@ import * as common from "@graffy/common";
3
3
  import Graffy from "@graffy/core";
4
4
  import GraffyFill from "@graffy/fill";
5
5
  import { useStore, Query, GraffyProvider } from "@graffy/react";
6
- import React, { useState, useCallback, useEffect } from "react";
6
+ import { useState, useCallback, useEffect } from "react";
7
7
  function Result({ result, loading, error }) {
8
8
  return /* @__PURE__ */ React.createElement(React.Fragment, null, loading ? /* @__PURE__ */ React.createElement("div", { className: "status" }, "Loading...") : error ? /* @__PURE__ */ React.createElement("div", { className: "error" }, error.toString()) : result ? /* @__PURE__ */ React.createElement("pre", null, JSON.stringify(result, null, 2)) : /* @__PURE__ */ React.createElement("div", { className: "status" }, "No results"), /* @__PURE__ */ React.createElement("style", { jsx: true }, `
9
9
  .error {
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.17.8-alpha.2",
5
+ "version": "0.17.8-alpha.3",
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/client": "0.17.8-alpha.2",
20
- "@graffy/common": "0.17.8-alpha.2",
21
- "@graffy/core": "0.17.8-alpha.2",
22
- "@graffy/fill": "0.17.8-alpha.2",
23
- "@graffy/react": "0.17.8-alpha.2"
19
+ "@graffy/client": "0.17.8-alpha.3",
20
+ "@graffy/common": "0.17.8-alpha.3",
21
+ "@graffy/core": "0.17.8-alpha.3",
22
+ "@graffy/fill": "0.17.8-alpha.3",
23
+ "@graffy/react": "0.17.8-alpha.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"