druxt-menu 0.22.2-dev.20261118025746 → 0.22.2-dev.20261121205033
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/druxt-menu.esm.js +24 -7
- package/dist/druxt-menu.ssr.js +24 -7
- package/package.json +3 -3
package/dist/druxt-menu.esm.js
CHANGED
|
@@ -122,17 +122,21 @@ class DruxtMenu {
|
|
|
122
122
|
const query = jsonApiMenuItems ? this.buildJsonApiMenuItemsQuery(menuName, settings) : this.buildMenuLinkContentQuery(menuName, settings);
|
|
123
123
|
const cacheKey = JSON.stringify([prefix || "", menuName, jsonApiMenuItems, query.getQueryString()]);
|
|
124
124
|
if (!cache.has(cacheKey)) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
const request = (async () => {
|
|
126
|
+
const url = typeof this.druxt.processCache === "function" ? await this.menuUrl(menuName, prefix, jsonApiMenuItems, query) : void 0;
|
|
127
|
+
const processCache = (scope) => typeof this.druxt.processCache === "function" ? this.druxt.processCache(scope, url) : null;
|
|
128
|
+
const sharedKey = JSON.stringify([this.druxt.indexKey, cacheKey]);
|
|
129
|
+
const shared = processCache("menu");
|
|
130
|
+
const stored = shared && shared.get(sharedKey);
|
|
131
|
+
if (stored)
|
|
132
|
+
return stored;
|
|
133
|
+
const since = shared ? shared.generation : void 0;
|
|
134
|
+
const result = await (jsonApiMenuItems ? this.getJsonApiMenuItems(menuName, settings, prefix, query) : this.getMenuLinkContent(menuName, settings, prefix, query));
|
|
131
135
|
const after = processCache("menu");
|
|
132
136
|
if (after && lifetimes.has(result))
|
|
133
137
|
after.set(sharedKey, result, lifetimes.get(result), since);
|
|
134
138
|
return result;
|
|
135
|
-
});
|
|
139
|
+
})();
|
|
136
140
|
cache.set(cacheKey, request);
|
|
137
141
|
request.catch(() => cache.delete(cacheKey));
|
|
138
142
|
if (!runtime.isServer()) {
|
|
@@ -145,6 +149,19 @@ class DruxtMenu {
|
|
|
145
149
|
}
|
|
146
150
|
return cache.get(cacheKey);
|
|
147
151
|
}
|
|
152
|
+
async menuUrl(menuName, prefix, jsonApiMenuItems, query) {
|
|
153
|
+
const endpoint = `${prefix || ""}${this.druxt.options.endpoint}`;
|
|
154
|
+
let href;
|
|
155
|
+
if (jsonApiMenuItems) {
|
|
156
|
+
const index = await this.druxt.getIndex(void 0, prefix) || {};
|
|
157
|
+
href = (index[`menu_items--${menuName}`] || {}).href || `${endpoint}/menu_items/${menuName}`;
|
|
158
|
+
} else {
|
|
159
|
+
href = (await this.druxt.getIndex("menu_link_content--menu_link_content", prefix) || {}).href;
|
|
160
|
+
}
|
|
161
|
+
if (!href)
|
|
162
|
+
return endpoint;
|
|
163
|
+
return typeof this.druxt.buildQueryUrl === "function" ? this.druxt.buildQueryUrl(href, query) : href;
|
|
164
|
+
}
|
|
148
165
|
withLifetime(result, collections) {
|
|
149
166
|
const lifetime = (collection) => typeof this.druxt.cacheLifetime === "function" ? this.druxt.cacheLifetime(collection) : 0;
|
|
150
167
|
lifetimes.set(result, collections.length ? Math.min(...collections.map(lifetime)) : 0);
|
package/dist/druxt-menu.ssr.js
CHANGED
|
@@ -130,17 +130,21 @@ class DruxtMenu {
|
|
|
130
130
|
const query = jsonApiMenuItems ? this.buildJsonApiMenuItemsQuery(menuName, settings) : this.buildMenuLinkContentQuery(menuName, settings);
|
|
131
131
|
const cacheKey = JSON.stringify([prefix || "", menuName, jsonApiMenuItems, query.getQueryString()]);
|
|
132
132
|
if (!cache.has(cacheKey)) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
const request = (async () => {
|
|
134
|
+
const url = typeof this.druxt.processCache === "function" ? await this.menuUrl(menuName, prefix, jsonApiMenuItems, query) : void 0;
|
|
135
|
+
const processCache = (scope) => typeof this.druxt.processCache === "function" ? this.druxt.processCache(scope, url) : null;
|
|
136
|
+
const sharedKey = JSON.stringify([this.druxt.indexKey, cacheKey]);
|
|
137
|
+
const shared = processCache("menu");
|
|
138
|
+
const stored = shared && shared.get(sharedKey);
|
|
139
|
+
if (stored)
|
|
140
|
+
return stored;
|
|
141
|
+
const since = shared ? shared.generation : void 0;
|
|
142
|
+
const result = await (jsonApiMenuItems ? this.getJsonApiMenuItems(menuName, settings, prefix, query) : this.getMenuLinkContent(menuName, settings, prefix, query));
|
|
139
143
|
const after = processCache("menu");
|
|
140
144
|
if (after && lifetimes.has(result))
|
|
141
145
|
after.set(sharedKey, result, lifetimes.get(result), since);
|
|
142
146
|
return result;
|
|
143
|
-
});
|
|
147
|
+
})();
|
|
144
148
|
cache.set(cacheKey, request);
|
|
145
149
|
request.catch(() => cache.delete(cacheKey));
|
|
146
150
|
if (!runtime.isServer()) {
|
|
@@ -153,6 +157,19 @@ class DruxtMenu {
|
|
|
153
157
|
}
|
|
154
158
|
return cache.get(cacheKey);
|
|
155
159
|
}
|
|
160
|
+
async menuUrl(menuName, prefix, jsonApiMenuItems, query) {
|
|
161
|
+
const endpoint = `${prefix || ""}${this.druxt.options.endpoint}`;
|
|
162
|
+
let href;
|
|
163
|
+
if (jsonApiMenuItems) {
|
|
164
|
+
const index = await this.druxt.getIndex(void 0, prefix) || {};
|
|
165
|
+
href = (index[`menu_items--${menuName}`] || {}).href || `${endpoint}/menu_items/${menuName}`;
|
|
166
|
+
} else {
|
|
167
|
+
href = (await this.druxt.getIndex("menu_link_content--menu_link_content", prefix) || {}).href;
|
|
168
|
+
}
|
|
169
|
+
if (!href)
|
|
170
|
+
return endpoint;
|
|
171
|
+
return typeof this.druxt.buildQueryUrl === "function" ? this.druxt.buildQueryUrl(href, query) : href;
|
|
172
|
+
}
|
|
156
173
|
withLifetime(result, collections) {
|
|
157
174
|
const lifetime = (collection) => typeof this.druxt.cacheLifetime === "function" ? this.druxt.cacheLifetime(collection) : 0;
|
|
158
175
|
lifetimes.set(result, collections.length ? Math.min(...collections.map(lifetime)) : 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-menu",
|
|
3
|
-
"version": "0.22.2-dev.
|
|
3
|
+
"version": "0.22.2-dev.20261121205033",
|
|
4
4
|
"description": "Drupal Menu and Menu item Druxt components, with support for the JSON:API Menu Items module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"deepmerge": "^4.3.1",
|
|
51
51
|
"drupal-jsonapi-params": "^2.3.2",
|
|
52
|
-
"druxt": "0.25.2-dev.
|
|
53
|
-
"druxt-blocks": "0.18.2-dev.
|
|
52
|
+
"druxt": "0.25.2-dev.20261121205033",
|
|
53
|
+
"druxt-blocks": "0.18.2-dev.20261121205033"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"axios": "0.35.0",
|