@taujs/server 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taujs/server",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "τjs [ taujs ]",
5
5
  "author": "John Smith | Aoede <taujs@aoede.uk.net> (https://www.aoede.uk.net)",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "path-to-regexp": "^8.1.0",
48
- "vite-plugin-node-polyfills": "^0.23.0"
48
+ "vite-plugin-node-polyfills": "^0.24.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@arethetypeswrong/cli": "^0.15.4",
package/dist/Build.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import { A as AppConfig } from './Config-CjwAJCfZ.js';
2
- import 'fastify';
3
- import 'vite';
4
-
5
- /**
6
- * τjs [ taujs ] Orchestration System
7
- * (c) 2024-present Aoede Ltd
8
- * Author: John Smith
9
- *
10
- * Licensed under the MIT License - attribution appreciated.
11
- * Part of the τjs [ taujs ] system for declarative, build-time orchestration of microfrontend applications,
12
- * including CSR, SSR, streaming, and middleware composition.
13
- */
14
-
15
- declare function taujsBuild({ configs, projectRoot, clientBaseDir, isSSRBuild, }: {
16
- configs: AppConfig[];
17
- projectRoot: string;
18
- clientBaseDir: string;
19
- isSSRBuild?: boolean;
20
- }): Promise<void>;
21
-
22
- export { taujsBuild };
package/dist/Build.js DELETED
@@ -1,228 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // node_modules/picocolors/picocolors.js
28
- var require_picocolors = __commonJS({
29
- "node_modules/picocolors/picocolors.js"(exports, module) {
30
- "use strict";
31
- var p = process || {};
32
- var argv = p.argv || [];
33
- var env = p.env || {};
34
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
35
- var formatter = (open, close, replace = open) => (input) => {
36
- let string = "" + input, index = string.indexOf(close, open.length);
37
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
38
- };
39
- var replaceClose = (string, close, replace, index) => {
40
- let result = "", cursor = 0;
41
- do {
42
- result += string.substring(cursor, index) + replace;
43
- cursor = index + close.length;
44
- index = string.indexOf(close, cursor);
45
- } while (~index);
46
- return result + string.substring(cursor);
47
- };
48
- var createColors = (enabled = isColorSupported) => {
49
- let f = enabled ? formatter : () => String;
50
- return {
51
- isColorSupported: enabled,
52
- reset: f("\x1B[0m", "\x1B[0m"),
53
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
54
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
55
- italic: f("\x1B[3m", "\x1B[23m"),
56
- underline: f("\x1B[4m", "\x1B[24m"),
57
- inverse: f("\x1B[7m", "\x1B[27m"),
58
- hidden: f("\x1B[8m", "\x1B[28m"),
59
- strikethrough: f("\x1B[9m", "\x1B[29m"),
60
- black: f("\x1B[30m", "\x1B[39m"),
61
- red: f("\x1B[31m", "\x1B[39m"),
62
- green: f("\x1B[32m", "\x1B[39m"),
63
- yellow: f("\x1B[33m", "\x1B[39m"),
64
- blue: f("\x1B[34m", "\x1B[39m"),
65
- magenta: f("\x1B[35m", "\x1B[39m"),
66
- cyan: f("\x1B[36m", "\x1B[39m"),
67
- white: f("\x1B[37m", "\x1B[39m"),
68
- gray: f("\x1B[90m", "\x1B[39m"),
69
- bgBlack: f("\x1B[40m", "\x1B[49m"),
70
- bgRed: f("\x1B[41m", "\x1B[49m"),
71
- bgGreen: f("\x1B[42m", "\x1B[49m"),
72
- bgYellow: f("\x1B[43m", "\x1B[49m"),
73
- bgBlue: f("\x1B[44m", "\x1B[49m"),
74
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
75
- bgCyan: f("\x1B[46m", "\x1B[49m"),
76
- bgWhite: f("\x1B[47m", "\x1B[49m"),
77
- blackBright: f("\x1B[90m", "\x1B[39m"),
78
- redBright: f("\x1B[91m", "\x1B[39m"),
79
- greenBright: f("\x1B[92m", "\x1B[39m"),
80
- yellowBright: f("\x1B[93m", "\x1B[39m"),
81
- blueBright: f("\x1B[94m", "\x1B[39m"),
82
- magentaBright: f("\x1B[95m", "\x1B[39m"),
83
- cyanBright: f("\x1B[96m", "\x1B[39m"),
84
- whiteBright: f("\x1B[97m", "\x1B[39m"),
85
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
86
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
87
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
88
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
89
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
90
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
91
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
92
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
93
- };
94
- };
95
- module.exports = createColors();
96
- module.exports.createColors = createColors;
97
- }
98
- });
99
-
100
- // src/Build.ts
101
- import path3 from "path";
102
- import { build } from "vite";
103
- import { nodePolyfills } from "vite-plugin-node-polyfills";
104
-
105
- // src/utils/AssetManager.ts
106
- import path2 from "path";
107
-
108
- // src/utils/System.ts
109
- import { dirname, join } from "path";
110
- import "path";
111
- import { fileURLToPath } from "url";
112
- var isDevelopment = process.env.NODE_ENV === "development";
113
- var __filename = fileURLToPath(import.meta.url);
114
- var __dirname = join(dirname(__filename), !isDevelopment ? "./" : "..");
115
-
116
- // src/constants.ts
117
- var import_picocolors = __toESM(require_picocolors(), 1);
118
- var TEMPLATE = {
119
- defaultEntryClient: "entry-client",
120
- defaultEntryServer: "entry-server",
121
- defaultHtmlTemplate: "index.html"
122
- };
123
- var DEBUG = {
124
- auth: { label: "auth", colour: import_picocolors.default.blue },
125
- csp: { label: "csp", colour: import_picocolors.default.yellow },
126
- errors: { label: "errors", colour: import_picocolors.default.red },
127
- routes: { label: "routes", colour: import_picocolors.default.cyan },
128
- security: { label: "security", colour: import_picocolors.default.yellow },
129
- trx: { label: "trx", colour: import_picocolors.default.magenta },
130
- vite: { label: "vite", colour: import_picocolors.default.yellow }
131
- };
132
-
133
- // src/utils/AssetManager.ts
134
- var processConfigs = (configs, baseClientRoot, templateDefaults) => {
135
- return configs.map((config) => {
136
- const clientRoot = path2.resolve(baseClientRoot, config.entryPoint);
137
- return {
138
- clientRoot,
139
- entryPoint: config.entryPoint,
140
- entryClient: config.entryClient || templateDefaults.defaultEntryClient,
141
- entryServer: config.entryServer || templateDefaults.defaultEntryServer,
142
- htmlTemplate: config.htmlTemplate || templateDefaults.defaultHtmlTemplate,
143
- appId: config.appId
144
- };
145
- });
146
- };
147
-
148
- // src/Build.ts
149
- async function taujsBuild({
150
- configs,
151
- projectRoot,
152
- clientBaseDir,
153
- isSSRBuild = process.env.BUILD_MODE === "ssr"
154
- }) {
155
- const deleteDist = async () => {
156
- const { rm } = await import("fs/promises");
157
- const distPath = path3.resolve(projectRoot, "dist");
158
- try {
159
- await rm(distPath, { recursive: true, force: true });
160
- console.log("Deleted the dist directory\n");
161
- } catch (err) {
162
- console.error("Error deleting dist directory:", err);
163
- }
164
- };
165
- const processedConfigs = processConfigs(configs, clientBaseDir, TEMPLATE);
166
- if (!isSSRBuild) await deleteDist();
167
- for (const config of processedConfigs) {
168
- const { appId, entryPoint, clientRoot, entryClient, entryServer, htmlTemplate, plugins = [] } = config;
169
- const outDir = path3.resolve(projectRoot, `dist/client/${entryPoint}`);
170
- const root = entryPoint ? path3.resolve(clientBaseDir, entryPoint) : clientBaseDir;
171
- const server = path3.resolve(clientRoot, `${entryServer}.tsx`);
172
- const client = path3.resolve(clientRoot, `${entryClient}.tsx`);
173
- const main = path3.resolve(clientRoot, htmlTemplate);
174
- const viteConfig = {
175
- base: entryPoint ? `/${entryPoint}/` : "/",
176
- build: {
177
- outDir,
178
- manifest: !isSSRBuild,
179
- rollupOptions: {
180
- input: isSSRBuild ? { server } : { client, main }
181
- },
182
- ssr: isSSRBuild ? server : void 0,
183
- ssrManifest: isSSRBuild,
184
- ...isSSRBuild && {
185
- format: "esm",
186
- target: `node${process.versions.node.split(".").map(Number)[0]}`
187
- }
188
- },
189
- css: {
190
- preprocessorOptions: {
191
- scss: { api: "modern-compiler" }
192
- }
193
- },
194
- plugins: [...config.plugins ?? [], nodePolyfills({ include: ["fs", "stream"] })],
195
- publicDir: "public",
196
- resolve: {
197
- alias: {
198
- "@client": root,
199
- "@server": path3.resolve(projectRoot, "src/server"),
200
- "@shared": path3.resolve(projectRoot, "src/shared")
201
- }
202
- },
203
- root,
204
- server: {
205
- proxy: {
206
- "/api": {
207
- target: "http://localhost:3000",
208
- changeOrigin: true,
209
- rewrite: (path4) => path4.replace(/^\/api/, "")
210
- }
211
- }
212
- }
213
- };
214
- try {
215
- console.log(`Building for entryPoint: "${entryPoint}" (${appId})`);
216
- await build(viteConfig);
217
- console.log(`Build complete for entryPoint: "${entryPoint}"
218
- `);
219
- } catch (error) {
220
- console.error(`Error building for entryPoint: "${entryPoint}"
221
- `, error);
222
- process.exit(1);
223
- }
224
- }
225
- }
226
- export {
227
- taujsBuild
228
- };
package/dist/types.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import 'fastify';
2
- import 'vite';
3
- export { h as BaseMiddleware, C as Config, k as DataHandler, j as DataResult, G as GenericPlugin, I as InitialRouteParams, d as Manifest, M as ManifestEntry, l as PathToRegExpParams, P as ProcessedConfig, b as RenderCallbacks, g as RenderModule, e as RenderSSR, f as RenderStream, n as Route, m as RouteAttributes, R as RouteCSPConfig, o as RoutePathsAndAttributes, c as SSRManifest, S as SSRServerOptions, i as ServiceCall } from './Config-CjwAJCfZ.js';
package/dist/types.js DELETED
File without changes