elegance-js 2.1.15 → 2.1.17

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/dist/build.d.ts CHANGED
@@ -1,26 +1,2 @@
1
- type CompilationOptions = {
2
- postCompile?: () => any;
3
- preCompile?: () => any;
4
- environment: "production" | "development";
5
- pagesDirectory: string;
6
- outputDirectory: string;
7
- /** Suppress native elegance logs. */
8
- quiet?: boolean;
9
- publicDirectory?: {
10
- path: string;
11
- };
12
- server?: {
13
- runServer: boolean;
14
- root?: string;
15
- port?: number;
16
- host?: string;
17
- };
18
- hotReload?: {
19
- port: number;
20
- hostname: string;
21
- /** Directories to watch for hot-reloading other than just the pagesDirectory. */
22
- extraWatchDirectories?: string[];
23
- };
24
- };
1
+ import { CompilationOptions } from "./compilation/compilation";
25
2
  export declare const compile: (props: CompilationOptions) => Promise<void>;
26
- export {};
package/dist/build.mjs CHANGED
@@ -5,7 +5,7 @@ import child_process from "node:child_process";
5
5
  import http from "http";
6
6
  import { startServer } from "./server/server";
7
7
  import { log, setQuiet } from "./log";
8
- import { populateServerMaps } from "./compilation/dynamic_compiler";
8
+ import { populateServerMaps, setCompilationOptions } from "./compilation/compilation";
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = path.dirname(__filename);
11
11
  const packageDir = path.resolve(__dirname, "..");
@@ -95,6 +95,7 @@ const runBuild = (filepath, DIST_DIR) => {
95
95
  };
96
96
  const build = (DIST_DIR) => {
97
97
  runBuild(builderPath, DIST_DIR);
98
+ setCompilationOptions(options, DIST_DIR);
98
99
  };
99
100
  let isTimedOut = false;
100
101
  const currentWatchers = [];
@@ -6,6 +6,8 @@ type CompilationOptions = {
6
6
  environment: "production" | "development";
7
7
  pagesDirectory: string;
8
8
  outputDirectory: string;
9
+ /** Suppress native elegance logs. */
10
+ quiet?: boolean;
9
11
  publicDirectory?: {
10
12
  path: string;
11
13
  };
@@ -18,11 +20,14 @@ type CompilationOptions = {
18
20
  hotReload?: {
19
21
  port: number;
20
22
  hostname: string;
23
+ /** Directories to watch for hot-reloading other than just the pagesDirectory. */
24
+ extraWatchDirectories?: string[];
21
25
  };
22
- quiet: boolean;
23
26
  };
24
- declare const PAGE_MAP: Map<string, PageInformation>;
25
- declare const LAYOUT_MAP: Map<string, LayoutInformation>;
27
+ declare let PAGE_MAP: Map<string, PageInformation>;
28
+ declare let LAYOUT_MAP: Map<string, LayoutInformation>;
29
+ /** The parent process calls this in order to set the LAYOUT_MAP and PAGE_MAP to the ones that that compiler process ended up with. */
30
+ declare function populateServerMaps(pageMap: Map<any, any>, layoutMap: Map<any, any>): void;
26
31
  /** A list of modules that are yet to be built. */
27
32
  declare let modulesToShip: Array<{
28
33
  path: string;
@@ -131,4 +136,4 @@ declare function retrievePageAndLayoutMaps(): {
131
136
  LAYOUT_MAP: Map<string, LayoutInformation>;
132
137
  PAGE_MAP: Map<string, PageInformation>;
133
138
  };
134
- export { CompilationOptions, setCompilationOptions, getAllSubdirectories, retrievePageAndLayoutMaps, buildClient, processPageElements, pageToHTML, generateClientPageData, generateLayout, buildLayouts, buildLayout, fetchPageLayoutHTML, buildPages, buildPage, shipModules, PAGE_MAP, LAYOUT_MAP, modulesToShip, };
139
+ export { CompilationOptions, setCompilationOptions, getAllSubdirectories, retrievePageAndLayoutMaps, buildClient, processPageElements, pageToHTML, generateClientPageData, generateLayout, buildLayouts, buildLayout, fetchPageLayoutHTML, buildPages, buildPage, shipModules, PAGE_MAP, LAYOUT_MAP, populateServerMaps, modulesToShip, };
@@ -11,8 +11,12 @@ import { getState, initializeState, initializeObjectAttributes, getObjectAttribu
11
11
  import { getLoadHooks, resetLoadHooks } from "../server/loadHook";
12
12
  import { resetLayouts } from "../server/layout";
13
13
  import { renderRecursively } from "../server/render";
14
- const PAGE_MAP = /* @__PURE__ */ new Map();
15
- const LAYOUT_MAP = /* @__PURE__ */ new Map();
14
+ let PAGE_MAP = /* @__PURE__ */ new Map();
15
+ let LAYOUT_MAP = /* @__PURE__ */ new Map();
16
+ function populateServerMaps(pageMap, layoutMap) {
17
+ LAYOUT_MAP = layoutMap;
18
+ PAGE_MAP = pageMap;
19
+ }
16
20
  let options;
17
21
  let DIST_DIR;
18
22
  let elementKey = 0;
@@ -730,6 +734,7 @@ export {
730
734
  getAllSubdirectories,
731
735
  modulesToShip,
732
736
  pageToHTML,
737
+ populateServerMaps,
733
738
  processPageElements,
734
739
  retrievePageAndLayoutMaps,
735
740
  setCompilationOptions,
@@ -1,6 +1,4 @@
1
1
  import { IncomingMessage, ServerResponse } from "http";
2
- /** Populate layout and page map for the server, so it knows what pages exist within the project. */
3
- declare function populateServerMaps(pageMap: Map<any, any>, layoutMap: Map<any, any>): void;
4
2
  /** Render a page that has been deemed dynamic. */
5
3
  declare function buildDynamicPage(DIST_DIR: string, directory: string, pageInfo: PageInformation, req: IncomingMessage, res: ServerResponse, middlewareData: MiddlewareData): Promise<false | {
6
4
  resultHTML: any;
@@ -8,5 +6,5 @@ declare function buildDynamicPage(DIST_DIR: string, directory: string, pageInfo:
8
6
  /** Check if a given pathname was found during the original compilation process. */
9
7
  declare function doesPageExist(pathname: string): boolean;
10
8
  /** Retrieve a given pathname from the page map. */
11
- declare function getPage(pathname: string): any;
12
- export { populateServerMaps, doesPageExist, getPage, buildDynamicPage, };
9
+ declare function getPage(pathname: string): PageInformation | undefined;
10
+ export { doesPageExist, getPage, buildDynamicPage, };
@@ -1,13 +1,7 @@
1
1
  import { initializeObjectAttributes, initializeState } from "../server/state";
2
2
  import { resetLoadHooks } from "../server/loadHook";
3
- import { fetchPageLayoutHTML, pageToHTML, shipModules, modulesToShip } from "./compilation";
3
+ import { fetchPageLayoutHTML, pageToHTML, shipModules, modulesToShip, PAGE_MAP } from "./compilation";
4
4
  import path from "path";
5
- let LAYOUT_MAP = /* @__PURE__ */ new Map();
6
- let PAGE_MAP = /* @__PURE__ */ new Map();
7
- function populateServerMaps(pageMap, layoutMap) {
8
- LAYOUT_MAP = layoutMap;
9
- PAGE_MAP = pageMap;
10
- }
11
5
  async function buildDynamicPage(DIST_DIR, directory, pageInfo, req, res, middlewareData) {
12
6
  directory = directory === "/" ? "" : directory;
13
7
  const filePath = pageInfo.filePath;
@@ -95,6 +89,5 @@ function getPage(pathname) {
95
89
  export {
96
90
  buildDynamicPage,
97
91
  doesPageExist,
98
- getPage,
99
- populateServerMaps
92
+ getPage
100
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "2.1.15",
3
+ "version": "2.1.17",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {