tinacms 0.62.0 → 0.63.0

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3897ec5d9: Replace `branch`, `clientId`, `isLocalClient` props with single `apiURL`. When working locally, this should be `http://localhost:4001/graphql`. For Tina Cloud, use `https://content.tinajs.io/content/<my-client-id>/github/<my-branch>`
8
+
9
+ ```tsx
10
+ // _app.tsx
11
+ // ...
12
+ <TinaCMS apiURL={process.env.NEXT_PUBLIC_TINA_API_URL} {...pageProps}>
13
+ {livePageProps => <Component {...livePageProps} />}
14
+ </TinaCMS>
15
+ ```
16
+
17
+ DEPRECATION NOTICE: `branch`, `clientId`, `isLocalClient` props will be deprecated in the future
18
+
19
+ ### Patch Changes
20
+
21
+ - 96e4a77e2: Fixed types
22
+ - b5c22503a: Changes messaging on login page for TinaAdmin when in local-mode
23
+ - Updated dependencies [60f939f34]
24
+ - @tinacms/toolkit@0.56.6
25
+
3
26
  ## 0.62.0
4
27
 
5
28
  ### Minor Changes
package/dist/index.es.js CHANGED
@@ -39,6 +39,7 @@ import styled from "styled-components";
39
39
  import * as yup from "yup";
40
40
  import { setEditing, useEditState } from "@tinacms/sharedctx";
41
41
  import { getIn, setIn } from "final-form";
42
+ import UrlPattern from "url-pattern";
42
43
  import { NavLink, useLocation, useParams, Link, useNavigate, BrowserRouter, Routes, Route } from "react-router-dom";
43
44
  import { Menu, Transition } from "@headlessui/react";
44
45
  function popupWindow(url, title, window2, w, h) {
@@ -1475,20 +1476,29 @@ class ErrorBoundary extends React.Component {
1475
1476
  return this.props.children;
1476
1477
  }
1477
1478
  }
1479
+ const parseURL = (url) => {
1480
+ if (url.includes("localhost")) {
1481
+ return { branch: null, isLocalClient: true, clientId: null };
1482
+ }
1483
+ const tinaHost = "content.tinajs.io";
1484
+ const params = new URL(url);
1485
+ const pattern = new UrlPattern("/content/:clientId/github/:branch");
1486
+ const result = pattern.match(params.pathname);
1487
+ if (params.host !== tinaHost) {
1488
+ throw new Error(`The only supported hosts are ${tinaHost} or localhost, but received ${params.host}.`);
1489
+ }
1490
+ return __spreadProps(__spreadValues({}, result), {
1491
+ isLocalClient: false
1492
+ });
1493
+ };
1478
1494
  const TinaCMSProvider2 = (_c) => {
1479
1495
  var _d = _c, {
1480
1496
  children,
1481
- branch,
1482
- clientId,
1483
- isLocalClient,
1484
1497
  cmsCallback,
1485
1498
  mediaStore,
1486
1499
  tinaioConfig
1487
1500
  } = _d, props = __objRest(_d, [
1488
1501
  "children",
1489
- "branch",
1490
- "clientId",
1491
- "isLocalClient",
1492
1502
  "cmsCallback",
1493
1503
  "mediaStore",
1494
1504
  "tinaioConfig"
@@ -1496,6 +1506,14 @@ const TinaCMSProvider2 = (_c) => {
1496
1506
  if (typeof props.query === "string") {
1497
1507
  props.query;
1498
1508
  }
1509
+ if (!props.apiURL && !((props == null ? void 0 : props.clientId) || (props == null ? void 0 : props.isLocalClient))) {
1510
+ throw new Error(`apiURL is a required field`);
1511
+ }
1512
+ const { branch, clientId, isLocalClient } = props.apiURL ? parseURL(props.apiURL) : {
1513
+ branch: props.branch,
1514
+ clientId: props.clientId,
1515
+ isLocalClient: props.isLocalClient
1516
+ };
1499
1517
  return /* @__PURE__ */ React.createElement(TinaCloudProvider, {
1500
1518
  branch,
1501
1519
  clientId,
@@ -1637,10 +1655,10 @@ const staticRequest = async ({
1637
1655
  if (!is_server()) {
1638
1656
  console.warn(`Whoops! Looks like you are using \`staticRequest\` in the browser to fetch data.
1639
1657
 
1640
- The local server is not available outside of \`getStaticProps\` or \`getStaticPaths\` functions.
1658
+ The local server is not available outside of \`getStaticProps\` or \`getStaticPaths\` functions.
1641
1659
  This function should only be called on the server at build time.
1642
1660
 
1643
- This will work when developing locally but NOT when deployed to production.
1661
+ This will work when developing locally but NOT when deployed to production.
1644
1662
  `);
1645
1663
  }
1646
1664
  return client.request(query, { variables });
@@ -1784,7 +1802,7 @@ const AuthTemplate = ({
1784
1802
  return /* @__PURE__ */ React.createElement("div", {
1785
1803
  className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
1786
1804
  }, /* @__PURE__ */ React.createElement("div", {
1787
- className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-md"
1805
+ className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-lg"
1788
1806
  }, /* @__PURE__ */ React.createElement("div", {
1789
1807
  className: "px-5 py-4 border-b border-gray-150"
1790
1808
  }, /* @__PURE__ */ React.createElement("h2", {
@@ -1809,9 +1827,7 @@ const AuthTemplate = ({
1809
1827
  const LoginPage = () => {
1810
1828
  const { setEdit } = useEditState();
1811
1829
  const login = () => setEdit(true);
1812
- return /* @__PURE__ */ React.createElement(AuthTemplate, {
1813
- message: "Please log in to Tina Cloud to access your content."
1814
- }, /* @__PURE__ */ React.createElement("a", {
1830
+ return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("a", {
1815
1831
  href: "/",
1816
1832
  className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
1817
1833
  }, /* @__PURE__ */ React.createElement(MdOutlineArrowBack, {
@@ -1823,7 +1839,7 @@ const LoginPage = () => {
1823
1839
  style: { background: "#0084FF" }
1824
1840
  }, /* @__PURE__ */ React.createElement(BiLogIn, {
1825
1841
  className: "w-6 h-auto mr-1.5 opacity-80"
1826
- }), " Log in"));
1842
+ }), " Enter edit-mode"));
1827
1843
  };
1828
1844
  const logout = () => {
1829
1845
  setEditing(false);
package/dist/index.js CHANGED
@@ -30,8 +30,8 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  (function(global, factory) {
33
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/toolkit"), require("graphql"), require("lodash.set"), require("graphql-tag"), require("react"), require("styled-components"), require("yup"), require("@tinacms/sharedctx"), require("final-form"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "@tinacms/toolkit", "graphql", "lodash.set", "graphql-tag", "react", "styled-components", "yup", "@tinacms/sharedctx", "final-form", "react-router-dom", "@headlessui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
34
- })(this, function(exports2, toolkit, graphql, set, gql$1, React, styled, yup, sharedctx, finalForm, reactRouterDom, react) {
33
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/toolkit"), require("graphql"), require("lodash.set"), require("graphql-tag"), require("react"), require("styled-components"), require("yup"), require("@tinacms/sharedctx"), require("final-form"), require("url-pattern"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "@tinacms/toolkit", "graphql", "lodash.set", "graphql-tag", "react", "styled-components", "yup", "@tinacms/sharedctx", "final-form", "url-pattern", "react-router-dom", "@headlessui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
34
+ })(this, function(exports2, toolkit, graphql, set, gql$1, React, styled, yup, sharedctx, finalForm, UrlPattern, reactRouterDom, react) {
35
35
  "use strict";
36
36
  function _interopDefaultLegacy(e) {
37
37
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
@@ -61,6 +61,7 @@ var __objRest = (source, exclude) => {
61
61
  var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
62
62
  var styled__default = /* @__PURE__ */ _interopDefaultLegacy(styled);
63
63
  var yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
64
+ var UrlPattern__default = /* @__PURE__ */ _interopDefaultLegacy(UrlPattern);
64
65
  function popupWindow(url, title, window2, w, h) {
65
66
  const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
66
67
  const x = window2.top.outerWidth / 2 + window2.top.screenX - w / 2;
@@ -1495,20 +1496,29 @@ mutation addPendingDocumentMutation(
1495
1496
  return this.props.children;
1496
1497
  }
1497
1498
  }
1499
+ const parseURL = (url) => {
1500
+ if (url.includes("localhost")) {
1501
+ return { branch: null, isLocalClient: true, clientId: null };
1502
+ }
1503
+ const tinaHost = "content.tinajs.io";
1504
+ const params = new URL(url);
1505
+ const pattern = new UrlPattern__default["default"]("/content/:clientId/github/:branch");
1506
+ const result = pattern.match(params.pathname);
1507
+ if (params.host !== tinaHost) {
1508
+ throw new Error(`The only supported hosts are ${tinaHost} or localhost, but received ${params.host}.`);
1509
+ }
1510
+ return __spreadProps(__spreadValues({}, result), {
1511
+ isLocalClient: false
1512
+ });
1513
+ };
1498
1514
  const TinaCMSProvider2 = (_c) => {
1499
1515
  var _d = _c, {
1500
1516
  children,
1501
- branch,
1502
- clientId,
1503
- isLocalClient,
1504
1517
  cmsCallback,
1505
1518
  mediaStore,
1506
1519
  tinaioConfig
1507
1520
  } = _d, props = __objRest(_d, [
1508
1521
  "children",
1509
- "branch",
1510
- "clientId",
1511
- "isLocalClient",
1512
1522
  "cmsCallback",
1513
1523
  "mediaStore",
1514
1524
  "tinaioConfig"
@@ -1516,6 +1526,14 @@ mutation addPendingDocumentMutation(
1516
1526
  if (typeof props.query === "string") {
1517
1527
  props.query;
1518
1528
  }
1529
+ if (!props.apiURL && !((props == null ? void 0 : props.clientId) || (props == null ? void 0 : props.isLocalClient))) {
1530
+ throw new Error(`apiURL is a required field`);
1531
+ }
1532
+ const { branch, clientId, isLocalClient } = props.apiURL ? parseURL(props.apiURL) : {
1533
+ branch: props.branch,
1534
+ clientId: props.clientId,
1535
+ isLocalClient: props.isLocalClient
1536
+ };
1519
1537
  return /* @__PURE__ */ React__default["default"].createElement(TinaCloudProvider, {
1520
1538
  branch,
1521
1539
  clientId,
@@ -1657,10 +1675,10 @@ mutation addPendingDocumentMutation(
1657
1675
  if (!is_server()) {
1658
1676
  console.warn(`Whoops! Looks like you are using \`staticRequest\` in the browser to fetch data.
1659
1677
 
1660
- The local server is not available outside of \`getStaticProps\` or \`getStaticPaths\` functions.
1678
+ The local server is not available outside of \`getStaticProps\` or \`getStaticPaths\` functions.
1661
1679
  This function should only be called on the server at build time.
1662
1680
 
1663
- This will work when developing locally but NOT when deployed to production.
1681
+ This will work when developing locally but NOT when deployed to production.
1664
1682
  `);
1665
1683
  }
1666
1684
  return client.request(query, { variables });
@@ -1804,7 +1822,7 @@ This will work when developing locally but NOT when deployed to production.
1804
1822
  return /* @__PURE__ */ React__default["default"].createElement("div", {
1805
1823
  className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
1806
1824
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
1807
- className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-md"
1825
+ className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-lg"
1808
1826
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
1809
1827
  className: "px-5 py-4 border-b border-gray-150"
1810
1828
  }, /* @__PURE__ */ React__default["default"].createElement("h2", {
@@ -1829,9 +1847,7 @@ This will work when developing locally but NOT when deployed to production.
1829
1847
  const LoginPage = () => {
1830
1848
  const { setEdit } = sharedctx.useEditState();
1831
1849
  const login = () => setEdit(true);
1832
- return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, {
1833
- message: "Please log in to Tina Cloud to access your content."
1834
- }, /* @__PURE__ */ React__default["default"].createElement("a", {
1850
+ return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, null, /* @__PURE__ */ React__default["default"].createElement("a", {
1835
1851
  href: "/",
1836
1852
  className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
1837
1853
  }, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
@@ -1843,7 +1859,7 @@ This will work when developing locally but NOT when deployed to production.
1843
1859
  style: { background: "#0084FF" }
1844
1860
  }, /* @__PURE__ */ React__default["default"].createElement(BiLogIn, {
1845
1861
  className: "w-6 h-auto mr-1.5 opacity-80"
1846
- }), " Log in"));
1862
+ }), " Enter edit-mode"));
1847
1863
  };
1848
1864
  const logout = () => {
1849
1865
  sharedctx.setEditing(false);