@amagaki/amagaki 4.0.0 → 4.1.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.
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeepWalk = void 0;
4
+ /**
5
+ * Recursively walks plain objects and arrays, transforming values via `callback`.
6
+ * Class instances and functions are passed directly to `callback` without recursing
7
+ * into their properties.
8
+ */
9
+ class DeepWalk {
10
+ async walk(value, callback) {
11
+ if (Array.isArray(value)) {
12
+ const out = new Array(value.length);
13
+ for (let i = 0; i < value.length; i++) {
14
+ out[i] = await this.walk(value[i], callback);
15
+ }
16
+ return out;
17
+ }
18
+ if (value !== null &&
19
+ typeof value === 'object' &&
20
+ (value.constructor === Object || Object.getPrototypeOf(value) === null)) {
21
+ const out = {};
22
+ for (const key of Object.keys(value)) {
23
+ out[key] = await this.walk(value[key], callback);
24
+ }
25
+ return out;
26
+ }
27
+ return await callback(value);
28
+ }
29
+ }
30
+ exports.DeepWalk = DeepWalk;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Locale } from './locale';
3
2
  import { Collection } from './collection';
4
3
  import { Environment } from './environment';
@@ -14,8 +13,8 @@ export interface TemplateContext {
14
13
  req?: express.Request;
15
14
  route?: Route;
16
15
  }
17
- declare type DocumentViewFunction = (context: TemplateContext) => Promise<string>;
18
- export declare type DocumentView = string | DocumentViewFunction;
16
+ type DocumentViewFunction = (context: TemplateContext) => Promise<string>;
17
+ export type DocumentView = string | DocumentViewFunction;
19
18
  export interface DocumentListOptions {
20
19
  /**
21
20
  * Exclude patterns for excluding documents that match the glob pattern(s).
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,24 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
24
35
  Object.defineProperty(exports, "__esModule", { value: true });
25
36
  exports.Document = void 0;
26
37
  const fsPath = __importStar(require("path"));
27
- const glob = __importStar(require("glob"));
38
+ const glob_1 = require("glob");
28
39
  const utils = __importStar(require("./utils"));
29
40
  const locale_1 = require("./locale");
30
- const deepWalk_1 = require("@blinkk/editor.dev-ui/dist/utility/deepWalk");
31
- const minimatch_1 = __importDefault(require("minimatch"));
41
+ const deepWalk_1 = require("./deepWalk");
42
+ const minimatch_1 = require("minimatch");
32
43
  /**
33
44
  * Documents represent dynamically rendered pages. The document object controls
34
45
  * all aspects of rendering itself, with references to things like its template
@@ -106,13 +117,13 @@ class Document {
106
117
  }
107
118
  patterns = patterns || [`${pod.defaultContentPodPath}**/*`];
108
119
  patterns.forEach(pattern => {
109
- paths = paths.concat(glob.sync(pattern, {
120
+ paths = paths.concat((0, glob_1.globSync)(pattern, {
110
121
  cwd: pod.root,
111
122
  root: pod.root,
112
- ignore: '/**/*/_*',
123
+ ignore: ['**/_*', '/**/*/_*'],
113
124
  matchBase: false,
114
125
  nodir: true,
115
- }));
126
+ }).sort());
116
127
  });
117
128
  // Include only files with supported extensions.
118
129
  paths = paths.filter(path => {
@@ -133,7 +144,7 @@ class Document {
133
144
  options.exclude = [options.exclude];
134
145
  }
135
146
  for (const pattern of options.exclude) {
136
- const pathsToBeExcluded = paths.filter(minimatch_1.default.filter(pattern));
147
+ const pathsToBeExcluded = paths.filter(path => (0, minimatch_1.minimatch)(path, pattern));
137
148
  paths = paths.filter(path => !pathsToBeExcluded.includes(path));
138
149
  }
139
150
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,18 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
37
  };
24
38
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.getGitData = void 0;
39
+ exports.getGitData = getGitData;
26
40
  const fsPath = __importStar(require("path"));
27
41
  const git = __importStar(require("isomorphic-git"));
28
42
  const fs_1 = __importDefault(require("fs"));
@@ -64,4 +78,3 @@ async function getGitData(path) {
64
78
  },
65
79
  };
66
80
  }
67
- exports.getGitData = getGitData;
package/dist/src/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,8 +1,8 @@
1
1
  import { Document } from './document';
2
2
  import { Pod } from './pod';
3
3
  import { TranslationString } from './string';
4
- export declare type Translatable = string | TranslationString;
5
- declare type LocaleId = string;
4
+ export type Translatable = string | TranslationString;
5
+ type LocaleId = string;
6
6
  export declare class LocaleSet extends Set {
7
7
  static fromIds(localeIds: Array<string>, pod: Pod): LocaleSet;
8
8
  toString(): string;
@@ -1,8 +1,8 @@
1
1
  import { BuildResult, Builder } from '../builder';
2
2
  import { PluginComponent } from '../plugins';
3
3
  import { Pod } from '../pod';
4
- export declare type afterBuildCallback = (result: BuildResult) => Promise<void>;
5
- export declare type beforeBuildCallback = (builder: Builder) => Promise<void>;
4
+ export type afterBuildCallback = (result: BuildResult) => Promise<void>;
5
+ export type beforeBuildCallback = (builder: Builder) => Promise<void>;
6
6
  /**
7
7
  * Plugin providing access to build steps.
8
8
  *
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  Object.defineProperty(exports, "__esModule", { value: true });
22
36
  exports.NunjucksTemplateEngine = exports.NunjucksPlugin = exports.NunjucksBuiltInFilters = void 0;
23
37
  const nunjucks = __importStar(require("nunjucks"));
@@ -63,7 +77,7 @@ class NunjucksBuiltInFilters {
63
77
  if (!value) {
64
78
  return '';
65
79
  }
66
- return marked_1.marked.parse(value);
80
+ return marked_1.marked.parse(value, { async: false });
67
81
  }
68
82
  /**
69
83
  * Returns a URL relative to the current document.
@@ -1,7 +1,7 @@
1
1
  import express = require('express');
2
2
  import { PluginComponent } from '../plugins';
3
3
  import { Pod } from '../pod';
4
- export declare type createServerCallbacks = (app: express.Express) => Promise<void>;
4
+ export type createServerCallbacks = (app: express.Express) => Promise<void>;
5
5
  /**
6
6
  * Plugin providing access to the Express server.
7
7
  */
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  Object.defineProperty(exports, "__esModule", { value: true });
22
36
  exports.YamlTypeManager = exports.YamlPlugin = void 0;
23
37
  const utils = __importStar(require("../utils"));
package/dist/src/pod.d.ts CHANGED
@@ -12,7 +12,7 @@ import { DocumentView } from '.';
12
12
  import { Profiler } from './profile';
13
13
  import { StaticFile } from './staticFile';
14
14
  import { TemplateEngineManager } from './templateEngine';
15
- export declare type TypeScriptLoader = 'sucrase' | 'tsx' | 'esbuild-register' | 'jiti' | 'auto';
15
+ export type TypeScriptLoader = 'sucrase' | 'tsx' | 'esbuild-register' | 'jiti' | 'auto';
16
16
  export interface PodOptions {
17
17
  /**
18
18
  * Preferred TypeScript loader for amagaki.ts files.
package/dist/src/pod.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
37
  };
@@ -45,7 +59,7 @@ const router_2 = require("./plugins/router");
45
59
  const server_1 = require("./plugins/server");
46
60
  const staticFile_1 = require("./staticFile");
47
61
  const templateEngine_1 = require("./templateEngine");
48
- const chalk_1 = __importDefault(require("chalk"));
62
+ const ansi_1 = __importDefault(require("./ansi"));
49
63
  /**
50
64
  * Pods are the "command center" for all operations within a site. Pods hold
51
65
  * references to things like the build environment, template engines, file
@@ -172,7 +186,7 @@ class Pod {
172
186
  return true;
173
187
  }
174
188
  if (!result) {
175
- console.warn(chalk_1.default.yellow(`Warning: Could not load TypeScript loader "${loader}". ` +
189
+ console.warn(ansi_1.default.yellow(`Warning: Could not load TypeScript loader "${loader}". ` +
176
190
  `Make sure it's installed. Falling back to require().`));
177
191
  }
178
192
  return false;
@@ -195,7 +209,7 @@ class Pod {
195
209
  }
196
210
  }
197
211
  // No loader found
198
- console.warn(chalk_1.default.yellow('Warning: No TypeScript loader found (tsx, esbuild-register, jiti, or sucrase). ' +
212
+ console.warn(ansi_1.default.yellow('Warning: No TypeScript loader found (tsx, esbuild-register, jiti, or sucrase). ' +
199
213
  'Install at least one TypeScript loader to use .ts config files.'));
200
214
  return false;
201
215
  }
@@ -533,7 +547,7 @@ class Pod {
533
547
  const seconds = await this.router.warmup();
534
548
  const routes = await this.router.routes();
535
549
  if (routes.length > 5000) {
536
- console.log(chalk_1.default.blue('Warmed up: ') +
550
+ console.log(ansi_1.default.blue('Warmed up: ') +
537
551
  `${routes.length} routes in ${seconds.toFixed(2)}s`);
538
552
  }
539
553
  }
@@ -1,4 +1,4 @@
1
- import Table = require('cli-table');
1
+ import { SimpleTable as Table } from './table';
2
2
  export declare class Profiler {
3
3
  timerTypes: Record<string, TimerType>;
4
4
  constructor();
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProfileReportSection = exports.ProfileReport = exports.Timer = exports.TimerType = exports.Profiler = void 0;
4
- const Table = require("cli-table");
4
+ const table_1 = require("./table");
5
5
  const perf_hooks_1 = require("perf_hooks");
6
6
  class Profiler {
7
7
  constructor() {
@@ -256,7 +256,7 @@ class ProfileReport {
256
256
  // Use the url as the label.
257
257
  reportSection.labelFunc = (timerType) => timerType.meta.urlPath;
258
258
  // Custom table structure.
259
- reportSection.table = new Table({
259
+ reportSection.table = new table_1.SimpleTable({
260
260
  head: [reportSection.title, 'Time'],
261
261
  colAligns: ['left', 'right'],
262
262
  chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
@@ -327,7 +327,7 @@ class ProfileReportSection {
327
327
  this.timerTypes = timerTypes;
328
328
  this.totalDuration = totalDuration;
329
329
  // Default table structure.
330
- this.table = new Table({
330
+ this.table = new table_1.SimpleTable({
331
331
  head: [title, '%', 'Time', 'Stats'],
332
332
  colAligns: ['left', 'right', 'right', 'left'],
333
333
  chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
@@ -0,0 +1,19 @@
1
+ export interface ProgressBarPayload {
2
+ customDuration?: string;
3
+ }
4
+ /**
5
+ * Minimal TTY progress bar replacing `cli-progress`.
6
+ */
7
+ export declare class ProgressBar {
8
+ private readonly isTTY;
9
+ private readonly label;
10
+ private active;
11
+ private total;
12
+ private value;
13
+ constructor(label: string);
14
+ start(total: number, startValue?: number, payload?: ProgressBarPayload): void;
15
+ increment(deltaOrPayload?: number | ProgressBarPayload, payload?: ProgressBarPayload): void;
16
+ update(value: number, payload?: ProgressBarPayload): void;
17
+ stop(): void;
18
+ private render;
19
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ProgressBar = void 0;
7
+ const ansi_1 = __importDefault(require("./ansi"));
8
+ /**
9
+ * Minimal TTY progress bar replacing `cli-progress`.
10
+ */
11
+ class ProgressBar {
12
+ constructor(label) {
13
+ this.active = false;
14
+ this.total = 0;
15
+ this.value = 0;
16
+ this.label = label;
17
+ this.isTTY = Boolean(process.env.TERM !== 'dumb' && process.stdout.isTTY);
18
+ }
19
+ start(total, startValue = 0, payload) {
20
+ this.total = total;
21
+ this.value = startValue;
22
+ this.active = true;
23
+ this.render(payload);
24
+ }
25
+ increment(deltaOrPayload, payload) {
26
+ if (typeof deltaOrPayload === 'number') {
27
+ this.value += deltaOrPayload;
28
+ this.render(payload);
29
+ }
30
+ else {
31
+ this.value += 1;
32
+ this.render(deltaOrPayload);
33
+ }
34
+ }
35
+ update(value, payload) {
36
+ this.value = value;
37
+ this.render(payload);
38
+ }
39
+ stop() {
40
+ if (!this.active) {
41
+ return;
42
+ }
43
+ this.active = false;
44
+ if (this.isTTY) {
45
+ process.stdout.write('\n');
46
+ }
47
+ }
48
+ render(payload) {
49
+ if (!this.active || !this.isTTY) {
50
+ return;
51
+ }
52
+ const width = 32;
53
+ const ratio = this.total > 0 ? Math.min(1, Math.max(0, this.value / this.total)) : 1;
54
+ const filled = Math.round(ratio * width);
55
+ const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(width - filled);
56
+ const duration = payload?.customDuration
57
+ ? ` Total: ${payload.customDuration}`
58
+ : '';
59
+ const line = ansi_1.default.green(`${this.label} (${this.value}/${this.total}): `) +
60
+ `${bar}${duration}`;
61
+ process.stdout.write(`\r${line}\x1b[K`);
62
+ }
63
+ }
64
+ exports.ProgressBar = ProgressBar;
@@ -21,7 +21,7 @@ export interface RouteOptions {
21
21
  /** Fields to store on the route. */
22
22
  fields?: Record<string, any>;
23
23
  }
24
- export declare type RouteBuilder = (provider: RouteProvider) => Promise<void>;
24
+ export type RouteBuilder = (provider: RouteProvider) => Promise<void>;
25
25
  export declare class Router {
26
26
  pod: Pod;
27
27
  providers: Record<string, RouteProvider[]>;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  Object.defineProperty(exports, "__esModule", { value: true });
22
36
  exports.StaticRoute = exports.DocumentRoute = exports.Route = exports.StaticDirectoryRouteProvider = exports.CollectionRouteProvider = exports.DocumentRouteProvider = exports.RouteProvider = exports.Router = void 0;
23
37
  const fsPath = __importStar(require("path"));
@@ -197,11 +211,11 @@ class CollectionRouteProvider extends RouteProvider {
197
211
  if (!document_1.Document.isServable(doc.podPath)) {
198
212
  return;
199
213
  }
200
- // Add base doc.
201
- addRoute(doc.podPath);
214
+ // Add base doc using its effective default locale.
215
+ addRoute(doc.podPath, doc.defaultLocale);
202
216
  // Add localized docs.
203
217
  doc.locales.forEach((locale) => {
204
- if (locale !== doc.defaultLocale) {
218
+ if (locale.id !== doc.defaultLocale.id) {
205
219
  addRoute(doc.podPath, locale);
206
220
  }
207
221
  });
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- import * as chokidar from 'chokidar';
3
1
  import * as events from 'events';
4
2
  import * as http from 'http';
5
3
  import { Pod } from './pod';
@@ -11,11 +9,15 @@ export interface ServerListeningEvent {
11
9
  app: http.Server;
12
10
  server: Server;
13
11
  }
12
+ export interface ServerWatcher {
13
+ close(): Promise<void>;
14
+ on(event: string, listener: (...args: any[]) => void): any;
15
+ }
14
16
  export declare class Server extends events.EventEmitter {
15
17
  private pod;
16
18
  private httpServer?;
17
19
  port: number;
18
- watcher?: chokidar.FSWatcher;
20
+ watcher?: ServerWatcher;
19
21
  static AUTORELOAD_PATHS_REGEX: RegExp;
20
22
  static CLEAR_MODULE_CACHE_PATH_REGEX: RegExp;
21
23
  static PLUGINS_PATH: string;