xpine 0.0.26 → 0.0.28
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -111
- package/dist/src/build/esbuild/transformTSXFiles.d.ts.map +1 -1
- package/dist/src/build/typescript-builder.d.ts +7 -0
- package/dist/src/build/typescript-builder.d.ts.map +1 -1
- package/dist/src/context.d.ts +18 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/express.d.ts.map +1 -1
- package/dist/src/scripts/build.d.ts +13 -2
- package/dist/src/scripts/build.d.ts.map +1 -1
- package/dist/src/scripts/xpine-build.js +273 -111
- package/dist/src/scripts/xpine-dev.js +258 -97
- package/dist/src/util/hooks/onInit.d.ts +3 -0
- package/dist/src/util/hooks/onInit.d.ts.map +1 -0
- package/dist/src/util/paths.d.ts +2 -0
- package/dist/src/util/paths.d.ts.map +1 -0
- package/dist/src/util/require.d.ts +0 -1
- package/dist/src/util/require.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -1
- package/types.ts +3 -1
|
@@ -11,12 +11,146 @@ import chokidar from "chokidar";
|
|
|
11
11
|
import path5 from "path";
|
|
12
12
|
import fs5 from "fs-extra";
|
|
13
13
|
import { build } from "esbuild";
|
|
14
|
-
import ts3 from "typescript";
|
|
15
14
|
|
|
16
15
|
// src/build/typescript-builder.ts
|
|
17
16
|
import ts from "typescript";
|
|
18
17
|
import fs from "fs-extra";
|
|
18
|
+
import path2 from "path";
|
|
19
|
+
|
|
20
|
+
// src/util/get-config.ts
|
|
19
21
|
import path from "path";
|
|
22
|
+
|
|
23
|
+
// src/util/require.ts
|
|
24
|
+
import { createRequire } from "module";
|
|
25
|
+
var require_default = createRequire(import.meta.url);
|
|
26
|
+
|
|
27
|
+
// src/util/get-config.ts
|
|
28
|
+
var rootDir = process.cwd();
|
|
29
|
+
function fromRoot(pathName) {
|
|
30
|
+
if (!pathName) return rootDir;
|
|
31
|
+
return path.join(rootDir, pathName);
|
|
32
|
+
}
|
|
33
|
+
var userConfig = require_default(path.join(process.cwd(), "./xpine.config.mjs")).default;
|
|
34
|
+
var configDefaults = {
|
|
35
|
+
rootDir: fromRoot(),
|
|
36
|
+
srcDir: fromRoot("./src"),
|
|
37
|
+
distDir: fromRoot("./dist"),
|
|
38
|
+
packageJsonPath: fromRoot("package.json"),
|
|
39
|
+
// We need to use getters here in the event someone wants to change folders, such as the dist folder
|
|
40
|
+
get distPublicDir() {
|
|
41
|
+
return path.join(this.distDir, "./public");
|
|
42
|
+
},
|
|
43
|
+
get distPublicScriptsDir() {
|
|
44
|
+
return path.join(this.distPublicDir, "./scripts");
|
|
45
|
+
},
|
|
46
|
+
get distTempFolder() {
|
|
47
|
+
return path.join(this.distDir, "./temp");
|
|
48
|
+
},
|
|
49
|
+
get clientJSBundlePath() {
|
|
50
|
+
return path.join(this.distPublicScriptsDir, "./app.js");
|
|
51
|
+
},
|
|
52
|
+
get alpineDataPath() {
|
|
53
|
+
return path.join(this.distTempFolder, "./alpine-data.ts");
|
|
54
|
+
},
|
|
55
|
+
get serverDistDir() {
|
|
56
|
+
return path.join(this.distDir, "./server");
|
|
57
|
+
},
|
|
58
|
+
get serverDistAppPath() {
|
|
59
|
+
return path.join(this.serverDistDir, "./app.js");
|
|
60
|
+
},
|
|
61
|
+
// Important dirs/paths
|
|
62
|
+
get pagesDir() {
|
|
63
|
+
return path.join(this.srcDir, "./pages");
|
|
64
|
+
},
|
|
65
|
+
get distPagesDir() {
|
|
66
|
+
return path.join(this.distDir, "./pages");
|
|
67
|
+
},
|
|
68
|
+
get publicDir() {
|
|
69
|
+
return path.join(this.srcDir, "./public");
|
|
70
|
+
},
|
|
71
|
+
get serverDir() {
|
|
72
|
+
return path.join(this.srcDir, "./server");
|
|
73
|
+
},
|
|
74
|
+
get runDir() {
|
|
75
|
+
return path.join(this.serverDir, "./run");
|
|
76
|
+
},
|
|
77
|
+
get serverAppPath() {
|
|
78
|
+
return path.join(this.serverDir, "./app.ts");
|
|
79
|
+
},
|
|
80
|
+
get globalCSSFile() {
|
|
81
|
+
return path.join(this.publicDir, "./styles/global.css");
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var config = {
|
|
85
|
+
...configDefaults,
|
|
86
|
+
...userConfig
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/context.ts
|
|
90
|
+
function createContext(value) {
|
|
91
|
+
let stateValue = value;
|
|
92
|
+
let arrayQueue = {};
|
|
93
|
+
return {
|
|
94
|
+
get(id) {
|
|
95
|
+
const val = stateValue[id];
|
|
96
|
+
if (Array.isArray(val)) return val.filter((item) => item !== void 0);
|
|
97
|
+
return val;
|
|
98
|
+
},
|
|
99
|
+
set(id, callback, defaultValue) {
|
|
100
|
+
if (!stateValue[id]) stateValue[id] = defaultValue ?? null;
|
|
101
|
+
stateValue[id] = callback(stateValue[id]);
|
|
102
|
+
},
|
|
103
|
+
clear() {
|
|
104
|
+
stateValue = {};
|
|
105
|
+
},
|
|
106
|
+
getAll() {
|
|
107
|
+
return stateValue;
|
|
108
|
+
},
|
|
109
|
+
getArrayQueue() {
|
|
110
|
+
return arrayQueue;
|
|
111
|
+
},
|
|
112
|
+
addToArray(id, value2, position) {
|
|
113
|
+
const output = {
|
|
114
|
+
id,
|
|
115
|
+
value: addToContextArray(value2, position),
|
|
116
|
+
position
|
|
117
|
+
};
|
|
118
|
+
if (!arrayQueue[id]) {
|
|
119
|
+
arrayQueue[id] = [output];
|
|
120
|
+
} else {
|
|
121
|
+
arrayQueue[id].push(output);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
runArrayQueue() {
|
|
125
|
+
Object.keys(arrayQueue).forEach((key) => {
|
|
126
|
+
arrayQueue[key].sort((a, b) => {
|
|
127
|
+
return (a?.position ?? Infinity) - (b.position ?? Infinity);
|
|
128
|
+
});
|
|
129
|
+
for (const item of arrayQueue[key]) {
|
|
130
|
+
this.set(key, item.value, []);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
arrayQueue = {};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
var context = createContext({});
|
|
138
|
+
function addToContextArray(newValue, position) {
|
|
139
|
+
return function(currentValue) {
|
|
140
|
+
if (!currentValue) return [newValue];
|
|
141
|
+
if (typeof position === "number") {
|
|
142
|
+
if (position > currentValue?.length) {
|
|
143
|
+
const output = [...currentValue, ...new Array(position + 1 - currentValue.length)];
|
|
144
|
+
return output.toSpliced(position, 0, newValue);
|
|
145
|
+
}
|
|
146
|
+
if (currentValue?.[position] === void 0) return currentValue.toSpliced(position, 1, newValue);
|
|
147
|
+
return currentValue.toSpliced(position, 0, newValue);
|
|
148
|
+
}
|
|
149
|
+
return [...currentValue, newValue];
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/build/typescript-builder.ts
|
|
20
154
|
function findDataAttributesAndFunctions(node, sourceFile, foundDataAttributes = [], foundFunctions = []) {
|
|
21
155
|
if (node.kind === ts.SyntaxKind.JsxAttribute) {
|
|
22
156
|
const attribute = getAttributeValuePair(node, sourceFile);
|
|
@@ -88,18 +222,7 @@ function removeClientScriptInTSXFile(pathName, source) {
|
|
|
88
222
|
}
|
|
89
223
|
if (child.kind === ts.SyntaxKind.ImportDeclaration && child.pos >= clientDataStart) {
|
|
90
224
|
const text = child.getText(source);
|
|
91
|
-
|
|
92
|
-
if (child2.kind === ts.SyntaxKind.StringLiteral) {
|
|
93
|
-
const text2 = child2.getText(source);
|
|
94
|
-
const importPath = text2.replace(/[\"\']/g, "");
|
|
95
|
-
const isRelativeImport = importPath.startsWith(".") || importPath.startsWith("/");
|
|
96
|
-
if (!isRelativeImport) return;
|
|
97
|
-
clientImportsToReplace.push({
|
|
98
|
-
old: importPath,
|
|
99
|
-
new: path.join(path.dirname(pathName), importPath)
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
225
|
+
clientImportsToReplace.push(...getImportsToAbsolutePaths(child, source, pathName));
|
|
103
226
|
clientImportsToHoist.push(text);
|
|
104
227
|
}
|
|
105
228
|
});
|
|
@@ -115,18 +238,58 @@ function removeClientScriptInTSXFile(pathName, source) {
|
|
|
115
238
|
clientDataStart
|
|
116
239
|
};
|
|
117
240
|
}
|
|
241
|
+
function getImportsToAbsolutePaths(child, source, pathName) {
|
|
242
|
+
const output = [];
|
|
243
|
+
child.forEachChild((child2) => {
|
|
244
|
+
if (child2.kind === ts.SyntaxKind.StringLiteral) {
|
|
245
|
+
const text = child2.getText(source);
|
|
246
|
+
const importPath = text.replace(/[\"\']/g, "");
|
|
247
|
+
const isRelativeImport = importPath.startsWith(".") || importPath.startsWith("/");
|
|
248
|
+
if (!isRelativeImport) return;
|
|
249
|
+
output.push({
|
|
250
|
+
old: importPath,
|
|
251
|
+
new: path2.join(path2.dirname(pathName), importPath)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return output;
|
|
256
|
+
}
|
|
257
|
+
function getXpineOnLoadFunction(pathName, source, onLoadFileResult) {
|
|
258
|
+
const value = {
|
|
259
|
+
imports: "",
|
|
260
|
+
fn: ""
|
|
261
|
+
};
|
|
262
|
+
source.forEachChild((child) => {
|
|
263
|
+
if (child.kind == ts.SyntaxKind.ImportDeclaration) {
|
|
264
|
+
let importText = child.getText(source);
|
|
265
|
+
const importOutput = getImportsToAbsolutePaths(child, source, pathName);
|
|
266
|
+
for (const importItem of importOutput) {
|
|
267
|
+
importText = importText.replace(importItem.old, importItem.new);
|
|
268
|
+
}
|
|
269
|
+
value.imports = importText + "\n" + value.imports;
|
|
270
|
+
}
|
|
271
|
+
if ([ts.SyntaxKind.FirstStatement, ts.SyntaxKind.FunctionDeclaration].includes(child.kind)) {
|
|
272
|
+
let text = child.getText(source);
|
|
273
|
+
if (text.includes("xpineOnLoad")) {
|
|
274
|
+
const body = child?.body?.getText(source) || "";
|
|
275
|
+
value.fn = value.fn + "\n" + body ? `(function() ${body})();` : "";
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
return value;
|
|
280
|
+
}
|
|
281
|
+
async function triggerXPineOnLoad(noCache = false) {
|
|
282
|
+
context.clear();
|
|
283
|
+
const xpineOnLoad = (await import(path2.join(config.distDir, `./__xpineOnLoad.js${noCache ? `?cache=${Date.now()}` : ""}`)))?.default;
|
|
284
|
+
if (xpineOnLoad) await xpineOnLoad();
|
|
285
|
+
}
|
|
118
286
|
|
|
119
287
|
// src/scripts/build.ts
|
|
120
288
|
import { globSync } from "glob";
|
|
121
289
|
import postcss from "postcss";
|
|
122
290
|
import tailwindPostcss from "@tailwindcss/postcss";
|
|
123
291
|
|
|
124
|
-
// src/util/
|
|
125
|
-
import path2 from "path";
|
|
126
|
-
|
|
127
|
-
// src/util/require.ts
|
|
128
|
-
import { createRequire } from "module";
|
|
129
|
-
var require_default = createRequire(import.meta.url);
|
|
292
|
+
// src/util/paths.ts
|
|
130
293
|
function getXPineDistDir() {
|
|
131
294
|
const dir = import.meta.dirname;
|
|
132
295
|
const splitDir = dir.split("/xpine/dist");
|
|
@@ -137,68 +300,6 @@ function getXPineDistDir() {
|
|
|
137
300
|
return splitDir[0] + "/xpine/dist";
|
|
138
301
|
}
|
|
139
302
|
|
|
140
|
-
// src/util/get-config.ts
|
|
141
|
-
var rootDir = process.cwd();
|
|
142
|
-
function fromRoot(pathName) {
|
|
143
|
-
if (!pathName) return rootDir;
|
|
144
|
-
return path2.join(rootDir, pathName);
|
|
145
|
-
}
|
|
146
|
-
var userConfig = require_default(path2.join(process.cwd(), "./xpine.config.mjs")).default;
|
|
147
|
-
var configDefaults = {
|
|
148
|
-
rootDir: fromRoot(),
|
|
149
|
-
srcDir: fromRoot("./src"),
|
|
150
|
-
distDir: fromRoot("./dist"),
|
|
151
|
-
packageJsonPath: fromRoot("package.json"),
|
|
152
|
-
// We need to use getters here in the event someone wants to change folders, such as the dist folder
|
|
153
|
-
get distPublicDir() {
|
|
154
|
-
return path2.join(this.distDir, "./public");
|
|
155
|
-
},
|
|
156
|
-
get distPublicScriptsDir() {
|
|
157
|
-
return path2.join(this.distPublicDir, "./scripts");
|
|
158
|
-
},
|
|
159
|
-
get distTempFolder() {
|
|
160
|
-
return path2.join(this.distDir, "./temp");
|
|
161
|
-
},
|
|
162
|
-
get clientJSBundlePath() {
|
|
163
|
-
return path2.join(this.distPublicScriptsDir, "./app.js");
|
|
164
|
-
},
|
|
165
|
-
get alpineDataPath() {
|
|
166
|
-
return path2.join(this.distTempFolder, "./alpine-data.ts");
|
|
167
|
-
},
|
|
168
|
-
get serverDistDir() {
|
|
169
|
-
return path2.join(this.distDir, "./server");
|
|
170
|
-
},
|
|
171
|
-
get serverDistAppPath() {
|
|
172
|
-
return path2.join(this.serverDistDir, "./app.js");
|
|
173
|
-
},
|
|
174
|
-
// Important dirs/paths
|
|
175
|
-
get pagesDir() {
|
|
176
|
-
return path2.join(this.srcDir, "./pages");
|
|
177
|
-
},
|
|
178
|
-
get distPagesDir() {
|
|
179
|
-
return path2.join(this.distDir, "./pages");
|
|
180
|
-
},
|
|
181
|
-
get publicDir() {
|
|
182
|
-
return path2.join(this.srcDir, "./public");
|
|
183
|
-
},
|
|
184
|
-
get serverDir() {
|
|
185
|
-
return path2.join(this.srcDir, "./server");
|
|
186
|
-
},
|
|
187
|
-
get runDir() {
|
|
188
|
-
return path2.join(this.serverDir, "./run");
|
|
189
|
-
},
|
|
190
|
-
get serverAppPath() {
|
|
191
|
-
return path2.join(this.serverDir, "./app.ts");
|
|
192
|
-
},
|
|
193
|
-
get globalCSSFile() {
|
|
194
|
-
return path2.join(this.publicDir, "./styles/global.css");
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
var config = {
|
|
198
|
-
...configDefaults,
|
|
199
|
-
...userConfig
|
|
200
|
-
};
|
|
201
|
-
|
|
202
303
|
// src/util/postcss/remove-layers.ts
|
|
203
304
|
var plugin = (opts = {}) => {
|
|
204
305
|
return {
|
|
@@ -272,13 +373,16 @@ function transformTSXFiles(componentData, pageConfigFiles) {
|
|
|
272
373
|
ts2.ScriptTarget.Latest
|
|
273
374
|
);
|
|
274
375
|
const cleanedContent = removeClientScriptInTSXFile(args.path, source);
|
|
275
|
-
const htmlImportStart =
|
|
276
|
-
|
|
376
|
+
const htmlImportStart = [
|
|
377
|
+
"import { html } from 'xpine';"
|
|
378
|
+
];
|
|
379
|
+
const newContent = `${htmlImportStart.join("\n")}${cleanedContent.content}`;
|
|
277
380
|
componentData.push({
|
|
278
381
|
...args,
|
|
279
382
|
contents: `${htmlImportStart}${cleanedContent.fullContent}`,
|
|
280
383
|
clientContent: cleanedContent.clientContent,
|
|
281
|
-
configFiles: isAConfigFile(args?.path) ? null : getConfigFiles(args.path, pageConfigFiles)
|
|
384
|
+
configFiles: isAConfigFile(args?.path) ? null : getConfigFiles(args.path, pageConfigFiles),
|
|
385
|
+
source
|
|
282
386
|
});
|
|
283
387
|
return {
|
|
284
388
|
contents: newContent,
|
|
@@ -344,11 +448,15 @@ var doctypeHTML = "<!DOCTYPE html>";
|
|
|
344
448
|
var staticComment = "<!-- static -->";
|
|
345
449
|
|
|
346
450
|
// src/scripts/build.ts
|
|
451
|
+
import ts3 from "typescript";
|
|
347
452
|
var extensions = [".ts", ".tsx"];
|
|
348
453
|
var packageJson = JSON.parse(fs5.readFileSync(config.packageJsonPath, "utf-8"));
|
|
349
454
|
var allPackages = Object.keys(packageJson.devDependencies).concat(Object.keys(packageJson.dependencies));
|
|
350
455
|
var xpineDistDir = getXPineDistDir();
|
|
351
|
-
async function buildApp(
|
|
456
|
+
async function buildApp(args) {
|
|
457
|
+
const isDev = args?.isDev || false;
|
|
458
|
+
const removePreviousBuild = args?.removePreviousBuild || false;
|
|
459
|
+
const disableTailwind = args?.disableTailwind || false;
|
|
352
460
|
try {
|
|
353
461
|
if (removePreviousBuild) fs5.removeSync(config.distDir);
|
|
354
462
|
const srcDirFiles = globSync(config.srcDir + "/**/*.{js,ts,tsx,jsx}");
|
|
@@ -356,9 +464,12 @@ async function buildApp(isDev = false, removePreviousBuild = false) {
|
|
|
356
464
|
const alpineDataFile = await buildAlpineDataFile(componentData, dataFiles);
|
|
357
465
|
await buildClientSideFiles([alpineDataFile], isDev);
|
|
358
466
|
fs5.removeSync(config.distTempFolder);
|
|
359
|
-
await buildCSS();
|
|
467
|
+
await buildCSS(disableTailwind);
|
|
360
468
|
await buildPublicFolderSymlinks();
|
|
469
|
+
await buildOnLoadFile(componentData, isDev);
|
|
470
|
+
if (!isDev) await triggerXPineOnLoad();
|
|
361
471
|
if (!isDev) await buildFilesWithConfigs(componentData);
|
|
472
|
+
if (!isDev) context.clear();
|
|
362
473
|
} catch (err) {
|
|
363
474
|
console.error("Build failed");
|
|
364
475
|
console.error(err);
|
|
@@ -452,12 +563,14 @@ async function buildAlpineDataFile(componentData, dataFiles) {
|
|
|
452
563
|
};
|
|
453
564
|
const componentsAndDataFiles = componentData.concat(dataFiles);
|
|
454
565
|
for (const component of componentsAndDataFiles) {
|
|
455
|
-
|
|
456
|
-
component.
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
566
|
+
if (!component.source) {
|
|
567
|
+
component.source = ts3.createSourceFile(
|
|
568
|
+
component.path,
|
|
569
|
+
component.contents,
|
|
570
|
+
ts3.ScriptTarget.Latest
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
const dataFunctionResult = findDataAttributesAndFunctions(component.source, component.source);
|
|
461
574
|
dataFunctionResults.foundDataAttributes.push(...dataFunctionResult.foundDataAttributes);
|
|
462
575
|
const foundFunctionsWithPath = dataFunctionResult.foundFunctions.map((item) => {
|
|
463
576
|
return {
|
|
@@ -481,11 +594,11 @@ async function buildAlpineDataFile(componentData, dataFiles) {
|
|
|
481
594
|
fs5.writeFileSync(config.alpineDataPath, result);
|
|
482
595
|
return config.alpineDataPath;
|
|
483
596
|
}
|
|
484
|
-
async function buildCSS() {
|
|
597
|
+
async function buildCSS(disableTailwind) {
|
|
485
598
|
const cssFiles = globSync(config.srcDir + "/**/*.css");
|
|
486
599
|
for (const file of cssFiles) {
|
|
487
600
|
const fileContents = fs5.readFileSync(file, "utf-8");
|
|
488
|
-
const result = await postcss([tailwindPostcss(), remove_layers_default()]).process(fileContents, { from: file });
|
|
601
|
+
const result = disableTailwind ? fileContents : await postcss([tailwindPostcss(), remove_layers_default()]).process(fileContents, { from: file });
|
|
489
602
|
const newPath = file.replace(config.srcDir, config.distDir);
|
|
490
603
|
fs5.ensureFileSync(newPath);
|
|
491
604
|
fs5.writeFileSync(newPath, result.css);
|
|
@@ -547,6 +660,7 @@ async function buildStaticFiles(config2, component, componentImport, builtCompon
|
|
|
547
660
|
}
|
|
548
661
|
const componentDynamicPaths = getComponentDynamicPaths(componentFileName);
|
|
549
662
|
const componentFn = componentImport.default;
|
|
663
|
+
if (componentImport?.onInit) await componentImport.onInit();
|
|
550
664
|
const outputPath = componentDynamicPaths?.length ? componentDynamicPaths.reduce((total, current) => {
|
|
551
665
|
return total.replace(`/[${current}]`, "");
|
|
552
666
|
}, path5.dirname(builtComponentPath)) : path5.dirname(builtComponentPath);
|
|
@@ -596,6 +710,53 @@ function getComponentDynamicPaths(componentPath) {
|
|
|
596
710
|
}
|
|
597
711
|
return output;
|
|
598
712
|
}
|
|
713
|
+
async function buildOnLoadFile(componentData, isDev) {
|
|
714
|
+
const onLoadFiles = [];
|
|
715
|
+
const onLoadFileResult = {
|
|
716
|
+
imports: "",
|
|
717
|
+
fn: ""
|
|
718
|
+
};
|
|
719
|
+
for (const component of componentData) {
|
|
720
|
+
if (component.contents.includes("xpineOnLoad")) {
|
|
721
|
+
onLoadFiles.push({
|
|
722
|
+
path: sourcePathToDistPath(component.path),
|
|
723
|
+
source: component.source
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
onLoadFiles.sort((a, b) => {
|
|
728
|
+
return a.path.localeCompare(b.path);
|
|
729
|
+
});
|
|
730
|
+
for (const file of onLoadFiles) {
|
|
731
|
+
const result = getXpineOnLoadFunction(file.path, file.source, onLoadFileResult);
|
|
732
|
+
onLoadFileResult.fn += result.fn;
|
|
733
|
+
onLoadFileResult.imports += result.imports;
|
|
734
|
+
}
|
|
735
|
+
const output = `
|
|
736
|
+
${onLoadFileResult.imports}
|
|
737
|
+
import { context } from "xpine";
|
|
738
|
+
export default async function triggerOnLoad() {
|
|
739
|
+
${onLoadFileResult.fn}
|
|
740
|
+
context.runArrayQueue();
|
|
741
|
+
}
|
|
742
|
+
`;
|
|
743
|
+
const onLoadFilePath = path5.join(config.distDir, "./__xpineOnLoad.ts");
|
|
744
|
+
fs5.writeFileSync(onLoadFilePath, output);
|
|
745
|
+
await build({
|
|
746
|
+
entryPoints: [onLoadFilePath],
|
|
747
|
+
format: "esm",
|
|
748
|
+
platform: "node",
|
|
749
|
+
outdir: config.distDir,
|
|
750
|
+
bundle: true,
|
|
751
|
+
sourcemap: isDev ? "inline" : false,
|
|
752
|
+
external: allPackages,
|
|
753
|
+
jsx: "transform",
|
|
754
|
+
minify: !isDev,
|
|
755
|
+
plugins: [
|
|
756
|
+
addDotJS(allPackages, extensions, isDev)
|
|
757
|
+
]
|
|
758
|
+
});
|
|
759
|
+
}
|
|
599
760
|
|
|
600
761
|
// src/runDevServer.ts
|
|
601
762
|
import path7 from "path";
|
|
@@ -636,7 +797,7 @@ await setupEnv();
|
|
|
636
797
|
async function runDevServer() {
|
|
637
798
|
process.env.NODE_ENV = "development";
|
|
638
799
|
const rebuildEmitter = createRebuildEmitter();
|
|
639
|
-
await buildApp(true);
|
|
800
|
+
await buildApp({ isDev: true });
|
|
640
801
|
const startServer = (await import(config.serverDistAppPath + `?cache=${Date.now()}`)).default;
|
|
641
802
|
let appServer = await startServer();
|
|
642
803
|
const watcher = chokidar.watch(config.srcDir, {
|
|
@@ -651,14 +812,14 @@ async function runDevServer() {
|
|
|
651
812
|
rebuildEmitter.emit("rebuild-server");
|
|
652
813
|
return;
|
|
653
814
|
}
|
|
654
|
-
await buildApp(true);
|
|
815
|
+
await buildApp({ isDev: true });
|
|
655
816
|
refreshEmitter.emit("refresh");
|
|
656
817
|
});
|
|
657
818
|
rebuildEmitter.on("done", async () => {
|
|
658
819
|
await rebuildServer();
|
|
659
820
|
});
|
|
660
821
|
async function rebuildServer() {
|
|
661
|
-
await buildApp(true);
|
|
822
|
+
await buildApp({ isDev: true });
|
|
662
823
|
const startServer2 = (await import(config.serverDistAppPath + `?cache=${Date.now()}`)).default;
|
|
663
824
|
appServer = await startServer2();
|
|
664
825
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onInit.d.ts","sourceRoot":"","sources":["../../../../src/util/hooks/onInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,uBAOhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/util/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,WAS9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require.d.ts","sourceRoot":"","sources":["../../../src/util/require.ts"],"names":[],"mappings":";AAEA,wBAA8C
|
|
1
|
+
{"version":3,"file":"require.d.ts","sourceRoot":"","sources":["../../../src/util/require.ts"],"names":[],"mappings":";AAEA,wBAA8C"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
+
import ts from 'typescript';
|
|
2
3
|
export type XPineConfig = {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
};
|
|
@@ -37,5 +38,6 @@ export type ComponentData = {
|
|
|
37
38
|
contents: string;
|
|
38
39
|
clientContent: string;
|
|
39
40
|
configFiles: string[];
|
|
41
|
+
source: ts.SourceFile;
|
|
40
42
|
};
|
|
41
43
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAC7C,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,aAAa,CAAC;IACnB,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC;CACvB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xpine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-secrets-manager": "^3.758.0",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"test:dev": "cd ./tests && npm run dev",
|
|
34
34
|
"test:start": "cd ./tests && npm run build && npm start",
|
|
35
35
|
"test:build": "cd ./tests && npm run build",
|
|
36
|
+
"test:build:dev": "cd ./tests && npm run build:dev",
|
|
36
37
|
"lint": "npx eslint",
|
|
37
38
|
"fix": "npx eslint --fix",
|
|
38
39
|
"release:patch": "npm run build && npm version patch && npm publish"
|
|
@@ -45,12 +46,14 @@
|
|
|
45
46
|
"type": "module",
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@eslint/js": "^9.24.0",
|
|
49
|
+
"@tailwindcss/oxide-darwin-arm64": "^4.1.3",
|
|
48
50
|
"@types/express": "^5.0.0",
|
|
49
51
|
"@types/node": "^22.13.5",
|
|
50
52
|
"@types/request-ip": "^0.0.41",
|
|
51
53
|
"@types/shelljs": "^0.8.15",
|
|
52
54
|
"@types/yargs": "^17.0.33",
|
|
53
55
|
"axios": "^1.8.4",
|
|
56
|
+
"lightningcss-darwin-arm64": "^1.29.3",
|
|
54
57
|
"typescript-eslint": "^8.29.0"
|
|
55
58
|
}
|
|
56
59
|
}
|
package/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
+
import ts from 'typescript';
|
|
2
3
|
|
|
3
4
|
export type XPineConfig = {
|
|
4
5
|
[key: string]: any;
|
|
@@ -22,7 +23,7 @@ export type WrapperProps = {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export type ConfigFile = {
|
|
25
|
-
staticPaths?: boolean | (() => Promise<{ [key: string]: string}[]>);
|
|
26
|
+
staticPaths?: boolean | (() => Promise<{ [key: string]: string }[]>);
|
|
26
27
|
wrapper?: (props: WrapperProps) => Promise<any>;
|
|
27
28
|
data?: (req: ServerRequest) => Promise<any>;
|
|
28
29
|
}
|
|
@@ -43,4 +44,5 @@ export type ComponentData = {
|
|
|
43
44
|
contents: string;
|
|
44
45
|
clientContent: string;
|
|
45
46
|
configFiles: string[];
|
|
47
|
+
source: ts.SourceFile;
|
|
46
48
|
}
|