@kithinji/pod 1.0.39 → 1.0.41
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.js +363 -129
- package/dist/index.js.map +3 -3
- package/dist/types/dev/server.d.ts +1 -0
- package/dist/types/dev/server.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/plugins/generators/utils.d.ts +1 -1
- package/dist/types/plugins/generators/utils.d.ts.map +1 -1
- package/dist/types/plugins/transformers/j2d.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1724,6 +1724,67 @@ var JSXUtilities = class {
|
|
|
1724
1724
|
isComponentTag(tag) {
|
|
1725
1725
|
return tag ? /^[A-Z]/.test(tag) : false;
|
|
1726
1726
|
}
|
|
1727
|
+
isSVGTag(tag) {
|
|
1728
|
+
const svgTags = /* @__PURE__ */ new Set([
|
|
1729
|
+
"svg",
|
|
1730
|
+
"circle",
|
|
1731
|
+
"rect",
|
|
1732
|
+
"line",
|
|
1733
|
+
"path",
|
|
1734
|
+
"polygon",
|
|
1735
|
+
"polyline",
|
|
1736
|
+
"ellipse",
|
|
1737
|
+
"text",
|
|
1738
|
+
"tspan",
|
|
1739
|
+
"g",
|
|
1740
|
+
"defs",
|
|
1741
|
+
"use",
|
|
1742
|
+
"symbol",
|
|
1743
|
+
"marker",
|
|
1744
|
+
"clipPath",
|
|
1745
|
+
"mask",
|
|
1746
|
+
"pattern",
|
|
1747
|
+
"linearGradient",
|
|
1748
|
+
"radialGradient",
|
|
1749
|
+
"stop",
|
|
1750
|
+
"animate",
|
|
1751
|
+
"animateTransform",
|
|
1752
|
+
"foreignObject",
|
|
1753
|
+
"image",
|
|
1754
|
+
"textPath",
|
|
1755
|
+
"feBlend",
|
|
1756
|
+
"feColorMatrix",
|
|
1757
|
+
"feComponentTransfer",
|
|
1758
|
+
"feComposite",
|
|
1759
|
+
"feConvolveMatrix",
|
|
1760
|
+
"feDiffuseLighting",
|
|
1761
|
+
"feDisplacementMap",
|
|
1762
|
+
"feDistantLight",
|
|
1763
|
+
"feFlood",
|
|
1764
|
+
"feFuncA",
|
|
1765
|
+
"feFuncB",
|
|
1766
|
+
"feFuncG",
|
|
1767
|
+
"feFuncR",
|
|
1768
|
+
"feGaussianBlur",
|
|
1769
|
+
"feImage",
|
|
1770
|
+
"feMerge",
|
|
1771
|
+
"feMergeNode",
|
|
1772
|
+
"feMorphology",
|
|
1773
|
+
"feOffset",
|
|
1774
|
+
"fePointLight",
|
|
1775
|
+
"feSpecularLighting",
|
|
1776
|
+
"feSpotLight",
|
|
1777
|
+
"feTile",
|
|
1778
|
+
"feTurbulence",
|
|
1779
|
+
"filter",
|
|
1780
|
+
"metadata",
|
|
1781
|
+
"title",
|
|
1782
|
+
"desc",
|
|
1783
|
+
"switch",
|
|
1784
|
+
"view"
|
|
1785
|
+
]);
|
|
1786
|
+
return svgTags.has(tag);
|
|
1787
|
+
}
|
|
1727
1788
|
};
|
|
1728
1789
|
var ObservableManager = class {
|
|
1729
1790
|
constructor(t, guards) {
|
|
@@ -1871,11 +1932,21 @@ var ElementTransformer = class {
|
|
|
1871
1932
|
transformDOMElement(jsxElement, tag, scope, context2) {
|
|
1872
1933
|
const elId = scope.generateUidIdentifier("el");
|
|
1873
1934
|
const statements = [];
|
|
1935
|
+
const isSVGTag = this.jsxUtils.isSVGTag(tag);
|
|
1874
1936
|
statements.push(
|
|
1875
1937
|
this.t.variableDeclaration("var", [
|
|
1876
1938
|
this.t.variableDeclarator(
|
|
1877
1939
|
elId,
|
|
1878
|
-
this.t.callExpression(
|
|
1940
|
+
isSVGTag ? this.t.callExpression(
|
|
1941
|
+
this.t.memberExpression(
|
|
1942
|
+
this.t.identifier("document"),
|
|
1943
|
+
this.t.identifier("createElementNS")
|
|
1944
|
+
),
|
|
1945
|
+
[
|
|
1946
|
+
this.t.stringLiteral("http://www.w3.org/2000/svg"),
|
|
1947
|
+
this.t.stringLiteral(tag)
|
|
1948
|
+
]
|
|
1949
|
+
) : this.t.callExpression(
|
|
1879
1950
|
this.t.memberExpression(
|
|
1880
1951
|
this.t.identifier("document"),
|
|
1881
1952
|
this.t.identifier("createElement")
|
|
@@ -2732,8 +2803,8 @@ function stringifyType3(typeNode) {
|
|
|
2732
2803
|
}
|
|
2733
2804
|
function generateStubCode(stub) {
|
|
2734
2805
|
const className = stub.name;
|
|
2735
|
-
const
|
|
2736
|
-
if (
|
|
2806
|
+
const build3 = stub.methods.find((p) => p.name == "build");
|
|
2807
|
+
if (build3 == void 0) {
|
|
2737
2808
|
throw new Error("Component has no build function");
|
|
2738
2809
|
}
|
|
2739
2810
|
const decoratorsStr = stub.decorators.length > 0 ? stub.decorators.join("\n") + "\n" : "";
|
|
@@ -3083,8 +3154,8 @@ function useMyPlugin(options) {
|
|
|
3083
3154
|
const clientTransformer = new ClientBuildTransformer();
|
|
3084
3155
|
return {
|
|
3085
3156
|
name: "Orca",
|
|
3086
|
-
setup(
|
|
3087
|
-
|
|
3157
|
+
setup(build3) {
|
|
3158
|
+
build3.onLoad(
|
|
3088
3159
|
{ filter: /\.tsx?$/ },
|
|
3089
3160
|
async (args) => {
|
|
3090
3161
|
const source = await fs2.readFile(args.path, "utf8");
|
|
@@ -3310,8 +3381,8 @@ import * as fs4 from "fs";
|
|
|
3310
3381
|
function stylePlugin(store) {
|
|
3311
3382
|
return {
|
|
3312
3383
|
name: "style",
|
|
3313
|
-
setup(
|
|
3314
|
-
|
|
3384
|
+
setup(build3) {
|
|
3385
|
+
build3.onEnd(() => {
|
|
3315
3386
|
const styleRules = store.get("style_rules");
|
|
3316
3387
|
if (!styleRules || styleRules.length === 0) {
|
|
3317
3388
|
console.log("No style rules generated");
|
|
@@ -3383,8 +3454,8 @@ function useCompilePlugin(options) {
|
|
|
3383
3454
|
const transformer = new BuildTransformer();
|
|
3384
3455
|
return {
|
|
3385
3456
|
name: "Orca",
|
|
3386
|
-
setup(
|
|
3387
|
-
|
|
3457
|
+
setup(build3) {
|
|
3458
|
+
build3.onLoad(
|
|
3388
3459
|
{ filter: /\.tsx?$/ },
|
|
3389
3460
|
async (args) => {
|
|
3390
3461
|
const source = await fs5.readFile(args.path, "utf8");
|
|
@@ -3518,6 +3589,12 @@ function createHotReloadTransformer(port) {
|
|
|
3518
3589
|
}
|
|
3519
3590
|
|
|
3520
3591
|
// src/dev/server.ts
|
|
3592
|
+
var createLogger = (debugMode = false) => ({
|
|
3593
|
+
info: (...args) => console.log("[INFO]", ...args),
|
|
3594
|
+
error: (...args) => console.error("[ERROR]", ...args),
|
|
3595
|
+
warn: (...args) => console.warn("[WARN]", ...args),
|
|
3596
|
+
debug: (...args) => debugMode && console.log("[DEBUG]", ...args)
|
|
3597
|
+
});
|
|
3521
3598
|
var virtualClientFiles = {
|
|
3522
3599
|
"virtual:navigate": {
|
|
3523
3600
|
output: "navigate",
|
|
@@ -3526,7 +3603,7 @@ export async function navigate(event, url) {
|
|
|
3526
3603
|
event.preventDefault();
|
|
3527
3604
|
|
|
3528
3605
|
try {
|
|
3529
|
-
const { Navigate, getCurrentInjector } = await import("
|
|
3606
|
+
const { Navigate, getCurrentInjector } = await import("/src/client/client.js");
|
|
3530
3607
|
const injector = getCurrentInjector();
|
|
3531
3608
|
|
|
3532
3609
|
if (injector) {
|
|
@@ -3546,8 +3623,8 @@ export async function navigate(event, url) {
|
|
|
3546
3623
|
function createVirtualModulePlugin(virtualFiles) {
|
|
3547
3624
|
return {
|
|
3548
3625
|
name: "virtual-module",
|
|
3549
|
-
setup(
|
|
3550
|
-
|
|
3626
|
+
setup(build3) {
|
|
3627
|
+
build3.onResolve({ filter: /^virtual:/ }, (args) => {
|
|
3551
3628
|
if (virtualFiles[args.path]) {
|
|
3552
3629
|
return {
|
|
3553
3630
|
path: args.path,
|
|
@@ -3555,7 +3632,7 @@ function createVirtualModulePlugin(virtualFiles) {
|
|
|
3555
3632
|
};
|
|
3556
3633
|
}
|
|
3557
3634
|
});
|
|
3558
|
-
|
|
3635
|
+
build3.onLoad({ filter: /.*/, namespace: "virtual" }, (args) => {
|
|
3559
3636
|
const virtualFile = virtualFiles[args.path];
|
|
3560
3637
|
if (virtualFile) {
|
|
3561
3638
|
return {
|
|
@@ -3568,37 +3645,50 @@ function createVirtualModulePlugin(virtualFiles) {
|
|
|
3568
3645
|
};
|
|
3569
3646
|
}
|
|
3570
3647
|
var HotReloadManager = class {
|
|
3571
|
-
constructor(port = 3001) {
|
|
3648
|
+
constructor(port = 3001, logger) {
|
|
3572
3649
|
this.wss = null;
|
|
3573
3650
|
this.clients = /* @__PURE__ */ new Set();
|
|
3574
3651
|
this.port = port;
|
|
3652
|
+
this.logger = logger;
|
|
3575
3653
|
}
|
|
3576
3654
|
start() {
|
|
3577
3655
|
this.wss = new WebSocketServer({ port: this.port });
|
|
3578
3656
|
this.wss.on("connection", (ws) => {
|
|
3579
3657
|
this.clients.add(ws);
|
|
3658
|
+
this.logger.debug(
|
|
3659
|
+
`Client connected. Total clients: ${this.clients.size}`
|
|
3660
|
+
);
|
|
3580
3661
|
ws.on("close", () => {
|
|
3581
3662
|
this.clients.delete(ws);
|
|
3663
|
+
this.logger.debug(
|
|
3664
|
+
`Client disconnected. Total clients: ${this.clients.size}`
|
|
3665
|
+
);
|
|
3582
3666
|
});
|
|
3583
3667
|
ws.on("error", (error) => {
|
|
3584
|
-
|
|
3668
|
+
this.logger.error("WebSocket error:", error);
|
|
3585
3669
|
this.clients.delete(ws);
|
|
3586
3670
|
});
|
|
3587
3671
|
});
|
|
3588
|
-
|
|
3672
|
+
this.logger.info(
|
|
3673
|
+
`Hot reload server listening on ws://localhost:${this.port}`
|
|
3674
|
+
);
|
|
3589
3675
|
}
|
|
3590
3676
|
reload() {
|
|
3591
3677
|
const activeClients = Array.from(this.clients).filter(
|
|
3592
3678
|
(client) => client.readyState === WebSocket.OPEN
|
|
3593
3679
|
);
|
|
3594
3680
|
if (activeClients.length === 0) {
|
|
3681
|
+
this.logger.debug("No active clients to reload");
|
|
3595
3682
|
return;
|
|
3596
3683
|
}
|
|
3684
|
+
this.logger.debug(
|
|
3685
|
+
`Sending reload signal to ${activeClients.length} client(s)`
|
|
3686
|
+
);
|
|
3597
3687
|
activeClients.forEach((client) => {
|
|
3598
3688
|
try {
|
|
3599
3689
|
client.send("reload");
|
|
3600
3690
|
} catch (error) {
|
|
3601
|
-
|
|
3691
|
+
this.logger.error("Failed to send reload signal:", error);
|
|
3602
3692
|
this.clients.delete(client);
|
|
3603
3693
|
}
|
|
3604
3694
|
});
|
|
@@ -3607,14 +3697,16 @@ var HotReloadManager = class {
|
|
|
3607
3697
|
if (this.wss) {
|
|
3608
3698
|
this.clients.forEach((client) => client.close());
|
|
3609
3699
|
this.wss.close();
|
|
3700
|
+
this.logger.debug("Hot reload server closed");
|
|
3610
3701
|
}
|
|
3611
3702
|
}
|
|
3612
3703
|
};
|
|
3613
|
-
async function copyAndProcessHtml(hotReloadPort, preprocessorOptions) {
|
|
3704
|
+
async function copyAndProcessHtml(hotReloadPort, preprocessorOptions, logger) {
|
|
3614
3705
|
try {
|
|
3615
3706
|
await fs7.mkdir("public", { recursive: true });
|
|
3707
|
+
const transformers = hotReloadPort ? [createHotReloadTransformer(hotReloadPort)] : [];
|
|
3616
3708
|
const preprocessor = new HtmlPreprocessor({
|
|
3617
|
-
transformers
|
|
3709
|
+
transformers,
|
|
3618
3710
|
injectScripts: ["./navigate.js"],
|
|
3619
3711
|
...preprocessorOptions
|
|
3620
3712
|
});
|
|
@@ -3622,149 +3714,212 @@ async function copyAndProcessHtml(hotReloadPort, preprocessorOptions) {
|
|
|
3622
3714
|
"./src/client/index.html",
|
|
3623
3715
|
"./public/index.html"
|
|
3624
3716
|
);
|
|
3717
|
+
logger?.debug("HTML processed successfully");
|
|
3625
3718
|
} catch (error) {
|
|
3626
|
-
|
|
3719
|
+
logger?.error("Failed to copy and process index.html:", error);
|
|
3627
3720
|
throw error;
|
|
3628
3721
|
}
|
|
3629
3722
|
}
|
|
3630
|
-
async function cleanDirectories() {
|
|
3723
|
+
async function cleanDirectories(logger) {
|
|
3724
|
+
logger?.debug("Cleaning build directories...");
|
|
3631
3725
|
await Promise.all([
|
|
3632
3726
|
fs7.rm("dist", { recursive: true, force: true }),
|
|
3633
3727
|
fs7.rm("public", { recursive: true, force: true })
|
|
3634
3728
|
]);
|
|
3635
3729
|
}
|
|
3636
|
-
function
|
|
3730
|
+
function waitForProcessExit(process2, timeout = 5e3) {
|
|
3731
|
+
return new Promise((resolve3) => {
|
|
3732
|
+
const timer = setTimeout(() => {
|
|
3733
|
+
process2.kill("SIGKILL");
|
|
3734
|
+
resolve3();
|
|
3735
|
+
}, timeout);
|
|
3736
|
+
process2.once("exit", () => {
|
|
3737
|
+
clearTimeout(timer);
|
|
3738
|
+
resolve3();
|
|
3739
|
+
});
|
|
3740
|
+
process2.kill("SIGTERM");
|
|
3741
|
+
});
|
|
3742
|
+
}
|
|
3743
|
+
function createRestartServerPlugin(serverProcess, onServerReady, hotReloadManager, logger) {
|
|
3637
3744
|
return {
|
|
3638
3745
|
name: "restart-server",
|
|
3639
|
-
setup(
|
|
3640
|
-
|
|
3746
|
+
setup(build3) {
|
|
3747
|
+
build3.onEnd(async (result) => {
|
|
3641
3748
|
if (result.errors.length > 0) {
|
|
3642
|
-
|
|
3749
|
+
logger.error(
|
|
3643
3750
|
`Server build failed with ${result.errors.length} error(s)`
|
|
3644
3751
|
);
|
|
3645
3752
|
return;
|
|
3646
3753
|
}
|
|
3754
|
+
logger.info("Server build completed");
|
|
3647
3755
|
if (serverProcess.current) {
|
|
3648
|
-
|
|
3756
|
+
logger.debug("Stopping existing server process...");
|
|
3757
|
+
await waitForProcessExit(serverProcess.current);
|
|
3649
3758
|
}
|
|
3650
3759
|
serverProcess.current = spawn("node", ["dist/main.js"], {
|
|
3651
3760
|
stdio: "inherit"
|
|
3652
3761
|
});
|
|
3653
3762
|
serverProcess.current.on("error", (err) => {
|
|
3654
|
-
|
|
3763
|
+
logger.error("Server process error:", err);
|
|
3764
|
+
});
|
|
3765
|
+
serverProcess.current.on("exit", (code) => {
|
|
3766
|
+
if (code !== null && code !== 0) {
|
|
3767
|
+
logger.warn(`Server process exited with code ${code}`);
|
|
3768
|
+
}
|
|
3655
3769
|
});
|
|
3656
3770
|
setTimeout(() => {
|
|
3657
|
-
|
|
3771
|
+
onServerReady();
|
|
3772
|
+
if (hotReloadManager) {
|
|
3773
|
+
hotReloadManager.reload();
|
|
3774
|
+
}
|
|
3658
3775
|
}, 500);
|
|
3659
|
-
onServerBuildComplete();
|
|
3660
3776
|
});
|
|
3661
3777
|
}
|
|
3662
3778
|
};
|
|
3663
3779
|
}
|
|
3780
|
+
async function buildVirtualFiles(config, logger) {
|
|
3781
|
+
logger.debug("Building virtual files...");
|
|
3782
|
+
const virtualEntryPoints = {};
|
|
3783
|
+
Object.entries(virtualClientFiles).forEach(([key, value]) => {
|
|
3784
|
+
virtualEntryPoints[value.output] = key;
|
|
3785
|
+
});
|
|
3786
|
+
await esbuild2.build({
|
|
3787
|
+
entryPoints: virtualEntryPoints,
|
|
3788
|
+
bundle: true,
|
|
3789
|
+
outdir: "public",
|
|
3790
|
+
platform: "browser",
|
|
3791
|
+
format: "iife",
|
|
3792
|
+
globalName: "Orca",
|
|
3793
|
+
sourcemap: config.build?.sourcemap ?? true,
|
|
3794
|
+
minify: config.build?.minify ?? false,
|
|
3795
|
+
plugins: [createVirtualModulePlugin(virtualClientFiles)],
|
|
3796
|
+
write: true
|
|
3797
|
+
});
|
|
3798
|
+
logger.debug("Virtual files built successfully");
|
|
3799
|
+
}
|
|
3800
|
+
async function buildClient(clientFiles, config, store, isWatch = false, onBuildComplete, logger) {
|
|
3801
|
+
if (clientFiles.size === 0) {
|
|
3802
|
+
logger?.debug("No client files to build");
|
|
3803
|
+
return null;
|
|
3804
|
+
}
|
|
3805
|
+
logger?.debug(`Building ${clientFiles.size} client file(s)...`);
|
|
3806
|
+
const entryPoints = Array.from(clientFiles);
|
|
3807
|
+
const graph = buildGraph(entryPoints);
|
|
3808
|
+
const buildOptions = {
|
|
3809
|
+
entryPoints,
|
|
3810
|
+
bundle: true,
|
|
3811
|
+
outdir: "public",
|
|
3812
|
+
outbase: ".",
|
|
3813
|
+
platform: "browser",
|
|
3814
|
+
format: "esm",
|
|
3815
|
+
sourcemap: config.build?.sourcemap ?? true,
|
|
3816
|
+
splitting: true,
|
|
3817
|
+
minify: config.build?.minify ?? false,
|
|
3818
|
+
plugins: [
|
|
3819
|
+
...config.plugins?.map((cb) => cb(store)) || [],
|
|
3820
|
+
...config.client_plugins?.map((cb) => cb(store)) || [],
|
|
3821
|
+
useMyPlugin({
|
|
3822
|
+
graph,
|
|
3823
|
+
isServerBuild: false,
|
|
3824
|
+
onClientFound: () => {
|
|
3825
|
+
}
|
|
3826
|
+
}),
|
|
3827
|
+
{
|
|
3828
|
+
name: "client-build-logger",
|
|
3829
|
+
setup(build3) {
|
|
3830
|
+
build3.onEnd((result) => {
|
|
3831
|
+
if (result.errors.length > 0) {
|
|
3832
|
+
logger?.error(
|
|
3833
|
+
`Client build failed with ${result.errors.length} error(s)`
|
|
3834
|
+
);
|
|
3835
|
+
} else {
|
|
3836
|
+
logger?.info("Client build completed");
|
|
3837
|
+
onBuildComplete?.();
|
|
3838
|
+
}
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
],
|
|
3843
|
+
write: true
|
|
3844
|
+
};
|
|
3845
|
+
if (isWatch) {
|
|
3846
|
+
const ctx = await esbuild2.context(buildOptions);
|
|
3847
|
+
await ctx.watch();
|
|
3848
|
+
return ctx;
|
|
3849
|
+
} else {
|
|
3850
|
+
await esbuild2.build(buildOptions);
|
|
3851
|
+
return null;
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
async function checkClientFilesExist() {
|
|
3855
|
+
try {
|
|
3856
|
+
await Promise.all([
|
|
3857
|
+
fs7.access("src/client/client.tsx"),
|
|
3858
|
+
fs7.access("src/client/index.html")
|
|
3859
|
+
]);
|
|
3860
|
+
return true;
|
|
3861
|
+
} catch {
|
|
3862
|
+
return false;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3664
3865
|
async function startDevServer() {
|
|
3866
|
+
const logger = createLogger(process.env.DEBUG === "true");
|
|
3665
3867
|
const store = Store.getInstance();
|
|
3666
3868
|
const userConfig = await loadConfig();
|
|
3667
3869
|
const config = mergeConfig(getDefaultConfig(), userConfig);
|
|
3668
3870
|
const HOT_RELOAD_PORT = 3001;
|
|
3669
|
-
const
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3871
|
+
const hasClientFiles = await checkClientFilesExist();
|
|
3872
|
+
if (!hasClientFiles) {
|
|
3873
|
+
logger.warn(
|
|
3874
|
+
"Client files not found (src/client/client.tsx or src/client/index.html missing). Skipping client build."
|
|
3875
|
+
);
|
|
3876
|
+
}
|
|
3877
|
+
const hotReloadManager = hasClientFiles ? new HotReloadManager(HOT_RELOAD_PORT, logger) : null;
|
|
3878
|
+
await cleanDirectories(logger);
|
|
3879
|
+
if (hasClientFiles) {
|
|
3880
|
+
await copyAndProcessHtml(HOT_RELOAD_PORT, config.htmlPreprocessor, logger);
|
|
3881
|
+
hotReloadManager.start();
|
|
3882
|
+
}
|
|
3673
3883
|
const entryPoints = ["src/main.ts"];
|
|
3674
|
-
const clientFiles = /* @__PURE__ */ new Set(["src/client/client.tsx"]);
|
|
3884
|
+
const clientFiles = hasClientFiles ? /* @__PURE__ */ new Set(["src/client/client.tsx"]) : /* @__PURE__ */ new Set();
|
|
3675
3885
|
const serverProcessRef = { current: null };
|
|
3676
3886
|
let clientCtx = null;
|
|
3677
|
-
let virtualCtx = null;
|
|
3678
3887
|
let isShuttingDown = false;
|
|
3679
3888
|
let pendingClientFiles = /* @__PURE__ */ new Set();
|
|
3680
|
-
let
|
|
3681
|
-
async function buildVirtualFiles() {
|
|
3682
|
-
if (isShuttingDown) return;
|
|
3683
|
-
try {
|
|
3684
|
-
if (virtualCtx) {
|
|
3685
|
-
await virtualCtx.dispose();
|
|
3686
|
-
virtualCtx = null;
|
|
3687
|
-
}
|
|
3688
|
-
const virtualEntryPoints = {};
|
|
3689
|
-
Object.entries(virtualClientFiles).forEach(([key, value]) => {
|
|
3690
|
-
virtualEntryPoints[value.output] = key;
|
|
3691
|
-
});
|
|
3692
|
-
virtualCtx = await esbuild2.context({
|
|
3693
|
-
entryPoints: virtualEntryPoints,
|
|
3694
|
-
bundle: true,
|
|
3695
|
-
outdir: "public",
|
|
3696
|
-
platform: "browser",
|
|
3697
|
-
format: "iife",
|
|
3698
|
-
globalName: "Orca",
|
|
3699
|
-
sourcemap: config.build?.sourcemap ?? true,
|
|
3700
|
-
minify: config.build?.minify ?? false,
|
|
3701
|
-
plugins: [createVirtualModulePlugin(virtualClientFiles)],
|
|
3702
|
-
write: true
|
|
3703
|
-
});
|
|
3704
|
-
await virtualCtx.rebuild();
|
|
3705
|
-
} catch (error) {
|
|
3706
|
-
console.error("Failed to build virtual files:", error);
|
|
3707
|
-
throw error;
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3889
|
+
let rebuildTimer = null;
|
|
3710
3890
|
async function rebuildClient() {
|
|
3711
|
-
if (isShuttingDown) return;
|
|
3891
|
+
if (isShuttingDown || !hasClientFiles) return;
|
|
3712
3892
|
try {
|
|
3893
|
+
logger.debug("Scheduling client rebuild...");
|
|
3713
3894
|
if (clientCtx) {
|
|
3714
3895
|
await clientCtx.dispose();
|
|
3715
3896
|
clientCtx = null;
|
|
3716
3897
|
}
|
|
3717
|
-
|
|
3718
|
-
const entryPoints2 = Array.from(clientFiles);
|
|
3719
|
-
const graph = buildGraph(entryPoints2);
|
|
3720
|
-
clientCtx = await esbuild2.context({
|
|
3721
|
-
entryPoints: entryPoints2,
|
|
3722
|
-
bundle: true,
|
|
3723
|
-
outdir: "public",
|
|
3724
|
-
outbase: ".",
|
|
3725
|
-
platform: "browser",
|
|
3726
|
-
format: "esm",
|
|
3727
|
-
sourcemap: config.build?.sourcemap ?? true,
|
|
3728
|
-
splitting: true,
|
|
3729
|
-
minify: config.build?.minify ?? false,
|
|
3730
|
-
plugins: [
|
|
3731
|
-
...config.plugins?.map((cb) => cb(store)) || [],
|
|
3732
|
-
...config.client_plugins?.map((cb) => cb(store)) || [],
|
|
3733
|
-
useMyPlugin({
|
|
3734
|
-
graph,
|
|
3735
|
-
isServerBuild: false,
|
|
3736
|
-
onClientFound: () => {
|
|
3737
|
-
}
|
|
3738
|
-
}),
|
|
3739
|
-
{
|
|
3740
|
-
name: "client-build-logger",
|
|
3741
|
-
setup(build2) {
|
|
3742
|
-
build2.onEnd((result) => {
|
|
3743
|
-
if (result.errors.length > 0) {
|
|
3744
|
-
console.error(
|
|
3745
|
-
`Client build failed with ${result.errors.length} error(s)`
|
|
3746
|
-
);
|
|
3747
|
-
} else {
|
|
3748
|
-
console.log("Client build completed");
|
|
3749
|
-
hotReloadManager.reload();
|
|
3750
|
-
}
|
|
3751
|
-
});
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
],
|
|
3755
|
-
write: true
|
|
3756
|
-
});
|
|
3757
|
-
await clientCtx.watch();
|
|
3898
|
+
pendingClientFiles.forEach((file) => clientFiles.add(file));
|
|
3758
3899
|
pendingClientFiles.clear();
|
|
3759
|
-
|
|
3900
|
+
clientCtx = await buildClient(
|
|
3901
|
+
clientFiles,
|
|
3902
|
+
config,
|
|
3903
|
+
store,
|
|
3904
|
+
true,
|
|
3905
|
+
() => hotReloadManager?.reload(),
|
|
3906
|
+
logger
|
|
3907
|
+
);
|
|
3760
3908
|
} catch (error) {
|
|
3761
|
-
|
|
3762
|
-
|
|
3909
|
+
logger.error("Failed to rebuild client:", error);
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
function scheduleClientRebuild() {
|
|
3913
|
+
if (rebuildTimer) {
|
|
3914
|
+
clearTimeout(rebuildTimer);
|
|
3763
3915
|
}
|
|
3916
|
+
rebuildTimer = setTimeout(() => {
|
|
3917
|
+
rebuildClient();
|
|
3918
|
+
}, 100);
|
|
3764
3919
|
}
|
|
3765
|
-
async function
|
|
3766
|
-
if (
|
|
3767
|
-
|
|
3920
|
+
async function onServerReady() {
|
|
3921
|
+
if (pendingClientFiles.size > 0) {
|
|
3922
|
+
scheduleClientRebuild();
|
|
3768
3923
|
}
|
|
3769
3924
|
}
|
|
3770
3925
|
const serverCtx = await esbuild2.context({
|
|
@@ -3784,16 +3939,16 @@ async function startDevServer() {
|
|
|
3784
3939
|
onClientFound: async (filePath) => {
|
|
3785
3940
|
const isNewFile = !clientFiles.has(filePath);
|
|
3786
3941
|
if (isNewFile) {
|
|
3787
|
-
|
|
3942
|
+
logger.debug(`New client file discovered: ${filePath}`);
|
|
3788
3943
|
pendingClientFiles.add(filePath);
|
|
3789
|
-
needsClientRebuild = true;
|
|
3790
3944
|
}
|
|
3791
3945
|
}
|
|
3792
3946
|
}),
|
|
3793
3947
|
createRestartServerPlugin(
|
|
3794
3948
|
serverProcessRef,
|
|
3795
|
-
|
|
3796
|
-
hotReloadManager
|
|
3949
|
+
onServerReady,
|
|
3950
|
+
hotReloadManager,
|
|
3951
|
+
logger
|
|
3797
3952
|
)
|
|
3798
3953
|
],
|
|
3799
3954
|
write: true
|
|
@@ -3801,29 +3956,99 @@ async function startDevServer() {
|
|
|
3801
3956
|
async function shutdown() {
|
|
3802
3957
|
if (isShuttingDown) return;
|
|
3803
3958
|
isShuttingDown = true;
|
|
3804
|
-
|
|
3959
|
+
logger.info("Shutting down dev server...");
|
|
3805
3960
|
try {
|
|
3806
3961
|
if (serverProcessRef.current) {
|
|
3807
|
-
|
|
3808
|
-
await
|
|
3962
|
+
logger.debug("Stopping server process...");
|
|
3963
|
+
await waitForProcessExit(serverProcessRef.current);
|
|
3809
3964
|
}
|
|
3810
3965
|
await serverCtx.dispose();
|
|
3811
3966
|
if (clientCtx) await clientCtx.dispose();
|
|
3812
|
-
if (
|
|
3813
|
-
|
|
3814
|
-
console.log("Dev server shut down successfully");
|
|
3967
|
+
if (hotReloadManager) hotReloadManager.close();
|
|
3968
|
+
logger.info("Dev server shut down successfully");
|
|
3815
3969
|
process.exit(0);
|
|
3816
3970
|
} catch (error) {
|
|
3817
|
-
|
|
3971
|
+
logger.error("Error during shutdown:", error);
|
|
3818
3972
|
process.exit(1);
|
|
3819
3973
|
}
|
|
3820
3974
|
}
|
|
3821
3975
|
process.on("SIGINT", shutdown);
|
|
3822
3976
|
process.on("SIGTERM", shutdown);
|
|
3823
|
-
|
|
3824
|
-
|
|
3977
|
+
logger.info("Starting dev server...");
|
|
3978
|
+
if (hasClientFiles) {
|
|
3979
|
+
await buildVirtualFiles(config, logger);
|
|
3980
|
+
}
|
|
3825
3981
|
await serverCtx.watch();
|
|
3826
3982
|
}
|
|
3983
|
+
async function startBuild() {
|
|
3984
|
+
const logger = createLogger(false);
|
|
3985
|
+
const store = Store.getInstance();
|
|
3986
|
+
logger.info("Starting production build...");
|
|
3987
|
+
try {
|
|
3988
|
+
const userConfig = await loadConfig();
|
|
3989
|
+
const config = mergeConfig(getDefaultConfig(), userConfig);
|
|
3990
|
+
const hasClientFiles = await checkClientFilesExist();
|
|
3991
|
+
if (!hasClientFiles) {
|
|
3992
|
+
logger.warn(
|
|
3993
|
+
"Client files not found (src/client/client.tsx or src/client/index.html missing). Skipping client build."
|
|
3994
|
+
);
|
|
3995
|
+
}
|
|
3996
|
+
await cleanDirectories(logger);
|
|
3997
|
+
if (hasClientFiles) {
|
|
3998
|
+
await copyAndProcessHtml(null, config.htmlPreprocessor, logger);
|
|
3999
|
+
await buildVirtualFiles(config, logger);
|
|
4000
|
+
}
|
|
4001
|
+
const clientFiles = hasClientFiles ? /* @__PURE__ */ new Set(["src/client/client.tsx"]) : /* @__PURE__ */ new Set();
|
|
4002
|
+
const entryPoints = ["src/main.ts"];
|
|
4003
|
+
logger.info("Building server...");
|
|
4004
|
+
await esbuild2.build({
|
|
4005
|
+
entryPoints,
|
|
4006
|
+
bundle: true,
|
|
4007
|
+
outdir: config.build?.outDir || "dist",
|
|
4008
|
+
platform: "node",
|
|
4009
|
+
format: "esm",
|
|
4010
|
+
packages: "external",
|
|
4011
|
+
sourcemap: config.build?.sourcemap ?? false,
|
|
4012
|
+
minify: config.build?.minify ?? true,
|
|
4013
|
+
plugins: [
|
|
4014
|
+
...config.plugins?.map((cb) => cb(store)) || [],
|
|
4015
|
+
...config.server_plugins?.map((cb) => cb(store)) || [],
|
|
4016
|
+
useMyPlugin({
|
|
4017
|
+
isServerBuild: true,
|
|
4018
|
+
onClientFound: async (filePath) => {
|
|
4019
|
+
if (hasClientFiles) {
|
|
4020
|
+
clientFiles.add(filePath);
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
}),
|
|
4024
|
+
{
|
|
4025
|
+
name: "build-complete-logger",
|
|
4026
|
+
setup(build3) {
|
|
4027
|
+
build3.onEnd((result) => {
|
|
4028
|
+
if (result.errors.length > 0) {
|
|
4029
|
+
logger.error(
|
|
4030
|
+
`Server build failed with ${result.errors.length} error(s)`
|
|
4031
|
+
);
|
|
4032
|
+
} else {
|
|
4033
|
+
logger.info("Server build completed");
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
],
|
|
4039
|
+
write: true
|
|
4040
|
+
});
|
|
4041
|
+
if (hasClientFiles && clientFiles.size > 0) {
|
|
4042
|
+
logger.info(`Building ${clientFiles.size} client file(s)...`);
|
|
4043
|
+
await buildClient(clientFiles, config, store, false, void 0, logger);
|
|
4044
|
+
}
|
|
4045
|
+
logger.info("Production build completed successfully!");
|
|
4046
|
+
logger.info(`Output: dist/${hasClientFiles ? " and public/" : ""}`);
|
|
4047
|
+
} catch (error) {
|
|
4048
|
+
logger.error("Build failed:", error);
|
|
4049
|
+
process.exit(1);
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
3827
4052
|
|
|
3828
4053
|
// src/config/index.ts
|
|
3829
4054
|
var config_exports = {};
|
|
@@ -6544,8 +6769,9 @@ async function compileFiles(entryPoints) {
|
|
|
6544
6769
|
}
|
|
6545
6770
|
|
|
6546
6771
|
// src/index.ts
|
|
6772
|
+
import { fileURLToPath } from "url";
|
|
6547
6773
|
var program = new Command();
|
|
6548
|
-
program.name("pod").description("Pod cli tool").version("1.0.
|
|
6774
|
+
program.name("pod").description("Pod cli tool").version("1.0.41");
|
|
6549
6775
|
program.command("new <name> [type]").description("Start a new Orca Project").action(async (name, type) => {
|
|
6550
6776
|
const orca = async () => {
|
|
6551
6777
|
await addNew(name);
|
|
@@ -6578,6 +6804,9 @@ program.command("new <name> [type]").description("Start a new Orca Project").act
|
|
|
6578
6804
|
program.command("dev").description("Start Pod development server").action(async (opts) => {
|
|
6579
6805
|
await startDevServer();
|
|
6580
6806
|
});
|
|
6807
|
+
program.command("build").description("Start Pod build").action(async (opts) => {
|
|
6808
|
+
await startBuild();
|
|
6809
|
+
});
|
|
6581
6810
|
program.command("compile <files...>").description("Compile ts files with pod").action(async (files) => {
|
|
6582
6811
|
await compileFiles(files);
|
|
6583
6812
|
});
|
|
@@ -6609,7 +6838,10 @@ program.command("deploy").description("Deploy to a target environment").argument
|
|
|
6609
6838
|
process.exit(1);
|
|
6610
6839
|
}
|
|
6611
6840
|
});
|
|
6612
|
-
|
|
6841
|
+
var isMainModule = process.argv[1] === fileURLToPath(import.meta.url);
|
|
6842
|
+
if (isMainModule) {
|
|
6843
|
+
program.parse(process.argv);
|
|
6844
|
+
}
|
|
6613
6845
|
export {
|
|
6614
6846
|
config_exports as config,
|
|
6615
6847
|
expandMacros,
|
|
@@ -6620,8 +6852,10 @@ export {
|
|
|
6620
6852
|
macros_exports as macros,
|
|
6621
6853
|
mergeConfig,
|
|
6622
6854
|
plugins_exports as plugins,
|
|
6855
|
+
program,
|
|
6623
6856
|
resetGlobalMacroGraph,
|
|
6624
6857
|
store_exports as store,
|
|
6625
|
-
stylePlugin
|
|
6858
|
+
stylePlugin,
|
|
6859
|
+
useMyPlugin
|
|
6626
6860
|
};
|
|
6627
6861
|
//# sourceMappingURL=index.js.map
|