@lumeland/core 1.0.0-beta-10 → 1.0.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/CHANGELOG.md +1 -1
- package/build/deps/path.js +0 -7
- package/build/src/components.d.ts +2 -0
- package/build/src/components.js +11 -0
- package/build/src/site.d.ts +10 -5
- package/build/src/site.js +18 -9
- package/build/src/utils/read.js +0 -7
- package/package.json +1 -3
- package/build/deps/cli.d.ts +0 -1
- package/build/deps/cli.js +0 -1
- package/build/deps/module.d.ts +0 -1
- package/build/deps/module.js +0 -1
- package/build/src/utils/lume-config.d.ts +0 -4
- package/build/src/utils/lume-config.js +0 -105
- package/build/src/utils/tokens.d.ts +0 -2
- package/build/src/utils/tokens.js +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,6 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
-
## 1.0.0 -
|
|
8
|
+
## 1.0.0 - 2026-10-30
|
|
9
9
|
|
|
10
10
|
First version
|
package/build/deps/path.js
CHANGED
|
@@ -2,10 +2,3 @@ export { posix, sep as SEPARATOR } from "node:path";
|
|
|
2
2
|
export { basename, dirname, extname, join, relative } from "node:path";
|
|
3
3
|
export { globToRegExp } from "deno-std/path/glob-to-regexp.js";
|
|
4
4
|
export { fileURLToPath as fromFileUrl, pathToFileURL as toFileUrl } from "node:url";
|
|
5
|
-
// posix.dirname
|
|
6
|
-
// posix.join
|
|
7
|
-
// posix.basename
|
|
8
|
-
// posix.extname
|
|
9
|
-
// posix.normalize
|
|
10
|
-
// posix.relative
|
|
11
|
-
// posix.resolve
|
|
@@ -57,3 +57,5 @@ export interface ProxyComponents {
|
|
|
57
57
|
* as comp.name() instead of components.get("name").render()
|
|
58
58
|
*/
|
|
59
59
|
export declare function toProxy(components: Components, extraCode: Map<string, string | Entry>): ProxyComponents;
|
|
60
|
+
export type ComponentsAssetsCompiler = (filename: string, imports: Map<string, string | Entry>, entries: Map<string, Entry>) => Promise<string>;
|
|
61
|
+
export declare const defaultAssetsCompiler: ComponentsAssetsCompiler;
|
package/build/src/components.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import text from "./loaders/text.js";
|
|
1
2
|
/**
|
|
2
3
|
* Class to load components from the _components folder.
|
|
3
4
|
*/
|
|
@@ -142,3 +143,13 @@ export function toProxy(components, extraCode) {
|
|
|
142
143
|
},
|
|
143
144
|
});
|
|
144
145
|
}
|
|
146
|
+
export const defaultAssetsCompiler = async (_, imports) => {
|
|
147
|
+
const content = await Promise.all(Array.from(imports).map(async ([, entry]) => {
|
|
148
|
+
if (typeof entry === "string") {
|
|
149
|
+
return entry;
|
|
150
|
+
}
|
|
151
|
+
const { content } = await entry.getContent(text);
|
|
152
|
+
return content || "";
|
|
153
|
+
}));
|
|
154
|
+
return content.join("\n");
|
|
155
|
+
};
|
package/build/src/site.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import DebugBar from "./debugbar.ts";
|
|
|
19
19
|
import type { Archetype } from "./archetypes.ts";
|
|
20
20
|
import type { Loader } from "./fs.ts";
|
|
21
21
|
import type { BasenameParser, Destination } from "./source.ts";
|
|
22
|
-
import type { Components, UserComponent } from "./components.ts";
|
|
22
|
+
import type { Components, ComponentsAssetsCompiler, UserComponent } from "./components.ts";
|
|
23
23
|
import type { Engine, Helper, HelperOptions, HelperThis } from "./renderer.ts";
|
|
24
24
|
import type { Event, EventListener, EventOptions } from "./events.ts";
|
|
25
25
|
import type { Processor } from "./processors.ts";
|
|
@@ -79,6 +79,8 @@ export default class Site {
|
|
|
79
79
|
dataLoader: DataLoader;
|
|
80
80
|
/** To load reusable components */
|
|
81
81
|
componentLoader: ComponentLoader;
|
|
82
|
+
/** To compile the components assets */
|
|
83
|
+
componentsAssetsCompilers: Map<"css" | "js", ComponentsAssetsCompiler>;
|
|
82
84
|
/** To scan the src folder */
|
|
83
85
|
source: Source;
|
|
84
86
|
/** To update pages of the same scope after any change */
|
|
@@ -213,8 +215,7 @@ export default class Site {
|
|
|
213
215
|
scopedUpdates(...scopes: ScopeFilter[]): this;
|
|
214
216
|
/** Define remote fallback files for missing local files */
|
|
215
217
|
remote(filename: string, url: string, paths?: string | string[]): this;
|
|
216
|
-
|
|
217
|
-
remoteFile(filename: string, url: string): this;
|
|
218
|
+
compileComponentsAssets(format: "css" | "js", compiler: ComponentsAssetsCompiler): this;
|
|
218
219
|
/** Clear the dest directory and any cache */
|
|
219
220
|
clear(): Promise<void>;
|
|
220
221
|
/** Build the entire site */
|
|
@@ -302,12 +303,16 @@ export interface WatcherOptions {
|
|
|
302
303
|
}
|
|
303
304
|
/** The options to configure the components */
|
|
304
305
|
export interface ComponentsOptions {
|
|
305
|
-
/** The name of the file to save the components
|
|
306
|
+
/** The name of the file to save the components CSS code */
|
|
306
307
|
cssFile?: string;
|
|
307
|
-
/** The name of the file to save the components
|
|
308
|
+
/** The name of the file to save the components JavaScript code */
|
|
308
309
|
jsFile?: string;
|
|
309
310
|
/** An optional placeholder to insert the CSS and JS code */
|
|
310
311
|
placeholder?: string;
|
|
312
|
+
/** Function to compile the different CSS files generated by components */
|
|
313
|
+
cssCompiler?: ComponentsAssetsCompiler;
|
|
314
|
+
/** Function to compile the different JavaScript files generated by components */
|
|
315
|
+
jsCompiler?: ComponentsAssetsCompiler;
|
|
311
316
|
}
|
|
312
317
|
export type SiteEventMap = {
|
|
313
318
|
afterLoad: {};
|
package/build/src/site.js
CHANGED
|
@@ -9,7 +9,7 @@ import { getFile, getFiles, isFromCdn } from "./utils/cdn.js";
|
|
|
9
9
|
import { setCache } from "./utils/read.js";
|
|
10
10
|
import Path from "./path.js";
|
|
11
11
|
import FS from "./fs.js";
|
|
12
|
-
import { ComponentLoader } from "./components.js";
|
|
12
|
+
import { ComponentLoader, defaultAssetsCompiler } from "./components.js";
|
|
13
13
|
import DataLoader from "./data-loader.js";
|
|
14
14
|
import Source from "./source.js";
|
|
15
15
|
import Scopes from "./scopes.js";
|
|
@@ -29,8 +29,6 @@ import Server from "./server.js";
|
|
|
29
29
|
import Cache from "./cache.js";
|
|
30
30
|
import DebugBar from "./debugbar.js";
|
|
31
31
|
import { cwd } from "./services/process.js";
|
|
32
|
-
import { compileComponentsCSS } from "@lumeland/plugin-lightningcss/comp.ts";
|
|
33
|
-
import { compileComponentsJS } from "@lumeland/plugin-esbuild/comp.ts";
|
|
34
32
|
/** Default options of the site */
|
|
35
33
|
const defaults = {
|
|
36
34
|
cwd: cwd(),
|
|
@@ -77,6 +75,8 @@ export default class Site {
|
|
|
77
75
|
dataLoader;
|
|
78
76
|
/** To load reusable components */
|
|
79
77
|
componentLoader;
|
|
78
|
+
/** To compile the components assets */
|
|
79
|
+
componentsAssetsCompilers = new Map();
|
|
80
80
|
/** To scan the src folder */
|
|
81
81
|
source;
|
|
82
82
|
/** To update pages of the same scope after any change */
|
|
@@ -144,6 +144,13 @@ export default class Site {
|
|
|
144
144
|
prettyUrls,
|
|
145
145
|
basenameParsers: [],
|
|
146
146
|
});
|
|
147
|
+
// Compile CSS & JS code generated by _components
|
|
148
|
+
if (components.cssCompiler) {
|
|
149
|
+
this.componentsAssetsCompilers.set("css", components.cssCompiler);
|
|
150
|
+
}
|
|
151
|
+
if (components.jsCompiler) {
|
|
152
|
+
this.componentsAssetsCompilers.set("js", components.jsCompiler);
|
|
153
|
+
}
|
|
147
154
|
// To render pages
|
|
148
155
|
const scopes = new Scopes();
|
|
149
156
|
const processors = new Processors();
|
|
@@ -458,7 +465,7 @@ export default class Site {
|
|
|
458
465
|
if (!to || to.endsWith("/")) {
|
|
459
466
|
throw new Error(`Invalid destination path: ${to}`);
|
|
460
467
|
}
|
|
461
|
-
this.
|
|
468
|
+
this.remote(to, url.href);
|
|
462
469
|
this.source.addFile(to, to, copy);
|
|
463
470
|
return;
|
|
464
471
|
}
|
|
@@ -511,9 +518,9 @@ export default class Site {
|
|
|
511
518
|
}
|
|
512
519
|
return this;
|
|
513
520
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return this
|
|
521
|
+
compileComponentsAssets(format, compiler) {
|
|
522
|
+
this.componentsAssetsCompilers.set(format, compiler);
|
|
523
|
+
return this;
|
|
517
524
|
}
|
|
518
525
|
/** Clear the dest directory and any cache */
|
|
519
526
|
async clear() {
|
|
@@ -671,7 +678,8 @@ export default class Site {
|
|
|
671
678
|
if (path.endsWith(".css")) {
|
|
672
679
|
this.debugBar?.startMeasure("components-css");
|
|
673
680
|
const page = await this.getOrCreatePage(path);
|
|
674
|
-
|
|
681
|
+
const compiler = this.componentsAssetsCompilers.get("css") ?? defaultAssetsCompiler;
|
|
682
|
+
page.text = insertContent(page.text, await compiler(path, entries, this.fs.entries), this.options.components.placeholder);
|
|
675
683
|
this.debugBar?.endMeasure("components-css", `[Components] Compiled CSS code into <code>${path}</code>`);
|
|
676
684
|
continue;
|
|
677
685
|
}
|
|
@@ -680,7 +688,8 @@ export default class Site {
|
|
|
680
688
|
// https://github.com/lumeland/lume/issues/659
|
|
681
689
|
const existingFile = this.search.file(path.replace(/.m?js$/, "{.mjs,.js,.ts}"));
|
|
682
690
|
const page = await this.getOrCreatePage(existingFile || path);
|
|
683
|
-
|
|
691
|
+
const compiler = this.componentsAssetsCompilers.get("js") ?? defaultAssetsCompiler;
|
|
692
|
+
page.text = insertContent(page.text, await compiler(path, entries, this.fs.entries), this.options.components.placeholder);
|
|
684
693
|
this.debugBar?.endMeasure("components-js", `[Components] Compiled JS code into <code>${path}</code>`);
|
|
685
694
|
}
|
|
686
695
|
}
|
package/build/src/utils/read.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isUrl } from "./path.js";
|
|
2
|
-
import { tokens } from "./tokens.js";
|
|
3
2
|
import { readFile as readFile_, readTextFile } from "../services/fs.js";
|
|
4
3
|
import { fromFileUrl } from "../../deps/path.js";
|
|
5
4
|
let cache;
|
|
@@ -19,12 +18,6 @@ export async function read(path, isBinary = false, init) {
|
|
|
19
18
|
const path = fromFileUrl(url);
|
|
20
19
|
return isBinary ? readFile_(path) : readTextFile(path);
|
|
21
20
|
}
|
|
22
|
-
const authorization = tokens.get(url.host);
|
|
23
|
-
if (authorization) {
|
|
24
|
-
const headers = new Headers(init?.headers);
|
|
25
|
-
headers.set("Authorization", authorization);
|
|
26
|
-
init = { ...init, headers };
|
|
27
|
-
}
|
|
28
21
|
const cached = isBinary ? cache?.getBytes([url]) : cache?.getText([url]);
|
|
29
22
|
if (cached) {
|
|
30
23
|
return cached;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumeland/core",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "The core of Lume SSG",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Óscar Otero",
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@lumeland/dom": "^0.1.56",
|
|
24
|
-
"@lumeland/plugin-esbuild": "^1.0.0-beta-9",
|
|
25
|
-
"@lumeland/plugin-lightningcss": "^1.0.0-beta-9",
|
|
26
24
|
"deno-std": "^1.6.0",
|
|
27
25
|
"remove-markdown": "0.8.0",
|
|
28
26
|
"temporal-polyfill": "^1.0.6",
|
package/build/deps/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseArgs } from "deno-std/cli/parse-args.js";
|
package/build/deps/cli.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseArgs } from "deno-std/cli/parse-args.js";
|
package/build/deps/module.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { registerHooks } from "node:module";
|
package/build/deps/module.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { registerHooks } from "node:module";
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { toFileUrl } from "../../deps/path.js";
|
|
2
|
-
import { realPathSync } from "../services/fs.js";
|
|
3
|
-
import { isUrl } from "./path.js";
|
|
4
|
-
/** A list of the available plugins not installed by default and sorted */
|
|
5
|
-
export const pluginNames = [
|
|
6
|
-
// Order doesn't matter, but should be first
|
|
7
|
-
"attributes",
|
|
8
|
-
"date",
|
|
9
|
-
"code_highlight",
|
|
10
|
-
"decap_cms",
|
|
11
|
-
"fff",
|
|
12
|
-
"eta",
|
|
13
|
-
"extract_date",
|
|
14
|
-
"extract_order",
|
|
15
|
-
"git_date",
|
|
16
|
-
"git_info",
|
|
17
|
-
"jsx",
|
|
18
|
-
"json_ld",
|
|
19
|
-
"reading_info",
|
|
20
|
-
"relations",
|
|
21
|
-
"lume_cms",
|
|
22
|
-
"mdx",
|
|
23
|
-
"multilanguage",
|
|
24
|
-
"nav",
|
|
25
|
-
"nunjucks",
|
|
26
|
-
"pagefind",
|
|
27
|
-
"plaintext",
|
|
28
|
-
"prism",
|
|
29
|
-
"pug",
|
|
30
|
-
"pwa",
|
|
31
|
-
"remark",
|
|
32
|
-
"robots",
|
|
33
|
-
"sheets",
|
|
34
|
-
"toc",
|
|
35
|
-
"filter_pages",
|
|
36
|
-
"redirects",
|
|
37
|
-
"icons",
|
|
38
|
-
"partytown",
|
|
39
|
-
"replace",
|
|
40
|
-
"well_known",
|
|
41
|
-
// CSS + JS + source maps
|
|
42
|
-
"esbuild",
|
|
43
|
-
"terser",
|
|
44
|
-
"katex",
|
|
45
|
-
"google_fonts",
|
|
46
|
-
"sass",
|
|
47
|
-
"unocss",
|
|
48
|
-
"tailwindcss",
|
|
49
|
-
"postcss",
|
|
50
|
-
"lightningcss",
|
|
51
|
-
"purgecss",
|
|
52
|
-
"source_maps",
|
|
53
|
-
// Modify URLs
|
|
54
|
-
"base_path",
|
|
55
|
-
"resolve_urls",
|
|
56
|
-
"relative_urls",
|
|
57
|
-
"slugify_urls",
|
|
58
|
-
"modify_urls",
|
|
59
|
-
"check_urls",
|
|
60
|
-
// Images
|
|
61
|
-
"og_images",
|
|
62
|
-
"favicon",
|
|
63
|
-
"svgo",
|
|
64
|
-
"picture",
|
|
65
|
-
"transform_images",
|
|
66
|
-
"image_size",
|
|
67
|
-
// Assets in HTML
|
|
68
|
-
"metas",
|
|
69
|
-
"inline",
|
|
70
|
-
"sri",
|
|
71
|
-
"validate_html",
|
|
72
|
-
// Generate files with URLs
|
|
73
|
-
"feed",
|
|
74
|
-
"sitemap",
|
|
75
|
-
"seo",
|
|
76
|
-
// Final minification and compression
|
|
77
|
-
"minify_html",
|
|
78
|
-
"epub",
|
|
79
|
-
"brotli",
|
|
80
|
-
"gzip",
|
|
81
|
-
];
|
|
82
|
-
/** Resolve a configuration file */
|
|
83
|
-
export function resolveConfigFile(defaultPaths, customPath) {
|
|
84
|
-
if (customPath) {
|
|
85
|
-
if (isUrl(customPath)) {
|
|
86
|
-
return new URL(customPath);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const file = realPathSync(customPath);
|
|
90
|
-
return toFileUrl(file);
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
throw new Error(`Config file not found (${customPath})`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
for (const path of defaultPaths) {
|
|
97
|
-
try {
|
|
98
|
-
const file = realPathSync(path);
|
|
99
|
-
return toFileUrl(file);
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
// Ignore
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { env } from "./env.js";
|
|
2
|
-
const tokens = new Map();
|
|
3
|
-
const denoAuthTokens = env("DENO_AUTH_TOKENS");
|
|
4
|
-
if (denoAuthTokens) {
|
|
5
|
-
const authTokens = denoAuthTokens.split(";");
|
|
6
|
-
for (const token of authTokens) {
|
|
7
|
-
const [credentials, host] = token.split("@");
|
|
8
|
-
if (credentials.includes(":")) {
|
|
9
|
-
// Basic Auth
|
|
10
|
-
const encodedCredentials = btoa(credentials);
|
|
11
|
-
tokens.set(host, `Basic ${encodedCredentials}`);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// Bearer Token
|
|
15
|
-
tokens.set(host, `Bearer ${credentials}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export { tokens };
|