drupal-canvas 0.4.0 → 0.4.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.
|
@@ -37,11 +37,11 @@ function sortMenu(linkset) {
|
|
|
37
37
|
}
|
|
38
38
|
const getPageData = () => {
|
|
39
39
|
const pageData = {
|
|
40
|
-
pageTitle:
|
|
41
|
-
breadcrumbs:
|
|
42
|
-
mainEntity:
|
|
40
|
+
pageTitle: globalThis?.drupalSettings?.canvasData?.v0?.pageTitle || "",
|
|
41
|
+
breadcrumbs: globalThis?.drupalSettings?.canvasData?.v0?.breadcrumbs || [],
|
|
42
|
+
mainEntity: globalThis?.drupalSettings?.canvasData?.v0?.mainEntity || null
|
|
43
43
|
};
|
|
44
|
-
window
|
|
44
|
+
globalThis?.window?.parent.postMessage({
|
|
45
45
|
type: "_canvas_useswr_data_fetch",
|
|
46
46
|
id: "getPageData()",
|
|
47
47
|
data: pageData
|
|
@@ -50,13 +50,13 @@ const getPageData = () => {
|
|
|
50
50
|
};
|
|
51
51
|
const getSiteData = () => {
|
|
52
52
|
const siteData = {
|
|
53
|
-
branding:
|
|
53
|
+
branding: globalThis?.drupalSettings?.canvasData?.v0?.branding || {
|
|
54
54
|
homeUrl: "",
|
|
55
55
|
siteName: "",
|
|
56
56
|
siteSlogan: ""
|
|
57
57
|
},
|
|
58
|
-
baseUrl:
|
|
59
|
-
themeAssets:
|
|
58
|
+
baseUrl: globalThis?.drupalSettings?.canvasData?.v0?.baseUrl || "/",
|
|
59
|
+
themeAssets: globalThis?.drupalSettings?.canvasData?.v0?.themeAssets || {
|
|
60
60
|
logo: { url: "" },
|
|
61
61
|
favicon: {
|
|
62
62
|
url: "",
|
|
@@ -64,7 +64,7 @@ const getSiteData = () => {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
window
|
|
67
|
+
globalThis?.window?.parent.postMessage({
|
|
68
68
|
type: "_canvas_useswr_data_fetch",
|
|
69
69
|
id: "getSiteData()",
|
|
70
70
|
data: siteData
|
package/dist/drupal-utils.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getSiteData, r as sortMenu, t as getPageData } from "./drupal-utils-
|
|
1
|
+
import { n as getSiteData, r as sortMenu, t as getPageData } from "./drupal-utils-BIEn-IiB.js";
|
|
2
2
|
import { t as FormattedText } from "./FormattedText-C1aZH-9n.js";
|
|
3
|
-
import { t as CanvasJsonApiClient } from "./jsonapi-client-
|
|
3
|
+
import { t as CanvasJsonApiClient } from "./jsonapi-client-VgGykg8d.js";
|
|
4
4
|
import { n as sortMenu$1, t as getNodePath } from "./jsonapi-utils-BA2DcHP4.js";
|
|
5
5
|
import { t as Image } from "./next-image-standalone-Cp3o4ile.js";
|
|
6
6
|
import { t as cn } from "./utils-DuVWmMX9.js";
|
|
@@ -3,11 +3,11 @@ import { DefaultSerializer, JsonApiClient } from "@drupal-api-client/json-api-cl
|
|
|
3
3
|
//#region src/jsonapi-client.ts
|
|
4
4
|
var CanvasJsonApiClient = class extends JsonApiClient {
|
|
5
5
|
constructor(baseUrl, options) {
|
|
6
|
-
if (
|
|
7
|
-
const clientBaseUrl = baseUrl ||
|
|
6
|
+
if (globalThis?.drupalSettings?.canvasData?.v0?.jsonapiSettings === null) throw new Error("The JSON:API module is not installed. Please install it to use JsonApiClient.");
|
|
7
|
+
const clientBaseUrl = baseUrl || globalThis?.drupalSettings?.canvasData?.v0?.baseUrl;
|
|
8
8
|
if (!baseUrl && !clientBaseUrl) throw new Error("Could not determine your site's base URL for the JSON:API client. If working outside of Drupal Canvas, you can use the @drupal-canvas/vite-plugin to automatically configure it for you. Otherwise you must explicitly provide a base URL, i.e. `const client = new JsonApiClient(\"https://...\")`");
|
|
9
9
|
const clientOptions = {
|
|
10
|
-
apiPrefix:
|
|
10
|
+
apiPrefix: globalThis?.drupalSettings?.canvasData?.v0?.jsonapiSettings?.apiPrefix,
|
|
11
11
|
serializer: new DefaultSerializer(),
|
|
12
12
|
...options
|
|
13
13
|
};
|
package/dist/jsonapi-client.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drupal-canvas",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Utilities and base components for building Drupal Canvas Code Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"tsdown": "^0.17.0-beta.5",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
|
-
"vitest": "^
|
|
69
|
+
"vitest": "^4.1.8"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "NODE_ENV=production tsdown",
|