druxt 0.19.0 → 0.19.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.
package/dist/druxt.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
3
- import { join, resolve } from 'path';
3
+ import { join, resolve, normalize } from 'path';
4
4
  import axios from 'axios';
5
5
  import { stringify } from 'querystring';
6
6
  import consola from 'consola';
@@ -251,7 +251,7 @@ class DruxtClient {
251
251
  }
252
252
 
253
253
  var name = "druxt";
254
- var version = "0.19.0";
254
+ var version = "0.19.3";
255
255
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
256
256
  var keywords = [
257
257
  "cms",
@@ -285,7 +285,6 @@ var main = "dist/druxt.ssr.js";
285
285
  var module = "dist/druxt.esm.js";
286
286
  var files = [
287
287
  "dist",
288
- "stories",
289
288
  "templates"
290
289
  ];
291
290
  var dependencies = {
@@ -340,6 +339,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
340
339
  ...moduleOptions,
341
340
  ...(this.options || {}).druxt
342
341
  };
342
+ this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
343
+ this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
343
344
  const druxt = new DruxtClient(options.baseUrl, {
344
345
  ...options,
345
346
  proxy: { ...options.proxy || {}, api: false }
@@ -348,11 +349,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
348
349
  const proxies = {};
349
350
  if ((options.proxy || {}).api) {
350
351
  proxies[options.endpoint] = options.baseUrl;
351
- const resourceType = "configurable_language--configurable_language";
352
- const query = new DrupalJsonApiParams().addFields(resourceType, ["drupal_internal__id"]);
353
- const languages = (await druxt.getCollectionAll(resourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(o.attributes.drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
354
- for (const langcode of languages) {
355
- proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
352
+ const languageResourceType = "configurable_language--configurable_language";
353
+ if ((await druxt.getIndex(languageResourceType) || {}).href) {
354
+ const query = new DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
355
+ const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
356
+ for (const langcode of languages) {
357
+ proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
358
+ }
356
359
  }
357
360
  proxies["/router/translate-path"] = options.baseUrl;
358
361
  }
@@ -363,13 +366,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
363
366
  if (this.options.proxy) {
364
367
  if (Array.isArray(this.options.proxy)) {
365
368
  this.options.proxy = [
366
- ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`),
367
- ...this.options.proxy
369
+ ...this.options.proxy,
370
+ ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
368
371
  ];
369
372
  } else {
370
373
  this.options.proxy = {
371
- ...proxies,
372
- ...this.options.proxy
374
+ ...this.options.proxy,
375
+ ...proxies
373
376
  };
374
377
  }
375
378
  } else {
@@ -396,10 +399,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
396
399
  const extendPlugins = this.options.extendPlugins;
397
400
  this.options.extendPlugins = (plugins) => {
398
401
  plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
399
- const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
402
+ const axiosIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/axios.js`));
400
403
  const axiosPlugin = plugins[axiosIndex];
401
404
  plugins.splice(axiosIndex, 1);
402
- const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
405
+ const druxtIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/druxt.js`));
403
406
  const druxtPlugin = plugins[druxtIndex];
404
407
  plugins.splice(druxtIndex, 1);
405
408
  plugins = [axiosPlugin, druxtPlugin, ...plugins];
@@ -414,10 +417,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
414
417
  this.options.components = (_a = this.options.components) != null ? _a : true;
415
418
  this.options.cli.badgeMessages.push(`${chalk.blue.bold("Druxt")} @ v${meta.version}`);
416
419
  this.options.cli.badgeMessages.push(`${chalk.bold("API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
420
+ const self = this;
417
421
  this.nuxt.hook("storybook:config", async ({ stories }) => {
418
- stories.push("druxt/stories/*.stories.mdx");
419
- stories.push("druxt/dist/components/*.stories.mdx");
420
- stories.push("druxt/dist/components/*.stories.mjs");
422
+ self.addTemplate({
423
+ src: resolve(__dirname, "../templates/stories/README.stories.mdx"),
424
+ fileName: "stories/druxt-README.stories.mdx"
425
+ });
426
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
427
+ self.addTemplate({
428
+ src: resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
429
+ fileName: "stories/druxt-module.stories.mdx"
430
+ });
431
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
432
+ self.addTemplate({
433
+ src: resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
434
+ fileName: "stories/druxt-debug.stories.js"
435
+ });
436
+ stories.push(resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
421
437
  });
422
438
  };
423
439
 
package/dist/druxt.ssr.js CHANGED
@@ -264,7 +264,7 @@ class DruxtClient {
264
264
  }
265
265
 
266
266
  var name = "druxt";
267
- var version = "0.19.0";
267
+ var version = "0.19.3";
268
268
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
269
269
  var keywords = [
270
270
  "cms",
@@ -298,7 +298,6 @@ var main = "dist/druxt.ssr.js";
298
298
  var module$1 = "dist/druxt.esm.js";
299
299
  var files = [
300
300
  "dist",
301
- "stories",
302
301
  "templates"
303
302
  ];
304
303
  var dependencies = {
@@ -353,6 +352,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
353
352
  ...moduleOptions,
354
353
  ...(this.options || {}).druxt
355
354
  };
355
+ this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
356
+ this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
356
357
  const druxt = new DruxtClient(options.baseUrl, {
357
358
  ...options,
358
359
  proxy: { ...options.proxy || {}, api: false }
@@ -361,11 +362,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
361
362
  const proxies = {};
362
363
  if ((options.proxy || {}).api) {
363
364
  proxies[options.endpoint] = options.baseUrl;
364
- const resourceType = "configurable_language--configurable_language";
365
- const query = new drupalJsonapiParams.DrupalJsonApiParams().addFields(resourceType, ["drupal_internal__id"]);
366
- const languages = (await druxt.getCollectionAll(resourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(o.attributes.drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
367
- for (const langcode of languages) {
368
- proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
365
+ const languageResourceType = "configurable_language--configurable_language";
366
+ if ((await druxt.getIndex(languageResourceType) || {}).href) {
367
+ const query = new drupalJsonapiParams.DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
368
+ const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
369
+ for (const langcode of languages) {
370
+ proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
371
+ }
369
372
  }
370
373
  proxies["/router/translate-path"] = options.baseUrl;
371
374
  }
@@ -376,13 +379,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
376
379
  if (this.options.proxy) {
377
380
  if (Array.isArray(this.options.proxy)) {
378
381
  this.options.proxy = [
379
- ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`),
380
- ...this.options.proxy
382
+ ...this.options.proxy,
383
+ ...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
381
384
  ];
382
385
  } else {
383
386
  this.options.proxy = {
384
- ...proxies,
385
- ...this.options.proxy
387
+ ...this.options.proxy,
388
+ ...proxies
386
389
  };
387
390
  }
388
391
  } else {
@@ -409,10 +412,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
409
412
  const extendPlugins = this.options.extendPlugins;
410
413
  this.options.extendPlugins = (plugins) => {
411
414
  plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
412
- const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
415
+ const axiosIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/axios.js`));
413
416
  const axiosPlugin = plugins[axiosIndex];
414
417
  plugins.splice(axiosIndex, 1);
415
- const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
418
+ const druxtIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/druxt.js`));
416
419
  const druxtPlugin = plugins[druxtIndex];
417
420
  plugins.splice(druxtIndex, 1);
418
421
  plugins = [axiosPlugin, druxtPlugin, ...plugins];
@@ -427,10 +430,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
427
430
  this.options.components = (_a = this.options.components) != null ? _a : true;
428
431
  this.options.cli.badgeMessages.push(`${chalk__default["default"].blue.bold("Druxt")} @ v${meta.version}`);
429
432
  this.options.cli.badgeMessages.push(`${chalk__default["default"].bold("API:")} ${chalk__default["default"].blue.underline(options.baseUrl + options.endpoint)}`);
433
+ const self = this;
430
434
  this.nuxt.hook("storybook:config", async ({ stories }) => {
431
- stories.push("druxt/stories/*.stories.mdx");
432
- stories.push("druxt/dist/components/*.stories.mdx");
433
- stories.push("druxt/dist/components/*.stories.mjs");
435
+ self.addTemplate({
436
+ src: path.resolve(__dirname, "../templates/stories/README.stories.mdx"),
437
+ fileName: "stories/druxt-README.stories.mdx"
438
+ });
439
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
440
+ self.addTemplate({
441
+ src: path.resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
442
+ fileName: "stories/druxt-module.stories.mdx"
443
+ });
444
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
445
+ self.addTemplate({
446
+ src: path.resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
447
+ fileName: "stories/druxt-debug.stories.js"
448
+ });
449
+ stories.push(path.resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
434
450
  });
435
451
  };
436
452
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt",
3
- "version": "0.19.0",
3
+ "version": "0.19.3",
4
4
  "description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
5
5
  "keywords": [
6
6
  "cms",
@@ -34,7 +34,6 @@
34
34
  "module": "dist/druxt.esm.js",
35
35
  "files": [
36
36
  "dist",
37
- "stories",
38
37
  "templates"
39
38
  ],
40
39
  "dependencies": {
@@ -1,4 +1,4 @@
1
- import DruxtDebug from './DruxtDebug.vue'
1
+ import DruxtDebug from 'druxt/dist/components/DruxtDebug.vue'
2
2
 
3
3
  export default {
4
4
  title: 'Druxt/DruxtDebug',
@@ -27,7 +27,9 @@ Json.args = {
27
27
  }
28
28
  Json.parameters = {
29
29
  docs: {
30
- storyDescription: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
30
+ description: {
31
+ story: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
32
+ },
31
33
  source: {
32
34
  code: '<DruxtDebug :json="entity" open>Debug information</DruxtDebug>'
33
35
  },
@@ -40,7 +42,9 @@ Summary.args = {
40
42
  }
41
43
  Summary.parameters = {
42
44
  docs: {
43
- storyDescription: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
45
+ description: {
46
+ story: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
47
+ },
44
48
  source: {
45
49
  code: `<DruxtDebug summary="${Summary.args.sumary}">Debug information</DruxtDebug>`
46
50
  },
@@ -102,7 +102,7 @@ Druxt module.
102
102
  import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
103
103
  export default {
104
104
  name: 'MyModule',
105
- extends: DruxtModule
105
+ extends: DruxtModule,
106
106
  druxt: {
107
107
  async fetchConfig() {
108
108
  // Load configuration data here.
@@ -113,7 +113,7 @@ export default {
113
113
  // Build nested arrays of component options based on the context.
114
114
  componentOptions: (context) => ([['default']]),
115
115
  // Map props data from the context.
116
- propsData: (context) => ({ ...context }),
116
+ propsData: (context) => ({}),
117
117
  // Build slots render arrays.
118
118
  slots(h) {
119
119
  return {