@lumeland/core 1.0.0-beta-3 → 1.0.0-beta-4

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 ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/).
7
+
8
+ ## 1.0.0 - Unreleased
9
+
10
+ First version
@@ -1 +1,2 @@
1
1
  import "temporal-polyfill/global";
2
+ export declare function toBase64(input: ArrayBuffer | Uint8Array): string;
@@ -1 +1,5 @@
1
1
  import "temporal-polyfill/global";
2
+ // Uint8Array.prototype.toBase64() not available in Node 24
3
+ export function toBase64(input) {
4
+ return Buffer.from(input).toString("base64");
5
+ }
@@ -4,6 +4,8 @@ export interface NetworkInterfaceInfo {
4
4
  }
5
5
  /** Returns an array with the network interfaces information */
6
6
  export declare function networkInterfaces(): NetworkInterfaceInfo[];
7
+ /** Check if a port is free */
8
+ export declare function checkPort(port: number): Promise<boolean>;
7
9
  export interface NetAddress {
8
10
  transport: "tcp" | "udp";
9
11
  hostname: string;
@@ -15,6 +15,24 @@ export function networkInterfaces() {
15
15
  }
16
16
  return result;
17
17
  }
18
+ /** Check if a port is free */
19
+ export function checkPort(port) {
20
+ return new Promise((resolve, reject) => {
21
+ const server = createServer(() => { });
22
+ server.once("error", (error) => {
23
+ if (error.code === "EADDRINUSE") {
24
+ resolve(false);
25
+ }
26
+ else {
27
+ reject(error);
28
+ }
29
+ });
30
+ server.once("listening", () => {
31
+ server.close(() => resolve(true));
32
+ });
33
+ server.listen(port, "0.0.0.0");
34
+ });
35
+ }
18
36
  /** Start a new HTTP server */
19
37
  export function serve(options) {
20
38
  const { handler, hostname = "0.0.0.0", port = 8000, signal, onListen, onUpgradeWebSocket, } = options;
@@ -17,3 +17,5 @@ export declare function inspect(value: unknown): string;
17
17
  export declare function runPipedCommand(cmd: string, args?: string[], cwd?: string): [string | undefined, string | undefined];
18
18
  /** Run an command and return if it's success */
19
19
  export declare function runCommand(cmd: string, args?: string[], cwd?: string): Promise<boolean>;
20
+ /** Reload the process */
21
+ export declare function reloadProcess(): void;
@@ -66,3 +66,9 @@ export async function runCommand(cmd, args = [], cwd) {
66
66
  child.on("close", (code) => resolve(code === 0));
67
67
  });
68
68
  }
69
+ /** Reload the process */
70
+ export function reloadProcess() {
71
+ if (process.send) {
72
+ process.send({ type: "reload" });
73
+ }
74
+ }
package/build/src/site.js CHANGED
@@ -424,8 +424,8 @@ export default class Site {
424
424
  }
425
425
  return;
426
426
  }
427
- // Remote files from NPM or GitHub CDN
428
- if (isFromCdn(from)) {
427
+ // Remote files CDN or filesystem
428
+ if (isFromCdn(from) || from.startsWith("file:")) {
429
429
  // It's a pattern
430
430
  if (from.includes("*")) {
431
431
  const pos = from.indexOf("*");
@@ -58,16 +58,15 @@ export function getFile(specifier) {
58
58
  if (specifier.startsWith("npm:")) {
59
59
  return specifier.replace("npm:", "https://cdn.jsdelivr.net/npm/");
60
60
  }
61
- else if (specifier.startsWith("gh:")) {
61
+ if (specifier.startsWith("gh:")) {
62
62
  return specifier.replace("gh:", "https://cdn.jsdelivr.net/gh/");
63
63
  }
64
- else if (specifier.startsWith("https://cdn.jsdelivr.net/npm/") ||
64
+ if (specifier.startsWith("file://") ||
65
+ specifier.startsWith("https://cdn.jsdelivr.net/npm/") ||
65
66
  specifier.startsWith("https://cdn.jsdelivr.net/gh/")) {
66
67
  return specifier;
67
68
  }
68
- else {
69
- throw new Error(`Invalid specifier: ${specifier}`);
70
- }
69
+ throw new Error(`Invalid specifier: ${specifier}`);
71
70
  }
72
71
  export async function getVersion(type, name, version) {
73
72
  // Check if the version is a hash (commit SHA)
@@ -4,7 +4,7 @@ export declare function setCache(instance: Cache): void;
4
4
  * Read a local or remote file and return its content.
5
5
  * If the file is remote, it will be cached in the `lume_remote_files` cache.
6
6
  */
7
- export declare function read(path: string, isBinary: false, init?: RequestInit): Promise<string>;
7
+ export declare function read(path: string, isBinary?: false, init?: RequestInit): Promise<string>;
8
8
  export declare function read(path: string, isBinary: true, init?: RequestInit): Promise<Uint8Array<ArrayBuffer>>;
9
9
  /** Read a text file like a browser */
10
10
  export declare function readFile(path: string): Promise<string>;
@@ -6,7 +6,7 @@ let cache;
6
6
  export function setCache(instance) {
7
7
  cache = instance;
8
8
  }
9
- export async function read(path, isBinary, init) {
9
+ export async function read(path, isBinary = false, init) {
10
10
  if (!isUrl(path)) {
11
11
  if (path.startsWith("data:")) {
12
12
  const response = await fetch(path);
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@lumeland/core",
3
- "version": "1.0.0-beta-3",
3
+ "version": "1.0.0-beta-4",
4
4
  "description": "The core of Lume SSG",
5
5
  "license": "MIT",
6
6
  "files": [
7
- "build"
7
+ "build",
8
+ "CHANGELOG.md"
8
9
  ],
9
10
  "type": "module",
10
11
  "exports": {