@e-mc/document 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/index.js +31 -18
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -325,26 +325,23 @@ class Document extends core_1.Client {
325
325
  restart() { }
326
326
  init(assets, config) {
327
327
  var _a;
328
- let ignoreModules;
328
+ let ignoreModules, ignoreExtensions;
329
329
  if (config) {
330
- const { baseUrl, ignoreExtensions } = config;
331
- if (ignoreExtensions === true) {
332
- this._extensions = [];
333
- }
334
- else if (typeof ignoreExtensions === 'string') {
335
- this._extensions = ignoreExtensions === this.moduleName ? [] : this._extensions.filter(value => value !== ignoreExtensions);
336
- }
337
- else if (Array.isArray(ignoreExtensions)) {
338
- this._extensions = ignoreExtensions.includes(this.moduleName) ? [] : this._extensions.filter(value => !ignoreExtensions.includes(value));
330
+ let baseUrl;
331
+ ({ baseUrl, ignoreModules, ignoreExtensions } = config);
332
+ let username, users;
333
+ if (username = this.host?.username) {
334
+ if (!(0, types_1.isPlainObject)(users = this.settings.users?.[username])) {
335
+ users = undefined;
336
+ }
337
+ else if (Array.isArray(users.extensions)) {
338
+ this._extensions = users.extensions.slice(0);
339
+ }
339
340
  }
340
341
  if (baseUrl) {
341
- const username = this.host?.username;
342
342
  let pages = this.settings.pages;
343
- if (username) {
344
- const users = this.settings.users?.[username]?.pages;
345
- if ((0, types_1.isPlainObject)(users)) {
346
- pages = (0, types_1.isPlainObject)(pages) ? { ...pages, ...users } : users;
347
- }
343
+ if (users && (0, types_1.isPlainObject)(users.pages)) {
344
+ pages = (0, types_1.isPlainObject)(pages) ? { ...pages, ...users.pages } : users.pages;
348
345
  }
349
346
  if ((0, types_1.isPlainObject)(pages)) {
350
347
  let mimeMap;
@@ -392,7 +389,6 @@ class Document extends core_1.Client {
392
389
  }
393
390
  }
394
391
  }
395
- ignoreModules = config.ignoreModules;
396
392
  }
397
393
  if (this.dataSource.length && !ignoreModules?.includes('db')) {
398
394
  const db = (_a = this.module).db || (_a.db = {});
@@ -430,7 +426,24 @@ class Document extends core_1.Client {
430
426
  }
431
427
  }
432
428
  this.assets = assets;
433
- return super.init();
429
+ super.init();
430
+ if (ignoreExtensions) {
431
+ if (ignoreExtensions === true || ignoreExtensions === this.moduleName || (0, types_1.isArray)(ignoreExtensions) && ignoreExtensions.includes(this.moduleName)) {
432
+ this._extensions = [];
433
+ }
434
+ else {
435
+ const extensions = this._extensions;
436
+ if ((0, types_1.isArray)(extensions)) {
437
+ if (typeof ignoreExtensions === 'string') {
438
+ this._extensions = extensions.filter(value => value !== ignoreExtensions);
439
+ }
440
+ else if ((0, types_1.isArray)(ignoreExtensions)) {
441
+ this._extensions = extensions.filter(value => !ignoreExtensions.includes(value));
442
+ }
443
+ }
444
+ }
445
+ }
446
+ return this;
434
447
  }
435
448
  abort(name) {
436
449
  if (this.aborted || name && this.settingsOf(name, 'abort') !== true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/document",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,12 +20,12 @@
20
20
  "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.6.0",
24
- "@e-mc/db": "0.6.0",
25
- "@e-mc/types": "0.6.0",
23
+ "@e-mc/core": "0.7.0",
24
+ "@e-mc/db": "0.7.0",
25
+ "@e-mc/types": "0.7.0",
26
26
  "chalk": "4.1.2",
27
27
  "htmlparser2": "^9.0.0",
28
28
  "js-yaml": "^4.1.0",
29
- "picomatch": "^2.3.1"
29
+ "picomatch": "^3.0.1"
30
30
  }
31
31
  }