@prismicio/react 2.6.0-alpha.3 → 2.6.1
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/dist/PrismicImage.cjs +1 -2
- package/dist/PrismicImage.cjs.map +1 -1
- package/dist/PrismicImage.js +1 -2
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicText.cjs +4 -2
- package/dist/PrismicText.cjs.map +1 -1
- package/dist/PrismicText.js +4 -2
- package/dist/PrismicText.js.map +1 -1
- package/dist/SliceZone.cjs +26 -12
- package/dist/SliceZone.cjs.map +1 -1
- package/dist/SliceZone.d.ts +62 -1
- package/dist/SliceZone.js +26 -12
- package/dist/SliceZone.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/lib/pascalCase.cjs +10 -0
- package/dist/lib/pascalCase.cjs.map +1 -0
- package/dist/lib/pascalCase.js +10 -0
- package/dist/lib/pascalCase.js.map +1 -0
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/react-server/PrismicLink.cjs +1 -2
- package/dist/react-server/PrismicLink.cjs.map +1 -1
- package/dist/react-server/PrismicLink.js +1 -2
- package/dist/react-server/PrismicLink.js.map +1 -1
- package/dist/react-server/PrismicRichText.cjs +7 -1
- package/dist/react-server/PrismicRichText.cjs.map +1 -1
- package/dist/react-server/PrismicRichText.d.ts +1 -1
- package/dist/react-server/PrismicRichText.js +7 -1
- package/dist/react-server/PrismicRichText.js.map +1 -1
- package/dist/usePrismicClient.cjs +3 -2
- package/dist/usePrismicClient.cjs.map +1 -1
- package/dist/usePrismicClient.js +3 -2
- package/dist/usePrismicClient.js.map +1 -1
- package/package.json +1 -1
- package/src/PrismicImage.tsx +1 -2
- package/src/PrismicText.tsx +10 -2
- package/src/SliceZone.tsx +138 -18
- package/src/index.ts +5 -2
- package/src/lib/processPolyfill.ts +4 -0
- package/src/react-server/PrismicLink.tsx +1 -2
- package/src/react-server/PrismicRichText.tsx +13 -0
- package/src/usePrismicClient.ts +6 -6
- package/dist/lib/__PRODUCTION__.cjs +0 -8
- package/dist/lib/__PRODUCTION__.cjs.map +0 -1
- package/dist/lib/__PRODUCTION__.d.ts +0 -7
- package/dist/lib/__PRODUCTION__.js +0 -8
- package/dist/lib/__PRODUCTION__.js.map +0 -1
- package/dist/lib/invariant.cjs +0 -15
- package/dist/lib/invariant.cjs.map +0 -1
- package/dist/lib/invariant.d.ts +0 -24
- package/dist/lib/invariant.js +0 -15
- package/dist/lib/invariant.js.map +0 -1
- package/src/lib/__PRODUCTION__.ts +0 -12
- package/src/lib/invariant.ts +0 -49
|
@@ -4,6 +4,7 @@ import * as prismicR from "@prismicio/richtext";
|
|
|
4
4
|
|
|
5
5
|
import { JSXFunctionSerializer, JSXMapSerializer } from "../types";
|
|
6
6
|
import { LinkProps, PrismicLink } from "./PrismicLink";
|
|
7
|
+
import { devMsg } from "../lib/devMsg";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Props for `<PrismicRichText>`.
|
|
@@ -222,8 +223,20 @@ export function PrismicRichText<
|
|
|
222
223
|
components,
|
|
223
224
|
externalLinkComponent,
|
|
224
225
|
internalLinkComponent,
|
|
226
|
+
...restProps
|
|
225
227
|
}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {
|
|
226
228
|
return React.useMemo(() => {
|
|
229
|
+
if (process.env.NODE_ENV === "development") {
|
|
230
|
+
if ("className" in restProps) {
|
|
231
|
+
console.warn(
|
|
232
|
+
`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(
|
|
233
|
+
"classname-is-not-a-valid-prop",
|
|
234
|
+
)}.`,
|
|
235
|
+
field,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
227
240
|
if (prismic.isFilled.richText(field)) {
|
|
228
241
|
const serializer = prismicR.composeSerializers(
|
|
229
242
|
typeof components === "object"
|
package/src/usePrismicClient.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type * as prismic from "@prismicio/client";
|
|
2
2
|
|
|
3
|
-
import { invariant } from "./lib/invariant";
|
|
4
|
-
|
|
5
3
|
import { usePrismicContext } from "./usePrismicContext";
|
|
6
4
|
|
|
7
5
|
/**
|
|
@@ -19,10 +17,12 @@ export const usePrismicClient = (
|
|
|
19
17
|
const context = usePrismicContext();
|
|
20
18
|
|
|
21
19
|
const client = explicitClient || context?.client;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
|
|
21
|
+
if (!client) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"A @prismicio/client is required to query documents. Provide a client to the hook or to a <PrismicProvider> higher in your component tree.",
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
26
|
|
|
27
27
|
return client;
|
|
28
28
|
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
if (typeof process === "undefined") {
|
|
4
|
-
globalThis.process = { env: {} };
|
|
5
|
-
}
|
|
6
|
-
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
7
|
-
exports.__PRODUCTION__ = __PRODUCTION__;
|
|
8
|
-
//# sourceMappingURL=__PRODUCTION__.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.cjs","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":";;AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;AAC5B;AAQY,MAAA,iBAAiB,QAAQ,IAAI,aAAa;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.js","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":"AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;AAC5B;AAQY,MAAA,iBAAiB,QAAQ,IAAI,aAAa;"}
|
package/dist/lib/invariant.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const __PRODUCTION__ = require("./__PRODUCTION__.cjs");
|
|
4
|
-
const prefix = "Invariant failed";
|
|
5
|
-
function invariant(condition, message) {
|
|
6
|
-
if (condition) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (__PRODUCTION__.__PRODUCTION__) {
|
|
10
|
-
throw new Error(prefix);
|
|
11
|
-
}
|
|
12
|
-
throw new Error(`${prefix}: ${message || ""}`);
|
|
13
|
-
}
|
|
14
|
-
exports.invariant = invariant;
|
|
15
|
-
//# sourceMappingURL=invariant.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invariant.cjs","sources":["../../../src/lib/invariant.ts"],"sourcesContent":["/**\n * MIT License\n *\n * Copyright (c) 2019 Alexander Reardon\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { __PRODUCTION__ } from \"./__PRODUCTION__\";\n\nconst prefix = \"Invariant failed\";\n\n// Throw an error if the condition fails\n// Strip out error messages for production\n// > Not providing an inline default argument for message as the result is smaller\nexport function invariant(\n\tcondition: unknown,\n\tmessage?: string,\n): asserts condition {\n\tif (condition) {\n\t\treturn;\n\t}\n\t// Condition not passed\n\n\t// In production we strip the message but still throw\n\tif (__PRODUCTION__) {\n\t\tthrow new Error(prefix);\n\t}\n\n\t// When not in production we allow the message to pass through\n\t// *This block will be removed in production builds*\n\tthrow new Error(`${prefix}: ${message || \"\"}`);\n}\n"],"names":["__PRODUCTION__"],"mappings":";;;AA0BA,MAAM,SAAS;AAKC,SAAA,UACf,WACA,SAAgB;AAEhB,MAAI,WAAW;AACd;AAAA,EACA;AAID,MAAIA,+BAAgB;AACb,UAAA,IAAI,MAAM,MAAM;AAAA,EACtB;AAID,QAAM,IAAI,MAAM,GAAG,WAAW,WAAW,IAAI;AAC9C;;"}
|
package/dist/lib/invariant.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 Alexander Reardon
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
export declare function invariant(condition: unknown, message?: string): asserts condition;
|
package/dist/lib/invariant.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { __PRODUCTION__ } from "./__PRODUCTION__.js";
|
|
2
|
-
const prefix = "Invariant failed";
|
|
3
|
-
function invariant(condition, message) {
|
|
4
|
-
if (condition) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
if (__PRODUCTION__) {
|
|
8
|
-
throw new Error(prefix);
|
|
9
|
-
}
|
|
10
|
-
throw new Error(`${prefix}: ${message || ""}`);
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
invariant
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=invariant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invariant.js","sources":["../../../src/lib/invariant.ts"],"sourcesContent":["/**\n * MIT License\n *\n * Copyright (c) 2019 Alexander Reardon\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { __PRODUCTION__ } from \"./__PRODUCTION__\";\n\nconst prefix = \"Invariant failed\";\n\n// Throw an error if the condition fails\n// Strip out error messages for production\n// > Not providing an inline default argument for message as the result is smaller\nexport function invariant(\n\tcondition: unknown,\n\tmessage?: string,\n): asserts condition {\n\tif (condition) {\n\t\treturn;\n\t}\n\t// Condition not passed\n\n\t// In production we strip the message but still throw\n\tif (__PRODUCTION__) {\n\t\tthrow new Error(prefix);\n\t}\n\n\t// When not in production we allow the message to pass through\n\t// *This block will be removed in production builds*\n\tthrow new Error(`${prefix}: ${message || \"\"}`);\n}\n"],"names":[],"mappings":";AA0BA,MAAM,SAAS;AAKC,SAAA,UACf,WACA,SAAgB;AAEhB,MAAI,WAAW;AACd;AAAA,EACA;AAID,MAAI,gBAAgB;AACb,UAAA,IAAI,MAAM,MAAM;AAAA,EACtB;AAID,QAAM,IAAI,MAAM,GAAG,WAAW,WAAW,IAAI;AAC9C;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// We need to polyfill process if it doesn't exist, such as in the browser.
|
|
2
|
-
if (typeof process === "undefined") {
|
|
3
|
-
globalThis.process = { env: {} } as typeof process;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `true` if in the production environment, `false` otherwise.
|
|
8
|
-
*
|
|
9
|
-
* This boolean can be used to perform actions only in development environments,
|
|
10
|
-
* such as logging.
|
|
11
|
-
*/
|
|
12
|
-
export const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
package/src/lib/invariant.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 Alexander Reardon
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { __PRODUCTION__ } from "./__PRODUCTION__";
|
|
26
|
-
|
|
27
|
-
const prefix = "Invariant failed";
|
|
28
|
-
|
|
29
|
-
// Throw an error if the condition fails
|
|
30
|
-
// Strip out error messages for production
|
|
31
|
-
// > Not providing an inline default argument for message as the result is smaller
|
|
32
|
-
export function invariant(
|
|
33
|
-
condition: unknown,
|
|
34
|
-
message?: string,
|
|
35
|
-
): asserts condition {
|
|
36
|
-
if (condition) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
// Condition not passed
|
|
40
|
-
|
|
41
|
-
// In production we strip the message but still throw
|
|
42
|
-
if (__PRODUCTION__) {
|
|
43
|
-
throw new Error(prefix);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// When not in production we allow the message to pass through
|
|
47
|
-
// *This block will be removed in production builds*
|
|
48
|
-
throw new Error(`${prefix}: ${message || ""}`);
|
|
49
|
-
}
|