@amagaki/amagaki 3.1.2 → 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.
- package/README.md +66 -62
- package/dist/src/ansi.d.ts +10 -0
- package/dist/src/ansi.js +17 -0
- package/dist/src/builder.d.ts +4 -4
- package/dist/src/builder.js +51 -43
- package/dist/src/cli.js +24 -10
- package/dist/src/collection.js +27 -16
- package/dist/src/commands/global.js +1 -2
- package/dist/src/commands/serve.js +5 -5
- package/dist/src/concurrency.d.ts +9 -0
- package/dist/src/concurrency.js +27 -0
- package/dist/src/deepWalk.d.ts +8 -0
- package/dist/src/deepWalk.js +30 -0
- package/dist/src/document.d.ts +2 -3
- package/dist/src/document.js +29 -18
- package/dist/src/gitData.js +23 -10
- package/dist/src/index.js +5 -1
- package/dist/src/locale.d.ts +2 -2
- package/dist/src/plugins/builder.d.ts +2 -2
- package/dist/src/plugins/index.js +5 -1
- package/dist/src/plugins/nunjucks.js +23 -9
- package/dist/src/plugins/server.d.ts +1 -1
- package/dist/src/plugins/yaml.js +22 -8
- package/dist/src/pod.d.ts +38 -1
- package/dist/src/pod.js +135 -21
- package/dist/src/profile.d.ts +1 -1
- package/dist/src/profile.js +3 -3
- package/dist/src/progress.d.ts +19 -0
- package/dist/src/progress.js +64 -0
- package/dist/src/router.d.ts +1 -1
- package/dist/src/router.js +25 -11
- package/dist/src/server.d.ts +5 -3
- package/dist/src/server.js +33 -12
- package/dist/src/table.d.ts +16 -0
- package/dist/src/table.js +62 -0
- package/dist/src/url.js +22 -8
- package/dist/src/utils.d.ts +5 -6
- package/dist/src/utils.js +31 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -61
|
@@ -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;
|
package/dist/src/document.d.ts
CHANGED
|
@@ -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
|
-
|
|
18
|
-
export
|
|
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).
|
package/dist/src/document.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.
|
|
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 (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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("
|
|
31
|
-
const minimatch_1 =
|
|
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(
|
|
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.
|
|
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
|
}
|
package/dist/src/gitData.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.
|
|
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 (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 =
|
|
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.
|
|
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];
|
package/dist/src/locale.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Document } from './document';
|
|
2
2
|
import { Pod } from './pod';
|
|
3
3
|
import { TranslationString } from './string';
|
|
4
|
-
export
|
|
5
|
-
|
|
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
|
|
5
|
-
export
|
|
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.
|
|
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.
|
|
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 (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
4
|
+
export type createServerCallbacks = (app: express.Express) => Promise<void>;
|
|
5
5
|
/**
|
|
6
6
|
* Plugin providing access to the Express server.
|
|
7
7
|
*/
|
package/dist/src/plugins/yaml.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.
|
|
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 (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,6 +12,18 @@ import { DocumentView } from '.';
|
|
|
12
12
|
import { Profiler } from './profile';
|
|
13
13
|
import { StaticFile } from './staticFile';
|
|
14
14
|
import { TemplateEngineManager } from './templateEngine';
|
|
15
|
+
export type TypeScriptLoader = 'sucrase' | 'tsx' | 'esbuild-register' | 'jiti' | 'auto';
|
|
16
|
+
export interface PodOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Preferred TypeScript loader for amagaki.ts files.
|
|
19
|
+
* - 'sucrase': Simple, fast loader (default for backwards compatibility)
|
|
20
|
+
* - 'tsx': Modern, fast, esbuild-based loader (recommended for monorepos)
|
|
21
|
+
* - 'esbuild-register': Fast alternative with good monorepo support
|
|
22
|
+
* - 'jiti': Universal loader with excellent compatibility
|
|
23
|
+
* - 'auto': Try loaders in order: tsx -> esbuild-register -> jiti -> sucrase
|
|
24
|
+
*/
|
|
25
|
+
tsLoader?: TypeScriptLoader;
|
|
26
|
+
}
|
|
15
27
|
export interface LocalizationConfig {
|
|
16
28
|
defaultLocale?: string;
|
|
17
29
|
locales?: Array<string>;
|
|
@@ -32,6 +44,23 @@ export interface PodConfig {
|
|
|
32
44
|
* references to things like the build environment, template engines, file
|
|
33
45
|
* system accessors, routes, etc. Pods provide an interaction model for accessing
|
|
34
46
|
* the different elements of a site and operating on them.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Basic usage
|
|
51
|
+
* const pod = new Pod('./path/to/site');
|
|
52
|
+
*
|
|
53
|
+
* // With environment options
|
|
54
|
+
* const pod = new Pod('./path/to/site', {
|
|
55
|
+
* name: 'prod',
|
|
56
|
+
* host: 'https://example.com',
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // With TypeScript loader preference (for monorepos with complex imports)
|
|
60
|
+
* const pod = new Pod('./path/to/site', undefined, {
|
|
61
|
+
* tsLoader: 'tsx' // or 'esbuild-register', 'jiti', 'sucrase' (default), 'auto'
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
35
64
|
*/
|
|
36
65
|
export declare class Pod {
|
|
37
66
|
static BuiltInPlugins: Array<PluginConstructor>;
|
|
@@ -48,8 +77,16 @@ export declare class Pod {
|
|
|
48
77
|
readonly plugins: Plugins;
|
|
49
78
|
readonly root: string;
|
|
50
79
|
readonly router: Router;
|
|
51
|
-
constructor(root: string, environmentOptions?: EnvironmentOptions);
|
|
80
|
+
constructor(root: string, environmentOptions?: EnvironmentOptions, podOptions?: PodOptions);
|
|
52
81
|
toString(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Registers a TypeScript loader based on the specified preference.
|
|
84
|
+
* Supports tsx, esbuild-register, jiti, or auto-detection.
|
|
85
|
+
* @param loader The TypeScript loader to use.
|
|
86
|
+
* @param podPath The path to the config file being loaded.
|
|
87
|
+
* @returns true if the config was already loaded by the loader (e.g., jiti), false otherwise.
|
|
88
|
+
*/
|
|
89
|
+
private registerTypeScriptLoader;
|
|
53
90
|
/**
|
|
54
91
|
* Returns a collection object. If no `_collection.yaml` file is found within
|
|
55
92
|
* the requested directory, the directory will be walked upwards until finding
|
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.
|
|
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 (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,15 +59,32 @@ 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
|
|
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
|
|
52
66
|
* system accessors, routes, etc. Pods provide an interaction model for accessing
|
|
53
67
|
* the different elements of a site and operating on them.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Basic usage
|
|
72
|
+
* const pod = new Pod('./path/to/site');
|
|
73
|
+
*
|
|
74
|
+
* // With environment options
|
|
75
|
+
* const pod = new Pod('./path/to/site', {
|
|
76
|
+
* name: 'prod',
|
|
77
|
+
* host: 'https://example.com',
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // With TypeScript loader preference (for monorepos with complex imports)
|
|
81
|
+
* const pod = new Pod('./path/to/site', undefined, {
|
|
82
|
+
* tsLoader: 'tsx' // or 'esbuild-register', 'jiti', 'sucrase' (default), 'auto'
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
54
85
|
*/
|
|
55
86
|
class Pod {
|
|
56
|
-
constructor(root, environmentOptions) {
|
|
87
|
+
constructor(root, environmentOptions, podOptions) {
|
|
57
88
|
this.defaultContentPodPath = '/content/';
|
|
58
89
|
this.defaultView = '/views/base.njk';
|
|
59
90
|
// Anything that occurs in the Pod constructor must be very lightweight.
|
|
@@ -78,20 +109,24 @@ class Pod {
|
|
|
78
109
|
this.plugins.register(BuiltInPlugin, {});
|
|
79
110
|
}
|
|
80
111
|
// Setup the pod using the `amagaki.{js|ts}` file.
|
|
81
|
-
// Use
|
|
112
|
+
// Use modern TS loaders that support ESM imports and monorepo resolution.
|
|
82
113
|
for (const podPath of Pod.DefaultConfigFiles) {
|
|
83
114
|
if (this.fileExists(podPath)) {
|
|
115
|
+
let configAlreadyLoaded = false;
|
|
84
116
|
if (podPath.endsWith('.ts')) {
|
|
85
|
-
|
|
117
|
+
configAlreadyLoaded = this.registerTypeScriptLoader(podOptions?.tsLoader ?? 'sucrase', podPath);
|
|
118
|
+
}
|
|
119
|
+
// If the loader already loaded the config (e.g., jiti), skip the require()
|
|
120
|
+
if (!configAlreadyLoaded) {
|
|
121
|
+
const configFilename = this.getAbsoluteFilePath(podPath);
|
|
122
|
+
// Allow runtime reloading of the config file.
|
|
123
|
+
delete require.cache[require.resolve(configFilename)];
|
|
124
|
+
// tslint:disable-next-line
|
|
125
|
+
const amagakiConfig = require(configFilename);
|
|
126
|
+
amagakiConfig && typeof amagakiConfig.default === 'function'
|
|
127
|
+
? amagakiConfig.default(this)
|
|
128
|
+
: amagakiConfig(this);
|
|
86
129
|
}
|
|
87
|
-
const configFilename = this.getAbsoluteFilePath(podPath);
|
|
88
|
-
// Allow runtime reloading of the config file.
|
|
89
|
-
delete require.cache[require.resolve(configFilename)];
|
|
90
|
-
// tslint:disable-next-line
|
|
91
|
-
const amagakiConfig = require(configFilename);
|
|
92
|
-
amagakiConfig && typeof amagakiConfig.default === 'function'
|
|
93
|
-
? amagakiConfig.default(this)
|
|
94
|
-
: amagakiConfig(this);
|
|
95
130
|
break;
|
|
96
131
|
}
|
|
97
132
|
}
|
|
@@ -99,6 +134,85 @@ class Pod {
|
|
|
99
134
|
toString() {
|
|
100
135
|
return `[Pod: ${this.root}]`;
|
|
101
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Registers a TypeScript loader based on the specified preference.
|
|
139
|
+
* Supports tsx, esbuild-register, jiti, or auto-detection.
|
|
140
|
+
* @param loader The TypeScript loader to use.
|
|
141
|
+
* @param podPath The path to the config file being loaded.
|
|
142
|
+
* @returns true if the config was already loaded by the loader (e.g., jiti), false otherwise.
|
|
143
|
+
*/
|
|
144
|
+
registerTypeScriptLoader(loader, podPath) {
|
|
145
|
+
const configFilename = this.getAbsoluteFilePath(podPath);
|
|
146
|
+
// Helper to try a specific loader
|
|
147
|
+
const tryLoader = (loaderName) => {
|
|
148
|
+
try {
|
|
149
|
+
switch (loaderName) {
|
|
150
|
+
case 'sucrase':
|
|
151
|
+
require('sucrase/register/ts');
|
|
152
|
+
return true;
|
|
153
|
+
case 'tsx':
|
|
154
|
+
require('tsx/cjs/api').register();
|
|
155
|
+
return true;
|
|
156
|
+
case 'esbuild-register':
|
|
157
|
+
require('esbuild-register/dist/node').register();
|
|
158
|
+
return true;
|
|
159
|
+
case 'jiti': {
|
|
160
|
+
const jiti = require('jiti')(__filename, {
|
|
161
|
+
interopDefault: true,
|
|
162
|
+
esmResolve: true,
|
|
163
|
+
});
|
|
164
|
+
// jiti requires direct file loading, not registration
|
|
165
|
+
delete require.cache[require.resolve(configFilename)];
|
|
166
|
+
const amagakiConfig = jiti(configFilename);
|
|
167
|
+
amagakiConfig && typeof amagakiConfig.default === 'function'
|
|
168
|
+
? amagakiConfig.default(this)
|
|
169
|
+
: amagakiConfig(this);
|
|
170
|
+
// Signal that we've handled the config loading
|
|
171
|
+
return 'handled';
|
|
172
|
+
}
|
|
173
|
+
default:
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
// If a specific loader is requested, try only that one
|
|
182
|
+
if (loader !== 'auto') {
|
|
183
|
+
const result = tryLoader(loader);
|
|
184
|
+
if (result === 'handled') {
|
|
185
|
+
// jiti has already loaded the config
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
if (!result) {
|
|
189
|
+
console.warn(ansi_1.default.yellow(`Warning: Could not load TypeScript loader "${loader}". ` +
|
|
190
|
+
`Make sure it's installed. Falling back to require().`));
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
// Auto mode: try loaders in order of preference (modern first, then sucrase for compatibility)
|
|
195
|
+
const loaders = [
|
|
196
|
+
'tsx',
|
|
197
|
+
'esbuild-register',
|
|
198
|
+
'jiti',
|
|
199
|
+
'sucrase',
|
|
200
|
+
];
|
|
201
|
+
for (const loaderName of loaders) {
|
|
202
|
+
const result = tryLoader(loaderName);
|
|
203
|
+
if (result === 'handled') {
|
|
204
|
+
// jiti has already loaded the config
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (result) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// No loader found
|
|
212
|
+
console.warn(ansi_1.default.yellow('Warning: No TypeScript loader found (tsx, esbuild-register, jiti, or sucrase). ' +
|
|
213
|
+
'Install at least one TypeScript loader to use .ts config files.'));
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
102
216
|
/**
|
|
103
217
|
* Returns a collection object. If no `_collection.yaml` file is found within
|
|
104
218
|
* the requested directory, the directory will be walked upwards until finding
|
|
@@ -433,7 +547,7 @@ class Pod {
|
|
|
433
547
|
const seconds = await this.router.warmup();
|
|
434
548
|
const routes = await this.router.routes();
|
|
435
549
|
if (routes.length > 5000) {
|
|
436
|
-
console.log(
|
|
550
|
+
console.log(ansi_1.default.blue('Warmed up: ') +
|
|
437
551
|
`${routes.length} routes in ${seconds.toFixed(2)}s`);
|
|
438
552
|
}
|
|
439
553
|
}
|
package/dist/src/profile.d.ts
CHANGED
package/dist/src/profile.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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': '' },
|