@kensio/colophon 2.15.3 → 2.15.5
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 +1 -1
- package/dist/cli/args/command.d.ts +3 -3
- package/dist/cli/args/command.d.ts.map +1 -1
- package/dist/cli/args/command.js +3 -2
- package/dist/cli/args/command.js.map +1 -1
- package/dist/cli/args/index.d.ts +2 -2
- package/dist/cli/args/index.d.ts.map +1 -1
- package/dist/cli/args/index.js +2 -1
- package/dist/cli/args/index.js.map +1 -1
- package/dist/cli/args/usage.d.ts +1 -1
- package/dist/cli/args/usage.d.ts.map +1 -1
- package/dist/cli/args/usage.js +9 -2
- package/dist/cli/args/usage.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/playground/background.d.ts +6 -0
- package/dist/cli/playground/background.d.ts.map +1 -0
- package/dist/cli/playground/background.js +15 -0
- package/dist/cli/playground/background.js.map +1 -0
- package/dist/cli/playground/config.d.ts +8 -0
- package/dist/cli/playground/config.d.ts.map +1 -0
- package/dist/cli/playground/config.js +46 -0
- package/dist/cli/playground/config.js.map +1 -0
- package/dist/cli/playground/discover.d.ts +6 -0
- package/dist/cli/playground/discover.d.ts.map +1 -0
- package/dist/cli/playground/discover.js +37 -0
- package/dist/cli/playground/discover.js.map +1 -0
- package/dist/cli/playground/index.d.ts +10 -0
- package/dist/cli/playground/index.d.ts.map +1 -0
- package/dist/cli/playground/index.js +37 -0
- package/dist/cli/playground/index.js.map +1 -0
- package/dist/cli/playground/sample.d.ts +10 -0
- package/dist/cli/playground/sample.d.ts.map +1 -0
- package/dist/cli/playground/sample.js +46 -0
- package/dist/cli/playground/sample.js.map +1 -0
- package/dist/cli/playground/share.d.ts +9 -0
- package/dist/cli/playground/share.d.ts.map +1 -0
- package/dist/cli/playground/share.js +11 -0
- package/dist/cli/playground/share.js.map +1 -0
- package/dist/generate/index.d.ts +4 -1
- package/dist/generate/index.d.ts.map +1 -1
- package/dist/generate/index.js +6 -1
- package/dist/generate/index.js.map +1 -1
- package/dist/generate/options.d.ts +14 -0
- package/dist/generate/options.d.ts.map +1 -1
- package/dist/generate/options.js +6 -0
- package/dist/generate/options.js.map +1 -1
- package/dist/generate/plan.d.ts +8 -0
- package/dist/generate/plan.d.ts.map +1 -1
- package/dist/generate/plan.js +1 -0
- package/dist/generate/plan.js.map +1 -1
- package/dist/generate/thread-pool.d.ts +30 -0
- package/dist/generate/thread-pool.d.ts.map +1 -0
- package/dist/generate/thread-pool.js +59 -0
- package/dist/generate/thread-pool.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ together.
|
|
|
99
99
|
Full documentation is in [`docs/`](./docs/).
|
|
100
100
|
|
|
101
101
|
- [Getting started](./docs/getting-started/ "Install, frontmatter, config and the CLI")
|
|
102
|
-
- [The command line](./docs/cli/ "Every command and flag, including init, preview, eject, dry runs and watching")
|
|
102
|
+
- [The command line](./docs/cli/ "Every command and flag, including init, preview, playground links, eject, dry runs and watching")
|
|
103
103
|
- [Templates](./docs/templates/ "The built-in layouts and how to register your own")
|
|
104
104
|
- [The code template](./docs/code-template/ "Syntax-highlighted code images")
|
|
105
105
|
- [Astro](./docs/astro/ "The integration and the meta tags component")
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** What the CLI has been asked to do. */
|
|
2
|
-
export type CliCommand = "generate" | "init" | "preview" | "eject";
|
|
2
|
+
export type CliCommand = "generate" | "init" | "preview" | "playground" | "eject";
|
|
3
3
|
/**
|
|
4
4
|
* Read the command out of the first argument.
|
|
5
5
|
*
|
|
6
6
|
* It is a command only where it names one: `colophon content` has always meant
|
|
7
7
|
* "build this tree", so a bare positional stays the content directory, and a
|
|
8
8
|
* subcommand is an addition to that rather than a replacement for it. The cost
|
|
9
|
-
* is that a content directory
|
|
10
|
-
*
|
|
9
|
+
* is that a content directory named after any command has to be written with
|
|
10
|
+
* a relative path such as `./init`. The help text says so.
|
|
11
11
|
*/
|
|
12
12
|
export declare function commandOf(first: string | undefined): CliCommand;
|
|
13
13
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/cli/args/command.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/cli/args/command.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,MAAM,GACN,SAAS,GACT,YAAY,GACZ,OAAO,CAAC;AAaZ;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAE/D"}
|
package/dist/cli/args/command.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const named = {
|
|
6
6
|
init: "init",
|
|
7
7
|
preview: "preview",
|
|
8
|
+
playground: "playground",
|
|
8
9
|
eject: "eject",
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
@@ -13,8 +14,8 @@ const named = {
|
|
|
13
14
|
* It is a command only where it names one: `colophon content` has always meant
|
|
14
15
|
* "build this tree", so a bare positional stays the content directory, and a
|
|
15
16
|
* subcommand is an addition to that rather than a replacement for it. The cost
|
|
16
|
-
* is that a content directory
|
|
17
|
-
*
|
|
17
|
+
* is that a content directory named after any command has to be written with
|
|
18
|
+
* a relative path such as `./init`. The help text says so.
|
|
18
19
|
*/
|
|
19
20
|
export function commandOf(first) {
|
|
20
21
|
return (first === undefined ? undefined : named[first]) ?? "generate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/cli/args/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/cli/args/command.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,KAAK,GAAyC;IAClD,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,KAAyB;IACjD,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC;AACxE,CAAC"}
|
package/dist/cli/args/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface CliArgs {
|
|
|
11
11
|
* `generate` reads as the default and `init` as an invitation to guess.
|
|
12
12
|
*/
|
|
13
13
|
readonly contentDir: string | undefined;
|
|
14
|
-
/** The post `preview` renders. */
|
|
14
|
+
/** The post `preview` renders or `playground` includes. */
|
|
15
15
|
readonly file: string | undefined;
|
|
16
16
|
/** What `eject` writes, naming the generator it is for. */
|
|
17
17
|
readonly adapter: string | undefined;
|
|
@@ -20,7 +20,7 @@ export interface CliArgs {
|
|
|
20
20
|
readonly dryRun: boolean;
|
|
21
21
|
readonly watch: boolean;
|
|
22
22
|
readonly concurrency: number | undefined;
|
|
23
|
-
/** Which configured size `preview` renders. */
|
|
23
|
+
/** Which configured size `preview` renders or `playground` opens. */
|
|
24
24
|
readonly size: string | undefined;
|
|
25
25
|
}
|
|
26
26
|
/** Read the command line into the options each command takes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/args/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/args/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AA4CD,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAyC7D"}
|
package/dist/cli/args/index.js
CHANGED
|
@@ -13,7 +13,8 @@ function target(command, positionals) {
|
|
|
13
13
|
const first = positionals[0];
|
|
14
14
|
const empty = { contentDir: undefined, file: undefined, adapter: undefined };
|
|
15
15
|
switch (command) {
|
|
16
|
-
case "preview":
|
|
16
|
+
case "preview":
|
|
17
|
+
case "playground": {
|
|
17
18
|
return { ...empty, file: first };
|
|
18
19
|
}
|
|
19
20
|
case "eject": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/args/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAyBnC,+EAA+E;AAC/E,SAAS,MAAM,CACb,OAAmB,EACnB,WAA8B;IAE9B,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAE7B,2EAA2E;IAC3E,mEAAmE;IACnE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAE7E,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/args/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAyBnC,+EAA+E;AAC/E,SAAS,MAAM,CACb,OAAmB,EACnB,WAA8B;IAE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QACL,OAAO;QACP,GAAG,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,YAAY,CAAC,KAAK,CAAC;KACvB,CAAC;AACJ,CAAC"}
|
package/dist/cli/args/usage.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Help text for `--help`, and for a run that asks for nothing else. */
|
|
2
|
-
export declare const usage = "colophon: generate social meta images from frontmatter\n\nUsage:\n colophon [contentDir] [options] Render the images for a content tree\n colophon init [contentDir] Write a starter config module\n colophon preview <file> [options] Render one post and open it\n colophon eject hugo Write a Hugo partial that reads the\n manifest and emits the meta tags\n\nImages carry a stamp of the props, config and size they came from, so a rebuild\nrenders only the ones that have actually changed.\n\nOptions:\n -c, --config <path> Load a config module. Its default export is either a\n ColophonConfig or a function (async or not) returning\n one, for a config that has to compute something.\n -f, --force Re-render every image, ignoring the stamps. For init\n and eject, overwrite a file that is already there\n -o, --overwrite Alias for --force\n -n, --dry-run Report what would change and write nothing\n -w, --watch Rebuild whenever a content file changes\n --concurrency <n> How many images to render at once\n --size <name> Which configured size preview renders\n -h, --help Show this help\n\nDefaults:\n contentDir content\n --concurrency one per available CPU\n --size the first configured size\n\nThe first argument is a command where it names one, so a content directory\ncalled init, preview or eject has to be written as ./init.";
|
|
2
|
+
export declare const usage = "colophon: generate social meta images from frontmatter\n\nUsage:\n colophon [contentDir] [options] Render the images for a content tree\n colophon init [contentDir] Write a starter config module\n colophon preview <file> [options] Render one post and open it\n colophon playground [file] [options]\n Print a playground link for this project\n colophon eject hugo Write a Hugo partial that reads the\n manifest and emits the meta tags\n\nImages carry a stamp of the props, config and size they came from, so a rebuild\nrenders only the ones that have actually changed.\n\nOptions:\n -c, --config <path> Load a config module. Its default export is either a\n ColophonConfig or a function (async or not) returning\n one, for a config that has to compute something.\n -f, --force Re-render every image, ignoring the stamps. For init\n and eject, overwrite a file that is already there\n -o, --overwrite Alias for --force\n -n, --dry-run Report what would change and write nothing\n -w, --watch Rebuild whenever a content file changes\n --concurrency <n> How many images to render at once\n --size <name> Which configured size preview renders, or the\n playground link opens\n -h, --help Show this help\n\nDefaults:\n contentDir content\n --concurrency one per available CPU\n --size the first configured size\n\nRendering happens on the libuv thread pool, four threads deep unless\nUV_THREADPOOL_SIZE says otherwise. A higher concurrency than that queues, and\nthe build warns. Raise the pool by setting the variable in the environment.\n\nThe first argument is a command where it names one, so a content directory\ncalled init, preview, playground or eject has to be written as ./init.";
|
|
3
3
|
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/cli/args/usage.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/cli/args/usage.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,KAAK,m8DAsCqD,CAAC"}
|
package/dist/cli/args/usage.js
CHANGED
|
@@ -5,6 +5,8 @@ Usage:
|
|
|
5
5
|
colophon [contentDir] [options] Render the images for a content tree
|
|
6
6
|
colophon init [contentDir] Write a starter config module
|
|
7
7
|
colophon preview <file> [options] Render one post and open it
|
|
8
|
+
colophon playground [file] [options]
|
|
9
|
+
Print a playground link for this project
|
|
8
10
|
colophon eject hugo Write a Hugo partial that reads the
|
|
9
11
|
manifest and emits the meta tags
|
|
10
12
|
|
|
@@ -21,7 +23,8 @@ Options:
|
|
|
21
23
|
-n, --dry-run Report what would change and write nothing
|
|
22
24
|
-w, --watch Rebuild whenever a content file changes
|
|
23
25
|
--concurrency <n> How many images to render at once
|
|
24
|
-
--size <name> Which configured size preview renders
|
|
26
|
+
--size <name> Which configured size preview renders, or the
|
|
27
|
+
playground link opens
|
|
25
28
|
-h, --help Show this help
|
|
26
29
|
|
|
27
30
|
Defaults:
|
|
@@ -29,6 +32,10 @@ Defaults:
|
|
|
29
32
|
--concurrency one per available CPU
|
|
30
33
|
--size the first configured size
|
|
31
34
|
|
|
35
|
+
Rendering happens on the libuv thread pool, four threads deep unless
|
|
36
|
+
UV_THREADPOOL_SIZE says otherwise. A higher concurrency than that queues, and
|
|
37
|
+
the build warns. Raise the pool by setting the variable in the environment.
|
|
38
|
+
|
|
32
39
|
The first argument is a command where it names one, so a content directory
|
|
33
|
-
called init, preview or eject has to be written as ./init.`;
|
|
40
|
+
called init, preview, playground or eject has to be written as ./init.`;
|
|
34
41
|
//# sourceMappingURL=usage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/cli/args/usage.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,CAAC,MAAM,KAAK,GAAG
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/cli/args/usage.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAsCkD,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { runBuild } from "./build.js";
|
|
|
4
4
|
import { runEject } from "./eject/index.js";
|
|
5
5
|
import { runInit } from "./init/index.js";
|
|
6
6
|
import { messageOf } from "./message.js";
|
|
7
|
+
import { runPlayground } from "./playground/index.js";
|
|
7
8
|
import { runPreview } from "./preview/index.js";
|
|
8
9
|
/** Run whichever command the arguments asked for. */
|
|
9
10
|
async function run(args) {
|
|
@@ -14,6 +15,9 @@ async function run(args) {
|
|
|
14
15
|
case "preview": {
|
|
15
16
|
return runPreview(args);
|
|
16
17
|
}
|
|
18
|
+
case "playground": {
|
|
19
|
+
return runPlayground(args);
|
|
20
|
+
}
|
|
17
21
|
case "eject": {
|
|
18
22
|
return runEject(args);
|
|
19
23
|
}
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,qDAAqD;AACrD,KAAK,UAAU,GAAG,CAAC,IAAa;IAC9B,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,KAAK,MAAM,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,UAAU,EAAE,CAAC;YAChB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;IAED,MAAM,GAAG,CAAC,YAAY,CAAC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,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;IAED,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,IAAI,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Background, OutputSize } from "../../types.js";
|
|
2
|
+
/** Drop a background image, whose source the browser cannot load. */
|
|
3
|
+
export declare function browserBackground(background: Background | undefined, label: string, omitted: string[]): Background | undefined;
|
|
4
|
+
/** Drop an image background from one size override. */
|
|
5
|
+
export declare function browserSize(size: OutputSize, omitted: string[]): OutputSize;
|
|
6
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/background.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE7D,qEAAqE;AACrE,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,GAChB,UAAU,GAAG,SAAS,CAOxB;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CAS3E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Drop a background image, whose source the browser cannot load. */
|
|
2
|
+
export function browserBackground(background, label, omitted) {
|
|
3
|
+
if (background?.type === "image") {
|
|
4
|
+
omitted.push(label);
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
return background;
|
|
8
|
+
}
|
|
9
|
+
/** Drop an image background from one size override. */
|
|
10
|
+
export function browserSize(size, omitted) {
|
|
11
|
+
const { background, ...rest } = size;
|
|
12
|
+
const kept = browserBackground(background, `sizes.${size.name}.background`, omitted);
|
|
13
|
+
return { ...rest, ...(kept === undefined ? {} : { background: kept }) };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.js","sourceRoot":"","sources":["../../../src/cli/playground/background.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,UAAU,iBAAiB,CAC/B,UAAkC,EAClC,KAAa,EACb,OAAiB;IAEjB,IAAI,UAAU,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,OAAiB;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,IAAI,GAAG,iBAAiB,CAC5B,UAAU,EACV,SAAS,IAAI,CAAC,IAAI,aAAa,EAC/B,OAAO,CACR,CAAC;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColophonConfig } from "../../types.js";
|
|
2
|
+
export interface PlaygroundConfig {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly omitted: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
/** Write the JSON subset of a project config that the browser can use. */
|
|
7
|
+
export declare function configForPlayground(config: ColophonConfig | undefined): PlaygroundConfig;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAGrE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAiBD,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,gBAAgB,CAiDlB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { browserBackground, browserSize } from "./background.js";
|
|
2
|
+
function browserContent(content, omitted) {
|
|
3
|
+
if (content === undefined) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const { props, ...rest } = content;
|
|
7
|
+
if (props !== undefined) {
|
|
8
|
+
omitted.push("content.props");
|
|
9
|
+
}
|
|
10
|
+
return rest;
|
|
11
|
+
}
|
|
12
|
+
/** Write the JSON subset of a project config that the browser can use. */
|
|
13
|
+
export function configForPlayground(config) {
|
|
14
|
+
if (config === undefined) {
|
|
15
|
+
return { text: "{}", omitted: [] };
|
|
16
|
+
}
|
|
17
|
+
const omitted = [];
|
|
18
|
+
const { background, content, extra, fonts, logo, manifest, onWarning, placement, rasteriser, sizes, templates, ...rest } = config;
|
|
19
|
+
const named = [
|
|
20
|
+
["extra", extra],
|
|
21
|
+
["fonts", fonts],
|
|
22
|
+
["logo", logo],
|
|
23
|
+
["manifest", manifest],
|
|
24
|
+
["onWarning", onWarning],
|
|
25
|
+
["placement", placement],
|
|
26
|
+
["rasteriser", rasteriser],
|
|
27
|
+
["templates", templates],
|
|
28
|
+
];
|
|
29
|
+
for (const [name, value] of named) {
|
|
30
|
+
if (value !== undefined) {
|
|
31
|
+
omitted.push(name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const keptBackground = browserBackground(background, "background", omitted);
|
|
35
|
+
const keptContent = browserContent(content, omitted);
|
|
36
|
+
const browserConfig = {
|
|
37
|
+
...rest,
|
|
38
|
+
...(keptBackground === undefined ? {} : { background: keptBackground }),
|
|
39
|
+
...(keptContent === undefined ? {} : { content: keptContent }),
|
|
40
|
+
...(sizes === undefined
|
|
41
|
+
? {}
|
|
42
|
+
: { sizes: sizes.map((size) => browserSize(size, omitted)) }),
|
|
43
|
+
};
|
|
44
|
+
return { text: JSON.stringify(browserConfig, undefined, 2), omitted };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/playground/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOjE,SAAS,cAAc,CACrB,OAAmC,EACnC,OAAiB;IAEjB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mB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AC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAC9D,GAAG,CAAC,KAAK,KAAK,SAAS;YACrB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColophonConfig, ContentFile } from "../../types.js";
|
|
2
|
+
/** The requested config, or the conventional config found in the project. */
|
|
3
|
+
export declare function playgroundConfigPath(requested: string | undefined, dir: string): Promise<string | undefined>;
|
|
4
|
+
/** Find the named post, or the first image post in a conventional content tree. */
|
|
5
|
+
export declare function playgroundSample(file: string | undefined, config: ColophonConfig | undefined, dir: string): Promise<ContentFile | undefined>;
|
|
6
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/discover.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlE,6EAA6E;AAC7E,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAM7B;AAsCD,mFAAmF;AACnF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAIlC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readContentFile, walkContent } from "../../content/index.js";
|
|
3
|
+
import { guessContentDir } from "../init/guess.js";
|
|
4
|
+
import { existingConfig } from "../init/module.js";
|
|
5
|
+
/** The requested config, or the conventional config found in the project. */
|
|
6
|
+
export async function playgroundConfigPath(requested, dir) {
|
|
7
|
+
if (requested !== undefined) {
|
|
8
|
+
return path.resolve(dir, requested);
|
|
9
|
+
}
|
|
10
|
+
const found = await existingConfig(dir);
|
|
11
|
+
return found === undefined ? undefined : path.join(dir, found);
|
|
12
|
+
}
|
|
13
|
+
async function namedFile(file, config, dir) {
|
|
14
|
+
const read = await readContentFile(path.resolve(dir, file), dir, config?.content);
|
|
15
|
+
if (read === undefined) {
|
|
16
|
+
throw new Error(`${file} declares no image props to send to the playground.`);
|
|
17
|
+
}
|
|
18
|
+
return read;
|
|
19
|
+
}
|
|
20
|
+
async function discoveredFile(config, dir) {
|
|
21
|
+
const contentDir = await guessContentDir(dir);
|
|
22
|
+
if (contentDir === undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const files = await walkContent({
|
|
26
|
+
dir: path.join(dir, contentDir),
|
|
27
|
+
...config?.content,
|
|
28
|
+
});
|
|
29
|
+
return files.toSorted((a, b) => a.contentPath.localeCompare(b.contentPath))[0];
|
|
30
|
+
}
|
|
31
|
+
/** Find the named post, or the first image post in a conventional content tree. */
|
|
32
|
+
export function playgroundSample(file, config, dir) {
|
|
33
|
+
return file === undefined
|
|
34
|
+
? discoveredFile(config, dir)
|
|
35
|
+
: namedFile(file, config, dir);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../src/cli/playground/discover.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,E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C;IACH,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC7B,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAC3C,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAC9B,IAAwB,EACxB,MAAkC,EAClC,GAAW;IAEX,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC;QAC7B,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliArgs } from "../args/index.js";
|
|
2
|
+
export interface PlaygroundLink {
|
|
3
|
+
readonly url: string;
|
|
4
|
+
readonly omitted: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
/** Build a colophonjs.dev link carrying this project's config and one post. */
|
|
7
|
+
export declare function playgroundLink(args: CliArgs, dir?: string): Promise<PlaygroundLink>;
|
|
8
|
+
/** Print a colophonjs.dev link carrying this project's config and one post. */
|
|
9
|
+
export declare function runPlayground(args: CliArgs, dir?: string): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQhD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,+EAA+E;AAC/E,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,EACb,GAAG,SAAgB,GAClB,OAAO,CAAC,cAAc,CAAC,CAsBzB;AAED,+EAA+E;AAC/E,wBAAsB,aAAa,CACjC,IAAI,EAAE,OAAO,EACb,GAAG,SAAgB,GAClB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DEFAULT_SIZES } from "../../config/index.js";
|
|
2
|
+
import { loadConfig } from "../config.js";
|
|
3
|
+
import { pickSize } from "../preview/size.js";
|
|
4
|
+
import { configForPlayground } from "./config.js";
|
|
5
|
+
import { playgroundConfigPath, playgroundSample } from "./discover.js";
|
|
6
|
+
import { fallbackFrontmatter, sampleFrontmatter } from "./sample.js";
|
|
7
|
+
import { shareUrl } from "./share.js";
|
|
8
|
+
/** Build a colophonjs.dev link carrying this project's config and one post. */
|
|
9
|
+
export async function playgroundLink(args, dir = process.cwd()) {
|
|
10
|
+
const config = await loadConfig(await playgroundConfigPath(args.configPath, dir));
|
|
11
|
+
if (args.size !== undefined) {
|
|
12
|
+
pickSize(config?.sizes ?? DEFAULT_SIZES, args.size);
|
|
13
|
+
}
|
|
14
|
+
const file = await playgroundSample(args.file, config, dir);
|
|
15
|
+
const frontmatter = file === undefined
|
|
16
|
+
? { text: fallbackFrontmatter(config), omitted: [] }
|
|
17
|
+
: await sampleFrontmatter(file, config);
|
|
18
|
+
const shared = configForPlayground(config);
|
|
19
|
+
return {
|
|
20
|
+
url: shareUrl({
|
|
21
|
+
config: shared.text,
|
|
22
|
+
frontmatter: frontmatter.text,
|
|
23
|
+
...(args.size === undefined ? {} : { size: args.size }),
|
|
24
|
+
}),
|
|
25
|
+
omitted: [...shared.omitted, ...frontmatter.omitted],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Print a colophonjs.dev link carrying this project's config and one post. */
|
|
29
|
+
export async function runPlayground(args, dir = process.cwd()) {
|
|
30
|
+
const link = await playgroundLink(args, dir);
|
|
31
|
+
if (link.omitted.length > 0) {
|
|
32
|
+
console.warn(`The playground cannot use: ${link.omitted.join(", ")}. ` +
|
|
33
|
+
"The link leaves them out.");
|
|
34
|
+
}
|
|
35
|
+
console.log(link.url);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/playground/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAa,EACb,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAEnB,MAAM,MAAM,GAAG,MAAM,UAAU,CAC7B,MAAM,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CACjD,CAAC;IACF,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,WAAW,GACf,IAAI,KAAK,SAAS;QAChB,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACpD,CAAC,CAAC,MAAM,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC;YACZ,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,WAAW,EAAE,WAAW,CAAC,IAAI;YAC7B,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;SACxD,CAAC;QACF,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAa,EACb,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAEnB,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE7C,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CACV,8BAA8B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACvD,2BAA2B,CAC9B,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentFile, ColophonConfig } from "../../types.js";
|
|
2
|
+
export interface PlaygroundFrontmatter {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly omitted: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
/** A generic post for a project where no content file could be found. */
|
|
7
|
+
export declare function fallbackFrontmatter(config: ColophonConfig | undefined): string;
|
|
8
|
+
/** Read a post and make its mapper-produced props explicit for the playground. */
|
|
9
|
+
export declare function sampleFrontmatter(file: ContentFile, config: ColophonConfig | undefined): Promise<PlaygroundFrontmatter>;
|
|
10
|
+
//# sourceMappingURL=sample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/sample.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AA4BD,yEAAyE;AACzE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,MAAM,CASR;AAED,kFAAkF;AAClF,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,OAAO,CAAC,qBAAqB,CAAC,CAYhC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import matter from "gray-matter";
|
|
3
|
+
const defaultPropsKey = "meta_img_props";
|
|
4
|
+
const defaultTemplateField = "template";
|
|
5
|
+
function browserProps(props) {
|
|
6
|
+
const kept = { ...props };
|
|
7
|
+
const omitted = [];
|
|
8
|
+
for (const name of ["avatar", "image"]) {
|
|
9
|
+
const value = kept[name];
|
|
10
|
+
if (typeof value === "string" && !value.startsWith("data:")) {
|
|
11
|
+
delete kept[name];
|
|
12
|
+
omitted.push(`frontmatter.${name}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return { props: kept, omitted };
|
|
16
|
+
}
|
|
17
|
+
/** Put the effective props under the frontmatter names this config reads. */
|
|
18
|
+
function declaredProps(props, config) {
|
|
19
|
+
const templateField = config?.content?.templateField ?? defaultTemplateField;
|
|
20
|
+
const { template, ...rest } = props;
|
|
21
|
+
return { [templateField]: template, ...rest };
|
|
22
|
+
}
|
|
23
|
+
/** A generic post for a project where no content file could be found. */
|
|
24
|
+
export function fallbackFrontmatter(config) {
|
|
25
|
+
const propsKey = config?.content?.propsKey ?? defaultPropsKey;
|
|
26
|
+
const templateField = config?.content?.templateField ?? defaultTemplateField;
|
|
27
|
+
const template = config?.content?.defaultTemplate ?? "banner";
|
|
28
|
+
return matter.stringify("", {
|
|
29
|
+
title: "Sample post",
|
|
30
|
+
[propsKey]: { [templateField]: template },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Read a post and make its mapper-produced props explicit for the playground. */
|
|
34
|
+
export async function sampleFrontmatter(file, config) {
|
|
35
|
+
const parsed = matter(await readFile(file.absolutePath, "utf8"));
|
|
36
|
+
const propsKey = config?.content?.propsKey ?? defaultPropsKey;
|
|
37
|
+
const browser = browserProps(file.props);
|
|
38
|
+
return {
|
|
39
|
+
text: matter.stringify("", {
|
|
40
|
+
...parsed.data,
|
|
41
|
+
[propsKey]: declaredProps(browser.props, config),
|
|
42
|
+
}),
|
|
43
|
+
omitted: browser.omitted,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=sample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../../src/cli/playground/sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,MAAM,MAAM,aAAa,CAAC;AAQjC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAOxC,SAAS,YAAY,CAAC,KAAqB;IAIzC,MAAM,IAAI,GAA4B,EAAE,GAAG,KAAK,EAAE,CAAC;IACnD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,IA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,MAAM,CAAC,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC;IAC9D,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE;YACzB,GAAG,MAAM,CAAC,IAAI;YACd,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACjD,CAAC;QACF,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The state understood by colophonjs.dev's playground. */
|
|
2
|
+
export interface PlaygroundState {
|
|
3
|
+
readonly config: string;
|
|
4
|
+
readonly frontmatter: string;
|
|
5
|
+
readonly size?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Build the public playground URL for one config and post. */
|
|
8
|
+
export declare function shareUrl(state: PlaygroundState): string;
|
|
9
|
+
//# sourceMappingURL=share.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../src/cli/playground/share.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAOvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { deflateRawSync } from "node:zlib";
|
|
2
|
+
const playground = "https://colophonjs.dev/playground/";
|
|
3
|
+
/** Build the public playground URL for one config and post. */
|
|
4
|
+
export function shareUrl(state) {
|
|
5
|
+
const json = JSON.stringify(state);
|
|
6
|
+
const encoded = deflateRawSync(json).toString("base64url");
|
|
7
|
+
const url = new URL(playground);
|
|
8
|
+
url.searchParams.set("s", encoded);
|
|
9
|
+
return url.href;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=share.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../src/cli/playground/share.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAS3C,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,+DAA+D;AAC/D,MAAM,UAAU,QAAQ,CAAC,KAAsB;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAChC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAEnC,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC"}
|
package/dist/generate/index.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ export type { GeneratedImage, GenerateOptions } from "./options.js";
|
|
|
13
13
|
* everything. Sizes with no image to render are never rasterised.
|
|
14
14
|
*
|
|
15
15
|
* Rendering runs `concurrency` images at a time rather than all of them, so a
|
|
16
|
-
* large tree does not start hundreds of rasterisations at once.
|
|
16
|
+
* large tree does not start hundreds of rasterisations at once. How many of
|
|
17
|
+
* those make progress at a time is the libuv thread pool's business, and a
|
|
18
|
+
* build asking for more than the pool has says so in a warning. See
|
|
19
|
+
* {@link GenerateOptions.concurrency}.
|
|
17
20
|
*
|
|
18
21
|
* `dryRun` stops short of writing: the plan is built and the stamps are read,
|
|
19
22
|
* so the results say which images are out of date, but nothing is rendered and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,EAAE,CAAC,CAgC3B"}
|
package/dist/generate/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { readImageStamp } from "../stamp/index.js";
|
|
|
4
4
|
import { resolveConcurrency } from "./options.js";
|
|
5
5
|
import { planBuild } from "./plan.js";
|
|
6
6
|
import { renderImage } from "./render-image.js";
|
|
7
|
+
import { warnIfPoolIsSmaller } from "./thread-pool.js";
|
|
7
8
|
export { defaultOutputPath } from "./output-path.js";
|
|
8
9
|
/**
|
|
9
10
|
* Walk a content tree and render meta images for every file that declares
|
|
@@ -17,7 +18,10 @@ export { defaultOutputPath } from "./output-path.js";
|
|
|
17
18
|
* everything. Sizes with no image to render are never rasterised.
|
|
18
19
|
*
|
|
19
20
|
* Rendering runs `concurrency` images at a time rather than all of them, so a
|
|
20
|
-
* large tree does not start hundreds of rasterisations at once.
|
|
21
|
+
* large tree does not start hundreds of rasterisations at once. How many of
|
|
22
|
+
* those make progress at a time is the libuv thread pool's business, and a
|
|
23
|
+
* build asking for more than the pool has says so in a warning. See
|
|
24
|
+
* {@link GenerateOptions.concurrency}.
|
|
21
25
|
*
|
|
22
26
|
* `dryRun` stops short of writing: the plan is built and the stamps are read,
|
|
23
27
|
* so the results say which images are out of date, but nothing is rendered and
|
|
@@ -26,6 +30,7 @@ export { defaultOutputPath } from "./output-path.js";
|
|
|
26
30
|
export async function generate(options) {
|
|
27
31
|
const concurrency = resolveConcurrency(options.concurrency);
|
|
28
32
|
const plan = await planBuild(options);
|
|
33
|
+
warnIfPoolIsSmaller(concurrency, plan.config.onWarning);
|
|
29
34
|
const results = await mapConcurrent(plan.jobs, concurrency, async (job) => {
|
|
30
35
|
const isSkipped = options.overwrite !== true &&
|
|
31
36
|
(await readImageStamp(job.outputPath)) === job.stamp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE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}
|
|
@@ -51,6 +51,14 @@ export interface GenerateOptions {
|
|
|
51
51
|
/**
|
|
52
52
|
* How many images to render at once. Defaults to the number of CPUs the
|
|
53
53
|
* process can use. Must be a positive integer.
|
|
54
|
+
*
|
|
55
|
+
* The parts of a render that take real time (the rasteriser, the PNG
|
|
56
|
+
* recompression and the quantiser) all run on the libuv thread pool. That
|
|
57
|
+
* pool has four threads unless `UV_THREADPOOL_SIZE` says otherwise, so on a
|
|
58
|
+
* machine with more cores than that a higher concurrency only queues work
|
|
59
|
+
* up. libuv sizes the pool from the environment before the process starts,
|
|
60
|
+
* and a build can only read it. Where the pool is the smaller of the two,
|
|
61
|
+
* `generate` warns.
|
|
54
62
|
*/
|
|
55
63
|
readonly concurrency?: number;
|
|
56
64
|
/** Called after each image is written or skipped. */
|
|
@@ -61,6 +69,12 @@ export interface GenerateOptions {
|
|
|
61
69
|
* the process can actually use. Rasterising is CPU-bound, so starting more
|
|
62
70
|
* than that only queues the work up while holding every pending image in
|
|
63
71
|
* memory.
|
|
72
|
+
*
|
|
73
|
+
* The real ceiling is the smaller of this and the libuv thread pool. That
|
|
74
|
+
* pool holds four threads unless `UV_THREADPOOL_SIZE` was set in the
|
|
75
|
+
* environment, so the default here is reached on a machine of four cores or
|
|
76
|
+
* fewer, or with the pool sized to match. `generate` warns where the two
|
|
77
|
+
* disagree.
|
|
64
78
|
*/
|
|
65
79
|
export declare function resolveConcurrency(concurrency: number | undefined): number;
|
|
66
80
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/generate/options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,QAA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AAS,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACzC,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAY1E"}
|
package/dist/generate/options.js
CHANGED
|
@@ -4,6 +4,12 @@ import { availableParallelism } from "node:os";
|
|
|
4
4
|
* the process can actually use. Rasterising is CPU-bound, so starting more
|
|
5
5
|
* than that only queues the work up while holding every pending image in
|
|
6
6
|
* memory.
|
|
7
|
+
*
|
|
8
|
+
* The real ceiling is the smaller of this and the libuv thread pool. That
|
|
9
|
+
* pool holds four threads unless `UV_THREADPOOL_SIZE` was set in the
|
|
10
|
+
* environment, so the default here is reached on a machine of four cores or
|
|
11
|
+
* fewer, or with the pool sized to match. `generate` warns where the two
|
|
12
|
+
* disagree.
|
|
7
13
|
*/
|
|
8
14
|
export function resolveConcurrency(concurrency) {
|
|
9
15
|
if (concurrency === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/generate/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/generate/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAuE/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA+B;IAChE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,CAAC,WAAW,CAAC,gCAAgC,CAC3E,CAAC;IACJ,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/generate/plan.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PlannedManifest } from "../manifest/index.js";
|
|
2
2
|
import type { Stamper } from "../stamp/index.js";
|
|
3
|
+
import type { ResolvedConfig } from "../types.js";
|
|
3
4
|
import type { RenderJob } from "./job.js";
|
|
4
5
|
import type { GenerateOptions } from "./options.js";
|
|
5
6
|
/**
|
|
@@ -9,6 +10,13 @@ import type { GenerateOptions } from "./options.js";
|
|
|
9
10
|
export interface BuildPlan {
|
|
10
11
|
readonly jobs: readonly RenderJob[];
|
|
11
12
|
readonly stamper: Stamper;
|
|
13
|
+
/**
|
|
14
|
+
* The build's own config, before any per-size overrides. Where a build has
|
|
15
|
+
* something to say about the run as a whole, this is where its `onWarning`
|
|
16
|
+
* comes from. The per-image handler lives on each job, and a tree with no
|
|
17
|
+
* images to render has no job to take one from.
|
|
18
|
+
*/
|
|
19
|
+
readonly config: ResolvedConfig;
|
|
12
20
|
/** What to write down about the build, where a config asked for it. */
|
|
13
21
|
readonly manifest: PlannedManifest | undefined;
|
|
14
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/generate/plan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/generate/plan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,CAAC;CAChD;AAqBD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAoD5E"}
|
package/dist/generate/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/generate/plan.ts"],"names":[],"mappings":"AAAA,OAAO,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AC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI;YACJ,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,KAAK;YACL,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ;SAChD,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACvE,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC3B,0BAA0B,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,GAAG;QACT,OAAO;QACP,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WarningHandler } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* How many threads this process's libuv pool has.
|
|
4
|
+
*
|
|
5
|
+
* The pool is sized once from the environment, the first time anything asks it
|
|
6
|
+
* to do work. A `process.env.UV_THREADPOOL_SIZE` written from inside the
|
|
7
|
+
* process arrives after that moment and changes nothing. This function only
|
|
8
|
+
* reads.
|
|
9
|
+
*
|
|
10
|
+
* libuv reads the setting with `atoi` and treats a zero as unset, and an
|
|
11
|
+
* unparseable value gives it a zero. Anything short of a positive integer
|
|
12
|
+
* therefore reads back here as the default.
|
|
13
|
+
*/
|
|
14
|
+
export declare function threadPoolSize(setting?: string | undefined): number;
|
|
15
|
+
/**
|
|
16
|
+
* A warner that says the concurrency a build asked for is above what the
|
|
17
|
+
* thread pool can serve, and says it once.
|
|
18
|
+
*
|
|
19
|
+
* Once, because the ceiling belongs to the process. A watch rebuilding on
|
|
20
|
+
* every content change would otherwise repeat the same line all day, and no
|
|
21
|
+
* build can act on it while it runs. The state lives in the returned function,
|
|
22
|
+
* so a test can hold one of its own and the shared warner stays shared.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createThreadPoolWarner(): (concurrency: number, onWarning: WarningHandler, poolSize?: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Tell a build that its concurrency is capped by the thread pool. One warner
|
|
27
|
+
* for the process, so every build in it shares the one warning.
|
|
28
|
+
*/
|
|
29
|
+
export declare const warnIfPoolIsSmaller: (concurrency: number, onWarning: WarningHandler, poolSize?: number) => void;
|
|
30
|
+
//# sourceMappingURL=thread-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-pool.d.ts","sourceRoot":"","sources":["../../src/generate/thread-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASlD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAM,GAAG,SAA6C,GAC9D,MAAM,CAQR;AAcD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,cAAc,EACzB,QAAQ,CAAC,EAAE,MAAM,KACd,IAAI,CAWR;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gBApBjB,MAAM,aACR,cAAc,aACd,MAAM,KACd,IAiBsD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many threads libuv starts when `UV_THREADPOOL_SIZE` says nothing, and
|
|
3
|
+
* the largest pool it will build however big the setting is.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_POOL_SIZE = 4;
|
|
6
|
+
const MAX_POOL_SIZE = 1024;
|
|
7
|
+
/**
|
|
8
|
+
* How many threads this process's libuv pool has.
|
|
9
|
+
*
|
|
10
|
+
* The pool is sized once from the environment, the first time anything asks it
|
|
11
|
+
* to do work. A `process.env.UV_THREADPOOL_SIZE` written from inside the
|
|
12
|
+
* process arrives after that moment and changes nothing. This function only
|
|
13
|
+
* reads.
|
|
14
|
+
*
|
|
15
|
+
* libuv reads the setting with `atoi` and treats a zero as unset, and an
|
|
16
|
+
* unparseable value gives it a zero. Anything short of a positive integer
|
|
17
|
+
* therefore reads back here as the default.
|
|
18
|
+
*/
|
|
19
|
+
export function threadPoolSize(setting = process.env["UV_THREADPOOL_SIZE"]) {
|
|
20
|
+
const parsed = Number(setting);
|
|
21
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
22
|
+
return DEFAULT_POOL_SIZE;
|
|
23
|
+
}
|
|
24
|
+
return Math.min(parsed, MAX_POOL_SIZE);
|
|
25
|
+
}
|
|
26
|
+
/** What to say about a concurrency the pool is too small to serve. */
|
|
27
|
+
function message(concurrency, poolSize) {
|
|
28
|
+
return (`Rendering ${String(concurrency)} images at once, but the libuv thread` +
|
|
29
|
+
` pool has ${String(poolSize)} threads. Rasterising, PNG recompression` +
|
|
30
|
+
` and quantising all run on that pool, so only ${String(poolSize)}` +
|
|
31
|
+
" renders make progress at a time. Set" +
|
|
32
|
+
` UV_THREADPOOL_SIZE=${String(concurrency)} in the environment before the` +
|
|
33
|
+
" process starts to lift the ceiling.");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A warner that says the concurrency a build asked for is above what the
|
|
37
|
+
* thread pool can serve, and says it once.
|
|
38
|
+
*
|
|
39
|
+
* Once, because the ceiling belongs to the process. A watch rebuilding on
|
|
40
|
+
* every content change would otherwise repeat the same line all day, and no
|
|
41
|
+
* build can act on it while it runs. The state lives in the returned function,
|
|
42
|
+
* so a test can hold one of its own and the shared warner stays shared.
|
|
43
|
+
*/
|
|
44
|
+
export function createThreadPoolWarner() {
|
|
45
|
+
let hasWarned = false;
|
|
46
|
+
return (concurrency, onWarning, poolSize = threadPoolSize()) => {
|
|
47
|
+
if (hasWarned || concurrency <= poolSize) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
hasWarned = true;
|
|
51
|
+
onWarning(message(concurrency, poolSize));
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tell a build that its concurrency is capped by the thread pool. One warner
|
|
56
|
+
* for the process, so every build in it shares the one warning.
|
|
57
|
+
*/
|
|
58
|
+
export const warnIfPoolIsSmaller = createThreadPoolWarner();
|
|
59
|
+
//# sourceMappingURL=thread-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-pool.js","sourceRoot":"","sources":["../../src/generate/thread-pool.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAO,GAAuB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAE/D,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACzC,CAAC;AAED,sEAAsE;AACtE,SAAS,OAAO,CAAC,WAAmB,EAAE,QAAgB;IACpD,OAAO,CACL,aAAa,MAAM,CAAC,WAAW,CAAC,uCAAuC;QACvE,aAAa,MAAM,CAAC,QAAQ,CAAC,0CAA0C;QACvE,iDAAiD,MAAM,CAAC,QAAQ,CAAC,EAAE;QACnE,uCAAuC;QACvC,uBAAuB,MAAM,CAAC,WAAW,CAAC,gCAAgC;QAC1E,sCAAsC,CACvC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB;IAKpC,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,GAAG,cAAc,EAAE,EAAE,EAAE;QAC7D,IAAI,SAAS,IAAI,WAAW,IAAI,QAAQ,EAAE,CAAC;YACzC,OAAO;QACT,CAAC;QAED,SAAS,GAAG,IAAI,CAAC;QACjB,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"repository": "https://github.com/KensioSoftware/colophon",
|
|
6
6
|
"homepage": "https://github.com/KensioSoftware/colophon#readme",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
-
"version": "2.15.
|
|
8
|
+
"version": "2.15.5",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
96
96
|
"dejavu-fonts-ttf": "^2.37.3",
|
|
97
97
|
"fta-cli": "^3.0.0",
|
|
98
|
-
"oxfmt": "^0.
|
|
98
|
+
"oxfmt": "^0.65.0",
|
|
99
99
|
"oxlint": "^1.77.0",
|
|
100
100
|
"oxlint-tsgolint": "^7.0.2001",
|
|
101
101
|
"semantic-release": "25.0.9",
|