@kithinji/pod 1.0.30 → 1.0.32

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/main.js CHANGED
@@ -11,7 +11,7 @@ import { Command } from "commander";
11
11
  // src/dev/server.ts
12
12
  import * as esbuild2 from "esbuild";
13
13
  import { spawn } from "child_process";
14
- import * as fs6 from "fs/promises";
14
+ import * as fs7 from "fs/promises";
15
15
  import { WebSocketServer, WebSocket } from "ws";
16
16
 
17
17
  // src/config/config.ts
@@ -55,8 +55,8 @@ async function loadJsConfig(configPath) {
55
55
  }
56
56
  async function loadTsConfig(configPath) {
57
57
  try {
58
- const esbuild3 = await import("esbuild");
59
- const result = await esbuild3.build({
58
+ const esbuild4 = await import("esbuild");
59
+ const result = await esbuild4.build({
60
60
  entryPoints: [configPath],
61
61
  bundle: true,
62
62
  platform: "node",
@@ -93,7 +93,9 @@ function getDefaultConfig() {
93
93
  build: {
94
94
  outDir: "dist",
95
95
  sourcemap: true,
96
- minify: false
96
+ minify: false,
97
+ types: false,
98
+ decorators: false
97
99
  },
98
100
  plugins: [],
99
101
  client_plugins: [],
@@ -121,6 +123,7 @@ var plugins_exports = {};
121
123
  __export(plugins_exports, {
122
124
  buildGraph: () => buildGraph,
123
125
  stylePlugin: () => stylePlugin,
126
+ useCompilePlugin: () => useCompilePlugin,
124
127
  useMyPlugin: () => useMyPlugin
125
128
  });
126
129
 
@@ -137,6 +140,7 @@ __export(macros_exports, {
137
140
  expandMacros: () => expandMacros,
138
141
  extractValueFromNode: () => extractValueFromNode,
139
142
  getGlobalMacroGraph: () => getGlobalMacroGraph,
143
+ macroContext: () => macroContext,
140
144
  macroExecuter: () => macroExecuter,
141
145
  resetGlobalMacroGraph: () => resetGlobalMacroGraph
142
146
  });
@@ -353,6 +357,22 @@ var Store = class _Store {
353
357
  };
354
358
 
355
359
  // src/macros/expand_macros.ts
360
+ var currentMacroContext = null;
361
+ function macroContext() {
362
+ if (!currentMacroContext) {
363
+ throw new Error("macroContext() called outside of macro execution");
364
+ }
365
+ return currentMacroContext;
366
+ }
367
+ function withMacroContext(context2, fn) {
368
+ const previousContext = currentMacroContext;
369
+ currentMacroContext = context2;
370
+ try {
371
+ return fn();
372
+ } finally {
373
+ currentMacroContext = previousContext;
374
+ }
375
+ }
356
376
  var MacroDependencyGraph = class {
357
377
  constructor(projectRoot) {
358
378
  this.nodes = /* @__PURE__ */ new Map();
@@ -406,17 +426,17 @@ var MacroDependencyGraph = class {
406
426
  const visited = /* @__PURE__ */ new Set();
407
427
  const inProgress = /* @__PURE__ */ new Set();
408
428
  const sorted = [];
409
- const visit = (key, path16 = []) => {
429
+ const visit = (key, path17 = []) => {
410
430
  if (visited.has(key)) return;
411
431
  if (inProgress.has(key)) {
412
- const cycle = [...path16, key].join(" -> ");
432
+ const cycle = [...path17, key].join(" -> ");
413
433
  throw new Error(`Circular macro dependency detected: ${cycle}`);
414
434
  }
415
435
  const node = this.nodes.get(key);
416
436
  if (!node) return;
417
437
  inProgress.add(key);
418
438
  for (const depKey of node.dependencies) {
419
- visit(depKey, [...path16, key]);
439
+ visit(depKey, [...path17, key]);
420
440
  }
421
441
  inProgress.delete(key);
422
442
  visited.add(key);
@@ -812,7 +832,7 @@ async function expandMacros(source, filePath, projectRoot = process.cwd()) {
812
832
  macroNode.sourceFile,
813
833
  compilerOptions
814
834
  );
815
- const macroContext = {
835
+ const macroContext2 = {
816
836
  node,
817
837
  sourceFile: macroNode.sourceFile,
818
838
  ts,
@@ -832,7 +852,10 @@ async function expandMacros(source, filePath, projectRoot = process.cwd()) {
832
852
  resolveIdentifier: resolver.resolveIdentifierToNode
833
853
  };
834
854
  try {
835
- const result2 = macro(...node.arguments, macroContext);
855
+ const result2 = withMacroContext(
856
+ macroContext2,
857
+ () => macro(...node.arguments)
858
+ );
836
859
  if (!result2 || typeof result2 !== "object" || !("kind" in result2)) {
837
860
  throw new Error(`Macro '${name}' must return a TypeScript AST node`);
838
861
  }
@@ -878,7 +901,7 @@ async function expandMacros(source, filePath, projectRoot = process.cwd()) {
878
901
  sourceFile,
879
902
  compilerOptions
880
903
  );
881
- const macroContext = {
904
+ const macroContext2 = {
882
905
  node,
883
906
  sourceFile,
884
907
  ts,
@@ -898,7 +921,10 @@ async function expandMacros(source, filePath, projectRoot = process.cwd()) {
898
921
  resolveIdentifier: resolver.resolveIdentifierToNode
899
922
  };
900
923
  try {
901
- const result2 = macro(...node.arguments, macroContext);
924
+ const result2 = withMacroContext(
925
+ macroContext2,
926
+ () => macro(...node.arguments)
927
+ );
902
928
  if (!result2 || typeof result2 !== "object" || !("kind" in result2)) {
903
929
  throw new Error(
904
930
  `Macro '${name}' must return a TypeScript AST node`
@@ -1629,16 +1655,16 @@ var ASTUtilities = class {
1629
1655
  });
1630
1656
  return cloned;
1631
1657
  }
1632
- walkAndTransform(node, transform2) {
1658
+ walkAndTransform(node, transform3) {
1633
1659
  if (!node || typeof node !== "object") return;
1634
- transform2(node);
1660
+ transform3(node);
1635
1661
  for (const key in node) {
1636
1662
  if (this.shouldSkipKey(key)) continue;
1637
1663
  const value = node[key];
1638
1664
  if (Array.isArray(value)) {
1639
- value.forEach((item) => this.walkAndTransform(item, transform2));
1665
+ value.forEach((item) => this.walkAndTransform(item, transform3));
1640
1666
  } else if (value && typeof value === "object") {
1641
- this.walkAndTransform(value, transform2);
1667
+ this.walkAndTransform(value, transform3);
1642
1668
  }
1643
1669
  }
1644
1670
  }
@@ -1798,22 +1824,22 @@ var ElementTransformer = class {
1798
1824
  this.jsxUtils = jsxUtils;
1799
1825
  this.observableManager = observableManager;
1800
1826
  }
1801
- transformElement(path16, scope, context2) {
1802
- if (this.t.isJSXFragment(path16.node)) {
1827
+ transformElement(path17, scope, context2) {
1828
+ if (this.t.isJSXFragment(path17.node)) {
1803
1829
  return this.transformFragment(
1804
- path16,
1830
+ path17,
1805
1831
  scope,
1806
1832
  context2
1807
1833
  );
1808
1834
  }
1809
1835
  return this.transformJSXElement(
1810
- path16,
1836
+ path17,
1811
1837
  scope,
1812
1838
  context2
1813
1839
  );
1814
1840
  }
1815
- transformJSXElement(path16, scope, context2) {
1816
- const jsxElement = path16.node;
1841
+ transformJSXElement(path17, scope, context2) {
1842
+ const jsxElement = path17.node;
1817
1843
  const tag = this.jsxUtils.getComponentName(jsxElement.openingElement.name);
1818
1844
  const isComponent = this.jsxUtils.isComponentTag(tag);
1819
1845
  if (isComponent && tag) {
@@ -1928,7 +1954,7 @@ var ElementTransformer = class {
1928
1954
  }
1929
1955
  return { id: elId, statements };
1930
1956
  }
1931
- transformFragment(path16, scope, context2) {
1957
+ transformFragment(path17, scope, context2) {
1932
1958
  const fragId = scope.generateUidIdentifier("frag");
1933
1959
  const statements = [];
1934
1960
  statements.push(
@@ -1946,7 +1972,7 @@ var ElementTransformer = class {
1946
1972
  ])
1947
1973
  );
1948
1974
  this.processDOMChildren(
1949
- path16.node.children,
1975
+ path17.node.children,
1950
1976
  fragId,
1951
1977
  statements,
1952
1978
  scope,
@@ -2335,7 +2361,7 @@ function j2d({ types: t }) {
2335
2361
  name: "jsx-to-dom",
2336
2362
  visitor: {
2337
2363
  Program: {
2338
- exit(path16, state) {
2364
+ exit(path17, state) {
2339
2365
  if (state.helpersImported) return;
2340
2366
  const helpers = [
2341
2367
  { local: "$insert", imported: "insert" },
@@ -2346,7 +2372,7 @@ function j2d({ types: t }) {
2346
2372
  { local: "$effect", imported: "effect" }
2347
2373
  ];
2348
2374
  for (const helper of helpers) {
2349
- path16.unshiftContainer(
2375
+ path17.unshiftContainer(
2350
2376
  "body",
2351
2377
  t.importDeclaration(
2352
2378
  [
@@ -2362,10 +2388,10 @@ function j2d({ types: t }) {
2362
2388
  state.helpersImported = true;
2363
2389
  }
2364
2390
  },
2365
- ClassMethod(path16) {
2366
- if (path16.getData("processed")) return;
2391
+ ClassMethod(path17) {
2392
+ if (path17.getData("processed")) return;
2367
2393
  let hasJSX = false;
2368
- path16.traverse({
2394
+ path17.traverse({
2369
2395
  JSXElement() {
2370
2396
  hasJSX = true;
2371
2397
  },
@@ -2374,11 +2400,11 @@ function j2d({ types: t }) {
2374
2400
  }
2375
2401
  });
2376
2402
  if (!hasJSX) return;
2377
- path16.setData("processed", true);
2378
- const body = path16.node.body;
2403
+ path17.setData("processed", true);
2404
+ const body = path17.node.body;
2379
2405
  if (!t.isBlockStatement(body)) return;
2380
2406
  const observables = /* @__PURE__ */ new Map();
2381
- path16.traverse({
2407
+ path17.traverse({
2382
2408
  JSXElement(jsxPath) {
2383
2409
  observableManager.collectObservables(
2384
2410
  jsxPath.node,
@@ -2402,7 +2428,7 @@ function j2d({ types: t }) {
2402
2428
  const observableSignals = /* @__PURE__ */ new Map();
2403
2429
  const signalDeclarations = [];
2404
2430
  for (const [key, observable] of observables) {
2405
- const signalId = path16.scope.generateUidIdentifier("sig");
2431
+ const signalId = path17.scope.generateUidIdentifier("sig");
2406
2432
  observableSignals.set(key, signalId);
2407
2433
  signalDeclarations.push(
2408
2434
  t.variableDeclaration("const", [
@@ -2420,7 +2446,7 @@ function j2d({ types: t }) {
2420
2446
  astUtils.insertBeforeReturn(body.body, signalDeclarations);
2421
2447
  }
2422
2448
  const context2 = { observables, observableSignals };
2423
- path16.traverse({
2449
+ path17.traverse({
2424
2450
  JSXElement(jsxPath) {
2425
2451
  if (jsxPath.getData("processed")) return;
2426
2452
  jsxPath.setData("processed", true);
@@ -2729,8 +2755,8 @@ function stringifyType3(typeNode) {
2729
2755
  }
2730
2756
  function generateStubCode(stub) {
2731
2757
  const className = stub.name;
2732
- const build = stub.methods.find((p) => p.name == "build");
2733
- if (build == void 0) {
2758
+ const build2 = stub.methods.find((p) => p.name == "build");
2759
+ if (build2 == void 0) {
2734
2760
  throw new Error("Component has no build function");
2735
2761
  }
2736
2762
  const decoratorsStr = stub.decorators.length > 0 ? stub.decorators.join("\n") + "\n" : "";
@@ -2953,75 +2979,75 @@ async function swcTransform(source, pathStr, tsx = false, react) {
2953
2979
  resolveDir
2954
2980
  };
2955
2981
  }
2956
- function parseFileMetadata(source, path16) {
2957
- const isTsx = path16.endsWith(".tsx");
2958
- const isInteractiveFile = source.startsWith('"use interactive"') || source.startsWith("'use interactive'");
2982
+ function parseFileMetadata(source, path17) {
2983
+ const isTsx = path17.endsWith(".tsx");
2984
+ const isClientFile = source.startsWith('"use client"') || source.startsWith("'use client'");
2959
2985
  const isPublicFile = source.startsWith('"use public"') || source.startsWith("'use public'");
2960
2986
  let directive = null;
2961
- if (isInteractiveFile) directive = "interactive";
2987
+ if (isClientFile) directive = "client";
2962
2988
  else if (isPublicFile) directive = "public";
2963
2989
  return {
2964
2990
  source,
2965
- path: path16,
2991
+ path: path17,
2966
2992
  isTsx,
2967
2993
  directive,
2968
2994
  isPublicFile,
2969
- isInteractiveFile
2995
+ isClientFile
2970
2996
  };
2971
2997
  }
2972
2998
  var ServerBuildTransformer = class {
2973
- async transformPublicFile(source, path16) {
2974
- const controllerCode = generateController(path16, source);
2999
+ async transformPublicFile(source, path17) {
3000
+ const controllerCode = generateController(path17, source);
2975
3001
  if (controllerCode) {
2976
3002
  source = `${source}
2977
3003
 
2978
3004
  ${controllerCode}
2979
3005
  `;
2980
3006
  }
2981
- return swcTransform(source, path16);
3007
+ return swcTransform(source, path17);
2982
3008
  }
2983
- async transformRegularTypeScript(source, path16, isPublic) {
3009
+ async transformRegularTypeScript(source, path17, isPublic) {
2984
3010
  if (isPublic) {
2985
- return this.transformPublicFile(source, path16);
3011
+ return this.transformPublicFile(source, path17);
2986
3012
  }
2987
- return swcTransform(source, path16);
3013
+ return swcTransform(source, path17);
2988
3014
  }
2989
- async transformServerTsx(source, path16) {
2990
- return swcTransform(source, path16, true, {
3015
+ async transformServerTsx(source, path17) {
3016
+ return swcTransform(source, path17, true, {
2991
3017
  runtime: "automatic",
2992
3018
  importSource: "@kithinji/orca"
2993
3019
  });
2994
3020
  }
2995
- async transformInteractiveTsxStub(source, path16) {
2996
- const stubSource = generateServerStub(path16, source);
2997
- return swcTransform(stubSource, path16);
3021
+ async transformClientTsxStub(source, path17) {
3022
+ const stubSource = generateServerStub(path17, source);
3023
+ return swcTransform(stubSource, path17);
2998
3024
  }
2999
3025
  async process(metadata, onClientFound) {
3000
3026
  const expandedSource = await expandMacros(metadata.source, metadata.path);
3001
3027
  const expandedMetadata = { ...metadata, source: expandedSource };
3002
- const { source, path: path16, isTsx, isInteractiveFile, isPublicFile } = expandedMetadata;
3028
+ const { source, path: path17, isTsx, isClientFile, isPublicFile } = expandedMetadata;
3003
3029
  if (isTsx) {
3004
- if (isInteractiveFile) {
3005
- onClientFound(path16);
3006
- const clientCode = await this.transformInteractiveTsxStub(source, path16);
3030
+ if (isClientFile) {
3031
+ onClientFound(path17);
3032
+ const clientCode = await this.transformClientTsxStub(source, path17);
3007
3033
  const store = Store.getInstance();
3008
- store.set(path16, clientCode.contents);
3034
+ store.set(path17, clientCode.contents);
3009
3035
  return clientCode;
3010
3036
  }
3011
- return this.transformServerTsx(source, path16);
3037
+ return this.transformServerTsx(source, path17);
3012
3038
  }
3013
- return this.transformRegularTypeScript(source, path16, isPublicFile);
3039
+ return this.transformRegularTypeScript(source, path17, isPublicFile);
3014
3040
  }
3015
3041
  };
3016
3042
  var ClientBuildTransformer = class {
3017
- async transformInteractiveTsx(source, path16) {
3018
- const swcResult = await swcTransform(source, path16, true, {
3043
+ async transformClientTsx(source, path17) {
3044
+ const swcResult = await swcTransform(source, path17, true, {
3019
3045
  runtime: "preserve"
3020
3046
  });
3021
3047
  const babelResult = await babel.transformAsync(
3022
3048
  swcResult.contents,
3023
3049
  {
3024
- filename: path16,
3050
+ filename: path17,
3025
3051
  sourceType: "module",
3026
3052
  plugins: [j2d],
3027
3053
  parserOpts: {
@@ -3037,37 +3063,37 @@ var ClientBuildTransformer = class {
3037
3063
  resolveDir: swcResult.resolveDir
3038
3064
  };
3039
3065
  }
3040
- async transformServerComponent(node, source, path16) {
3041
- const scSource = generateServerComponent(path16, source);
3042
- return swcTransform(scSource, path16);
3066
+ async transformServerComponent(node, source, path17) {
3067
+ const scSource = generateServerComponent(path17, source);
3068
+ return swcTransform(scSource, path17);
3043
3069
  }
3044
- async transformPublicFileRpc(node, source, path16) {
3045
- const stubSource = generateRpcStub(path16, source);
3046
- return swcTransform(stubSource, path16);
3070
+ async transformPublicFileRpc(node, source, path17) {
3071
+ const stubSource = generateRpcStub(path17, source);
3072
+ return swcTransform(stubSource, path17);
3047
3073
  }
3048
- async transformSharedCode(source, path16) {
3049
- return swcTransform(source, path16);
3074
+ async transformSharedCode(source, path17) {
3075
+ return swcTransform(source, path17);
3050
3076
  }
3051
3077
  async process(node, metadata) {
3052
3078
  const expandedSource = await expandMacros(metadata.source, metadata.path);
3053
3079
  const expandedMetadata = { ...metadata, source: expandedSource };
3054
- const { source, path: path16, isTsx, directive } = expandedMetadata;
3080
+ const { source, path: path17, isTsx, directive } = expandedMetadata;
3055
3081
  if (isTsx) {
3056
- if (directive === "interactive") {
3057
- return this.transformInteractiveTsx(source, path16);
3082
+ if (directive === "client") {
3083
+ return this.transformClientTsx(source, path17);
3058
3084
  } else if (directive === null) {
3059
- return this.transformServerComponent(node, source, path16);
3085
+ return this.transformServerComponent(node, source, path17);
3060
3086
  } else {
3061
3087
  throw new Error(
3062
- `Unexpected directive "${directive}" for TSX file: ${path16}`
3088
+ `Unexpected directive "${directive}" for TSX file: ${path17}`
3063
3089
  );
3064
3090
  }
3065
3091
  }
3066
3092
  if (directive === "public") {
3067
- return this.transformPublicFileRpc(node, source, path16);
3093
+ return this.transformPublicFileRpc(node, source, path17);
3068
3094
  }
3069
3095
  if (directive === null) {
3070
- return this.transformSharedCode(source, path16);
3096
+ return this.transformSharedCode(source, path17);
3071
3097
  }
3072
3098
  return {
3073
3099
  contents: source,
@@ -3080,8 +3106,8 @@ function useMyPlugin(options) {
3080
3106
  const clientTransformer = new ClientBuildTransformer();
3081
3107
  return {
3082
3108
  name: "Orca",
3083
- setup(build) {
3084
- build.onLoad(
3109
+ setup(build2) {
3110
+ build2.onLoad(
3085
3111
  { filter: /\.tsx?$/ },
3086
3112
  async (args) => {
3087
3113
  const source = await fs2.readFile(args.path, "utf8");
@@ -3143,7 +3169,7 @@ function extractDirective(ast) {
3143
3169
  if (item.type === "ExpressionStatement" && item.expression.type === "StringLiteral") {
3144
3170
  const val = item.expression.value;
3145
3171
  if (val === "use public") return "public";
3146
- if (val === "use interactive") return "interactive";
3172
+ if (val === "use client") return "client";
3147
3173
  } else {
3148
3174
  break;
3149
3175
  }
@@ -3307,8 +3333,8 @@ import * as fs4 from "fs";
3307
3333
  function stylePlugin(store) {
3308
3334
  return {
3309
3335
  name: "style",
3310
- setup(build) {
3311
- build.onEnd(() => {
3336
+ setup(build2) {
3337
+ build2.onEnd(() => {
3312
3338
  const styleRules = store.get("style_rules");
3313
3339
  if (!styleRules || styleRules.length === 0) {
3314
3340
  console.log("No style rules generated");
@@ -3323,16 +3349,90 @@ function stylePlugin(store) {
3323
3349
  };
3324
3350
  }
3325
3351
 
3326
- // src/html/index.ts
3352
+ // src/plugins/compile.ts
3327
3353
  import * as fs5 from "fs/promises";
3354
+ import * as path8 from "path";
3355
+ import { transform as transform2 } from "@swc/core";
3356
+ function parseFileMetadata2(source, path17, decorators) {
3357
+ return {
3358
+ source,
3359
+ path: path17,
3360
+ decorators
3361
+ };
3362
+ }
3363
+ async function swcTransform2(source, pathStr, tsx = false, react) {
3364
+ const resolveDir = path8.dirname(pathStr);
3365
+ const swcResult = await transform2(source, {
3366
+ filename: pathStr,
3367
+ jsc: {
3368
+ parser: {
3369
+ syntax: "typescript",
3370
+ tsx,
3371
+ decorators: true
3372
+ },
3373
+ transform: {
3374
+ legacyDecorator: true,
3375
+ decoratorMetadata: true,
3376
+ react
3377
+ },
3378
+ target: "esnext"
3379
+ },
3380
+ isModule: true
3381
+ });
3382
+ return {
3383
+ contents: swcResult.code,
3384
+ loader: "js",
3385
+ resolveDir
3386
+ };
3387
+ }
3388
+ var BuildTransformer = class {
3389
+ async transformTypeScript(source, path17) {
3390
+ return swcTransform2(source, path17);
3391
+ }
3392
+ async process(metadata) {
3393
+ const expandedSource = await expandMacros(metadata.source, metadata.path);
3394
+ const expandedMetadata = { ...metadata, source: expandedSource };
3395
+ const { source, path: path17, decorators } = expandedMetadata;
3396
+ if (!decorators) {
3397
+ return {
3398
+ contents: source,
3399
+ loader: "ts"
3400
+ };
3401
+ }
3402
+ return this.transformTypeScript(source, path17);
3403
+ }
3404
+ };
3405
+ function useCompilePlugin(options) {
3406
+ const transformer = new BuildTransformer();
3407
+ return {
3408
+ name: "Orca",
3409
+ setup(build2) {
3410
+ build2.onLoad(
3411
+ { filter: /\.tsx?$/ },
3412
+ async (args) => {
3413
+ const source = await fs5.readFile(args.path, "utf8");
3414
+ const metadata = parseFileMetadata2(
3415
+ source,
3416
+ args.path,
3417
+ options.decorators
3418
+ );
3419
+ return transformer.process(metadata);
3420
+ }
3421
+ );
3422
+ }
3423
+ };
3424
+ }
3425
+
3426
+ // src/html/index.ts
3427
+ import * as fs6 from "fs/promises";
3328
3428
  var HtmlPreprocessor = class {
3329
3429
  constructor(options = {}) {
3330
3430
  this.options = options;
3331
3431
  }
3332
3432
  async processFile(inputPath, outputPath) {
3333
- const html = await fs5.readFile(inputPath, "utf-8");
3433
+ const html = await fs6.readFile(inputPath, "utf-8");
3334
3434
  const processed = await this.process(html);
3335
- await fs5.writeFile(outputPath, processed, "utf-8");
3435
+ await fs6.writeFile(outputPath, processed, "utf-8");
3336
3436
  }
3337
3437
  async process(html) {
3338
3438
  let result = html;
@@ -3469,8 +3569,8 @@ export async function navigate(event, url) {
3469
3569
  function createVirtualModulePlugin(virtualFiles) {
3470
3570
  return {
3471
3571
  name: "virtual-module",
3472
- setup(build) {
3473
- build.onResolve({ filter: /^virtual:/ }, (args) => {
3572
+ setup(build2) {
3573
+ build2.onResolve({ filter: /^virtual:/ }, (args) => {
3474
3574
  if (virtualFiles[args.path]) {
3475
3575
  return {
3476
3576
  path: args.path,
@@ -3478,7 +3578,7 @@ function createVirtualModulePlugin(virtualFiles) {
3478
3578
  };
3479
3579
  }
3480
3580
  });
3481
- build.onLoad({ filter: /.*/, namespace: "virtual" }, (args) => {
3581
+ build2.onLoad({ filter: /.*/, namespace: "virtual" }, (args) => {
3482
3582
  const virtualFile = virtualFiles[args.path];
3483
3583
  if (virtualFile) {
3484
3584
  return {
@@ -3535,7 +3635,7 @@ var HotReloadManager = class {
3535
3635
  };
3536
3636
  async function copyAndProcessHtml(hotReloadPort, preprocessorOptions) {
3537
3637
  try {
3538
- await fs6.mkdir("public", { recursive: true });
3638
+ await fs7.mkdir("public", { recursive: true });
3539
3639
  const preprocessor = new HtmlPreprocessor({
3540
3640
  transformers: [createHotReloadTransformer(hotReloadPort)],
3541
3641
  injectScripts: ["./navigate.js"],
@@ -3552,15 +3652,15 @@ async function copyAndProcessHtml(hotReloadPort, preprocessorOptions) {
3552
3652
  }
3553
3653
  async function cleanDirectories() {
3554
3654
  await Promise.all([
3555
- fs6.rm("dist", { recursive: true, force: true }),
3556
- fs6.rm("public", { recursive: true, force: true })
3655
+ fs7.rm("dist", { recursive: true, force: true }),
3656
+ fs7.rm("public", { recursive: true, force: true })
3557
3657
  ]);
3558
3658
  }
3559
3659
  function createRestartServerPlugin(serverProcess, onServerBuildComplete, hotReloadManager) {
3560
3660
  return {
3561
3661
  name: "restart-server",
3562
- setup(build) {
3563
- build.onEnd((result) => {
3662
+ setup(build2) {
3663
+ build2.onEnd((result) => {
3564
3664
  if (result.errors.length > 0) {
3565
3665
  console.error(
3566
3666
  `Server build failed with ${result.errors.length} error(s)`
@@ -3661,8 +3761,8 @@ async function startDevServer() {
3661
3761
  }),
3662
3762
  {
3663
3763
  name: "client-build-logger",
3664
- setup(build) {
3665
- build.onEnd((result) => {
3764
+ setup(build2) {
3765
+ build2.onEnd((result) => {
3666
3766
  if (result.errors.length > 0) {
3667
3767
  console.error(
3668
3768
  `Client build failed with ${result.errors.length} error(s)`
@@ -3701,6 +3801,7 @@ async function startDevServer() {
3701
3801
  minify: config.build?.minify ?? false,
3702
3802
  plugins: [
3703
3803
  ...config.plugins?.map((cb) => cb(store)) || [],
3804
+ ...config.server_plugins?.map((cb) => cb(store)) || [],
3704
3805
  useMyPlugin({
3705
3806
  isServerBuild: true,
3706
3807
  onClientFound: async (filePath) => {
@@ -3756,8 +3857,8 @@ __export(config_exports, {
3756
3857
  });
3757
3858
 
3758
3859
  // src/add/component/component.ts
3759
- import * as fs7 from "fs";
3760
- import * as path8 from "path";
3860
+ import * as fs8 from "fs";
3861
+ import * as path9 from "path";
3761
3862
  import * as ts2 from "typescript";
3762
3863
  var ComponentDefinition = class {
3763
3864
  };
@@ -3768,7 +3869,7 @@ var ButtonComponent = class extends ComponentDefinition {
3768
3869
  this.dependencies = [];
3769
3870
  }
3770
3871
  generate() {
3771
- return `"use interactive";
3872
+ return `"use client";
3772
3873
 
3773
3874
  import { Component, JSX } from "@kithinji/orca";
3774
3875
 
@@ -3796,7 +3897,7 @@ var InputComponent = class extends ComponentDefinition {
3796
3897
  this.dependencies = [];
3797
3898
  }
3798
3899
  generate() {
3799
- return `"use interactive";
3900
+ return `"use client";
3800
3901
 
3801
3902
  import { Component } from "@kithinji/orca";
3802
3903
 
@@ -3818,7 +3919,7 @@ var FormComponent = class extends ComponentDefinition {
3818
3919
  this.dependencies = ["button", "input"];
3819
3920
  }
3820
3921
  generate() {
3821
- return `"use interactive";
3922
+ return `"use client";
3822
3923
 
3823
3924
  import { Component } from "@kithinji/orca";
3824
3925
  import { Button } from "./button.component";
@@ -3849,7 +3950,7 @@ var CardComponent = class extends ComponentDefinition {
3849
3950
  this.dependencies = ["button"];
3850
3951
  }
3851
3952
  generate() {
3852
- return `"use interactive";
3953
+ return `"use client";
3853
3954
 
3854
3955
  import { Component } from "@kithinji/orca";
3855
3956
  import { Button } from "./button.component";
@@ -3923,40 +4024,40 @@ Processing dependencies for "${name}": [${component.dependencies.join(
3923
4024
  addComponent(dependency, processedComponents);
3924
4025
  }
3925
4026
  }
3926
- const componentModulePath = path8.join(
4027
+ const componentModulePath = path9.join(
3927
4028
  process.cwd(),
3928
4029
  "src/component/component.module.ts"
3929
4030
  );
3930
- const componentPath = path8.join(
4031
+ const componentPath = path9.join(
3931
4032
  process.cwd(),
3932
4033
  `src/component/component/${name}.component.tsx`
3933
4034
  );
3934
- const componentDir = path8.dirname(componentPath);
3935
- const appModulePath = path8.join(process.cwd(), "src/app/app.module.ts");
3936
- if (!fs7.existsSync(componentModulePath)) {
3937
- const moduleDir = path8.dirname(componentModulePath);
3938
- if (!fs7.existsSync(moduleDir)) {
3939
- fs7.mkdirSync(moduleDir, { recursive: true });
4035
+ const componentDir = path9.dirname(componentPath);
4036
+ const appModulePath = path9.join(process.cwd(), "src/app/app.module.ts");
4037
+ if (!fs8.existsSync(componentModulePath)) {
4038
+ const moduleDir = path9.dirname(componentModulePath);
4039
+ if (!fs8.existsSync(moduleDir)) {
4040
+ fs8.mkdirSync(moduleDir, { recursive: true });
3940
4041
  }
3941
- fs7.writeFileSync(componentModulePath, createModule(), "utf-8");
4042
+ fs8.writeFileSync(componentModulePath, createModule(), "utf-8");
3942
4043
  }
3943
- if (!fs7.existsSync(componentDir)) {
3944
- fs7.mkdirSync(componentDir, { recursive: true });
4044
+ if (!fs8.existsSync(componentDir)) {
4045
+ fs8.mkdirSync(componentDir, { recursive: true });
3945
4046
  }
3946
- if (!fs7.existsSync(componentPath)) {
3947
- fs7.writeFileSync(componentPath, component.generate(), "utf-8");
4047
+ if (!fs8.existsSync(componentPath)) {
4048
+ fs8.writeFileSync(componentPath, component.generate(), "utf-8");
3948
4049
  console.log(`Created ${name}.component.tsx`);
3949
4050
  } else {
3950
4051
  console.log(`${name}.component.tsx already exists, skipping file creation`);
3951
4052
  }
3952
- const moduleContent = fs7.readFileSync(componentModulePath, "utf-8");
4053
+ const moduleContent = fs8.readFileSync(componentModulePath, "utf-8");
3953
4054
  const updatedModule = updateModuleWithComponent(moduleContent, name);
3954
- fs7.writeFileSync(componentModulePath, updatedModule, "utf-8");
3955
- if (fs7.existsSync(appModulePath)) {
3956
- const appModuleContent = fs7.readFileSync(appModulePath, "utf-8");
4055
+ fs8.writeFileSync(componentModulePath, updatedModule, "utf-8");
4056
+ if (fs8.existsSync(appModulePath)) {
4057
+ const appModuleContent = fs8.readFileSync(appModulePath, "utf-8");
3957
4058
  const updatedAppModule = ensureComponentModuleImported(appModuleContent);
3958
4059
  if (updatedAppModule !== appModuleContent) {
3959
- fs7.writeFileSync(appModulePath, updatedAppModule, "utf-8");
4060
+ fs8.writeFileSync(appModulePath, updatedAppModule, "utf-8");
3960
4061
  }
3961
4062
  }
3962
4063
  }
@@ -4142,28 +4243,28 @@ function toPascalCase(str) {
4142
4243
  }
4143
4244
 
4144
4245
  // src/utils/create.ts
4145
- import * as fs8 from "fs";
4146
- import * as path9 from "path";
4246
+ import * as fs9 from "fs";
4247
+ import * as path10 from "path";
4147
4248
  function createStructure(basePath, entry) {
4148
- fs8.mkdirSync(basePath, { recursive: true });
4249
+ fs9.mkdirSync(basePath, { recursive: true });
4149
4250
  entry.files?.forEach((file) => {
4150
- fs8.writeFileSync(path9.join(basePath, file.name), file.content);
4251
+ fs9.writeFileSync(path10.join(basePath, file.name), file.content);
4151
4252
  });
4152
4253
  entry.dirs?.forEach((dir) => {
4153
- const dirPath = path9.join(basePath, dir.name || "");
4254
+ const dirPath = path10.join(basePath, dir.name || "");
4154
4255
  createStructure(dirPath, dir);
4155
4256
  });
4156
4257
  }
4157
4258
 
4158
4259
  // src/add/new/index.ts
4159
- import path11 from "path";
4260
+ import path12 from "path";
4160
4261
 
4161
4262
  // src/add/module/module.ts
4162
- import * as path10 from "path";
4163
- import * as fs9 from "fs";
4263
+ import * as path11 from "path";
4264
+ import * as fs10 from "fs";
4164
4265
  import * as ts3 from "typescript";
4165
4266
  function addFeature(name) {
4166
- const featureDir = path10.join(process.cwd(), "src", "features", name);
4267
+ const featureDir = path11.join(process.cwd(), "src", "features", name);
4167
4268
  addModule(name, featureDir);
4168
4269
  updateFeaturesIndex(name);
4169
4270
  updateAppModule(name);
@@ -4215,7 +4316,7 @@ function addModule(name, baseDir, root) {
4215
4316
  createStructure(baseDir, structure);
4216
4317
  }
4217
4318
  function updateFeaturesIndex(featureName) {
4218
- const featuresIndexPath = path10.join(
4319
+ const featuresIndexPath = path11.join(
4219
4320
  process.cwd(),
4220
4321
  "src",
4221
4322
  "features",
@@ -4223,8 +4324,8 @@ function updateFeaturesIndex(featureName) {
4223
4324
  );
4224
4325
  const moduleName = toPascalCase(featureName + "_Module");
4225
4326
  const importPath = `./${featureName}/${featureName}.module`;
4226
- if (fs9.existsSync(featuresIndexPath)) {
4227
- let content = fs9.readFileSync(featuresIndexPath, "utf-8");
4327
+ if (fs10.existsSync(featuresIndexPath)) {
4328
+ let content = fs10.readFileSync(featuresIndexPath, "utf-8");
4228
4329
  const sourceFile = ts3.createSourceFile(
4229
4330
  "index.ts",
4230
4331
  content,
@@ -4250,24 +4351,24 @@ function updateFeaturesIndex(featureName) {
4250
4351
  }
4251
4352
  const exportStatement = `export { ${moduleName} } from "${importPath}";
4252
4353
  `;
4253
- fs9.appendFileSync(featuresIndexPath, exportStatement);
4354
+ fs10.appendFileSync(featuresIndexPath, exportStatement);
4254
4355
  } else {
4255
- const featuresDir = path10.dirname(featuresIndexPath);
4256
- if (!fs9.existsSync(featuresDir)) {
4257
- fs9.mkdirSync(featuresDir, { recursive: true });
4356
+ const featuresDir = path11.dirname(featuresIndexPath);
4357
+ if (!fs10.existsSync(featuresDir)) {
4358
+ fs10.mkdirSync(featuresDir, { recursive: true });
4258
4359
  }
4259
4360
  const exportStatement = `export { ${moduleName} } from "${importPath}";
4260
4361
  `;
4261
- fs9.writeFileSync(featuresIndexPath, exportStatement, "utf-8");
4362
+ fs10.writeFileSync(featuresIndexPath, exportStatement, "utf-8");
4262
4363
  }
4263
4364
  }
4264
4365
  function updateAppModule(featureName) {
4265
- const appModulePath = path10.join(process.cwd(), "src", "app", "app.module.ts");
4266
- if (!fs9.existsSync(appModulePath)) {
4366
+ const appModulePath = path11.join(process.cwd(), "src", "app", "app.module.ts");
4367
+ if (!fs10.existsSync(appModulePath)) {
4267
4368
  return;
4268
4369
  }
4269
4370
  const moduleName = toPascalCase(featureName + "_Module");
4270
- let content = fs9.readFileSync(appModulePath, "utf-8");
4371
+ let content = fs10.readFileSync(appModulePath, "utf-8");
4271
4372
  const sourceFile = ts3.createSourceFile(
4272
4373
  "app.module.ts",
4273
4374
  content,
@@ -4291,7 +4392,7 @@ function updateAppModule(featureName) {
4291
4392
  });
4292
4393
  if (hasImport) {
4293
4394
  content = addToModuleImportsArray(content, sourceFile, moduleName);
4294
- fs9.writeFileSync(appModulePath, content, "utf-8");
4395
+ fs10.writeFileSync(appModulePath, content, "utf-8");
4295
4396
  return;
4296
4397
  }
4297
4398
  let lastImportEnd = 0;
@@ -4310,7 +4411,7 @@ function updateAppModule(featureName) {
4310
4411
  true
4311
4412
  );
4312
4413
  content = addToModuleImportsArray(content, newSourceFile, moduleName);
4313
- fs9.writeFileSync(appModulePath, content, "utf-8");
4414
+ fs10.writeFileSync(appModulePath, content, "utf-8");
4314
4415
  }
4315
4416
  function addToModuleImportsArray(content, sourceFile, moduleName) {
4316
4417
  let decoratorNode;
@@ -4607,7 +4708,7 @@ function createListComponent(name) {
4607
4708
  const componentName = toPascalCase(name + "_List");
4608
4709
  const serviceName = toPascalCase(name + "_Service");
4609
4710
  const serviceVar = toCamelCase(name + "_Service");
4610
- return `"use interactive";
4711
+ return `"use client";
4611
4712
 
4612
4713
  import { Component } from "@kithinji/orca";
4613
4714
  import { ${serviceName} } from "../${name}.service";
@@ -4637,7 +4738,7 @@ export class ${componentName} {
4637
4738
 
4638
4739
  // src/add/new/index.ts
4639
4740
  function addNew(name) {
4640
- const baseDir = path11.join(process.cwd(), name);
4741
+ const baseDir = path12.join(process.cwd(), name);
4641
4742
  const structure = {
4642
4743
  files: [
4643
4744
  { name: "package.json", content: genPackageJson(name) },
@@ -4664,7 +4765,7 @@ function addNew(name) {
4664
4765
  ]
4665
4766
  };
4666
4767
  createStructure(baseDir, structure);
4667
- const appDir = path11.join(process.cwd(), name, "src", "app");
4768
+ const appDir = path12.join(process.cwd(), name, "src", "app");
4668
4769
  addModule("app", appDir, true);
4669
4770
  process.chdir(baseDir);
4670
4771
  addComponent("button");
@@ -4740,6 +4841,7 @@ build
4740
4841
  *.log
4741
4842
  .env
4742
4843
  .DS_Store
4844
+ public
4743
4845
  `;
4744
4846
  }
4745
4847
  function genEnv() {
@@ -4763,7 +4865,7 @@ function genIndexHtml(name) {
4763
4865
  `;
4764
4866
  }
4765
4867
  function genClientTsx() {
4766
- return `"use interactive";
4868
+ return `"use client";
4767
4869
 
4768
4870
  import {
4769
4871
  Module,
@@ -4816,10 +4918,10 @@ bootstrap();
4816
4918
  }
4817
4919
 
4818
4920
  // src/add/ts/index.ts
4819
- import path12 from "path";
4921
+ import path13 from "path";
4820
4922
  import prompts from "prompts";
4821
4923
  async function addTs(name) {
4822
- const baseDir = path12.join(process.cwd(), name);
4924
+ const baseDir = path13.join(process.cwd(), name);
4823
4925
  const response = await prompts({
4824
4926
  type: "select",
4825
4927
  name: "target",
@@ -5197,21 +5299,21 @@ console.log('Running in Node.js environment');
5197
5299
  }
5198
5300
 
5199
5301
  // src/main.ts
5200
- import path15 from "path";
5201
- import { execSync } from "child_process";
5302
+ import path16 from "path";
5303
+ import { execSync as execSync2 } from "child_process";
5202
5304
 
5203
5305
  // src/docker/docker.ts
5204
- import fs10 from "fs-extra";
5205
- import path13 from "path";
5306
+ import fs11 from "fs-extra";
5307
+ import path14 from "path";
5206
5308
  import prompts2 from "prompts";
5207
5309
  import yaml from "js-yaml";
5208
5310
  async function dockerize(env = "prod") {
5209
5311
  const cwd = process.cwd();
5210
- const packageJsonPath = path13.join(cwd, "package.json");
5211
- if (!fs10.existsSync(packageJsonPath)) {
5312
+ const packageJsonPath = path14.join(cwd, "package.json");
5313
+ if (!fs11.existsSync(packageJsonPath)) {
5212
5314
  throw new Error("package.json not found. Are you in a Pod project?");
5213
5315
  }
5214
- const packageJson = await fs10.readJSON(packageJsonPath);
5316
+ const packageJson = await fs11.readJSON(packageJsonPath);
5215
5317
  const projectName = packageJson.name;
5216
5318
  const detectedServices = detectServices(packageJson);
5217
5319
  const selectedServices = await selectServices(detectedServices);
@@ -5251,31 +5353,31 @@ async function selectServices(detected) {
5251
5353
  return detected.filter((s) => response.services.includes(s.name));
5252
5354
  }
5253
5355
  async function restructureProject(cwd, projectName) {
5254
- const nestedDir = path13.join(cwd, projectName);
5255
- if (fs10.existsSync(nestedDir)) {
5356
+ const nestedDir = path14.join(cwd, projectName);
5357
+ if (fs11.existsSync(nestedDir)) {
5256
5358
  console.log("\u26A0\uFE0F Project already restructured, skipping...");
5257
5359
  return;
5258
5360
  }
5259
- await fs10.ensureDir(nestedDir);
5260
- const items = await fs10.readdir(cwd);
5361
+ await fs11.ensureDir(nestedDir);
5362
+ const items = await fs11.readdir(cwd);
5261
5363
  const toMove = items.filter((item) => item !== projectName);
5262
5364
  for (const item of toMove) {
5263
- const src = path13.join(cwd, item);
5264
- const dest = path13.join(nestedDir, item);
5265
- await fs10.move(src, dest, { overwrite: true });
5365
+ const src = path14.join(cwd, item);
5366
+ const dest = path14.join(nestedDir, item);
5367
+ await fs11.move(src, dest, { overwrite: true });
5266
5368
  }
5267
- const envSrc = path13.join(nestedDir, ".env");
5268
- const envDest = path13.join(cwd, ".env");
5269
- if (fs10.existsSync(envSrc)) {
5270
- await fs10.move(envSrc, envDest, { overwrite: true });
5369
+ const envSrc = path14.join(nestedDir, ".env");
5370
+ const envDest = path14.join(cwd, ".env");
5371
+ if (fs11.existsSync(envSrc)) {
5372
+ await fs11.move(envSrc, envDest, { overwrite: true });
5271
5373
  }
5272
5374
  }
5273
5375
  async function writeEnvVars(cwd, services, env) {
5274
- const envPath = path13.join(cwd, ".env");
5376
+ const envPath = path14.join(cwd, ".env");
5275
5377
  let existingEnv = {};
5276
5378
  let existingContent = "";
5277
- if (fs10.existsSync(envPath)) {
5278
- existingContent = await fs10.readFile(envPath, "utf8");
5379
+ if (fs11.existsSync(envPath)) {
5380
+ existingContent = await fs11.readFile(envPath, "utf8");
5279
5381
  existingEnv = parseEnvFile(existingContent);
5280
5382
  }
5281
5383
  const newVars = [];
@@ -5304,7 +5406,7 @@ async function writeEnvVars(cwd, services, env) {
5304
5406
  if (newVars.length > 0) {
5305
5407
  const separator = existingContent && !existingContent.endsWith("\n") ? "\n" : "";
5306
5408
  const newContent = existingContent + separator + (existingContent ? "\n" : "") + newVars.join("\n") + "\n";
5307
- await fs10.writeFile(envPath, newContent);
5409
+ await fs11.writeFile(envPath, newContent);
5308
5410
  console.log(
5309
5411
  `\u2705 Added ${newVars.length} new environment variable(s) to .env`
5310
5412
  );
@@ -5328,8 +5430,8 @@ function parseEnvFile(content) {
5328
5430
  return env;
5329
5431
  }
5330
5432
  async function createDockerfile(cwd, projectName) {
5331
- const dockerfilePath = path13.join(cwd, projectName, "Dockerfile");
5332
- const dockerignorePath = path13.join(cwd, projectName, ".dockerignore");
5433
+ const dockerfilePath = path14.join(cwd, projectName, "Dockerfile");
5434
+ const dockerignorePath = path14.join(cwd, projectName, ".dockerignore");
5333
5435
  const dockerfile = `FROM node:18-alpine
5334
5436
 
5335
5437
  WORKDIR /app
@@ -5400,8 +5502,8 @@ docker-compose*.yml
5400
5502
  tmp
5401
5503
  temp
5402
5504
  `;
5403
- await fs10.writeFile(dockerfilePath, dockerfile);
5404
- await fs10.writeFile(dockerignorePath, dockerignore);
5505
+ await fs11.writeFile(dockerfilePath, dockerfile);
5506
+ await fs11.writeFile(dockerignorePath, dockerignore);
5405
5507
  }
5406
5508
  async function createDeployfile(cwd, projectName) {
5407
5509
  const deployFile = `name: ${projectName}
@@ -5519,8 +5621,8 @@ targets:
5519
5621
  find *backup_path -name "backup-*.tar.gz" -mtime +7 -delete
5520
5622
  docker image prune -af --filter "until=24h"
5521
5623
  `;
5522
- const deployFilePath = path13.join(cwd, "pod.deploy.yml");
5523
- await fs10.writeFile(deployFilePath, deployFile);
5624
+ const deployFilePath = path14.join(cwd, "pod.deploy.yml");
5625
+ await fs11.writeFile(deployFilePath, deployFile);
5524
5626
  }
5525
5627
  async function setupProduction(cwd, projectName, services) {
5526
5628
  const compose = {
@@ -5590,17 +5692,17 @@ async function setupProduction(cwd, projectName, services) {
5590
5692
  }
5591
5693
  compose.services[projectName].depends_on.push(service.name);
5592
5694
  }
5593
- const composePath = path13.join(cwd, "docker-compose.yml");
5594
- await fs10.writeFile(
5695
+ const composePath = path14.join(cwd, "docker-compose.yml");
5696
+ await fs11.writeFile(
5595
5697
  composePath,
5596
5698
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
5597
5699
  );
5598
5700
  }
5599
5701
  async function setupDevelopment(cwd, projectName, services) {
5600
- const existingCompose = path13.join(cwd, "docker-compose.yml");
5702
+ const existingCompose = path14.join(cwd, "docker-compose.yml");
5601
5703
  let existingServices = [];
5602
- if (fs10.existsSync(existingCompose)) {
5603
- const content = await fs10.readFile(existingCompose, "utf8");
5704
+ if (fs11.existsSync(existingCompose)) {
5705
+ const content = await fs11.readFile(existingCompose, "utf8");
5604
5706
  const existing = yaml.load(content);
5605
5707
  if (existing.services) {
5606
5708
  existingServices = Object.keys(existing.services).filter((s) => ["postgres", "mysql", "redis", "mongodb"].includes(s)).map((name) => ({ name }));
@@ -5669,15 +5771,15 @@ async function setupDevelopment(cwd, projectName, services) {
5669
5771
  };
5670
5772
  compose.services[projectName].depends_on.push(tunnelName);
5671
5773
  }
5672
- const devComposePath = path13.join(cwd, "docker-compose.dev.yml");
5673
- await fs10.writeFile(
5774
+ const devComposePath = path14.join(cwd, "docker-compose.dev.yml");
5775
+ await fs11.writeFile(
5674
5776
  devComposePath,
5675
5777
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
5676
5778
  );
5677
5779
  }
5678
5780
  async function createTunnelService(projectDir, serviceName) {
5679
- const tunnelDir = path13.join(projectDir, `${serviceName}-tunnel`);
5680
- await fs10.ensureDir(tunnelDir);
5781
+ const tunnelDir = path14.join(projectDir, `${serviceName}-tunnel`);
5782
+ await fs11.ensureDir(tunnelDir);
5681
5783
  const dockerfile = `FROM alpine:latest
5682
5784
 
5683
5785
  RUN apk add --no-cache openssh-client
@@ -5705,8 +5807,8 @@ ssh -i $SSH_KEY \\
5705
5807
  -o ServerAliveInterval=60 \\
5706
5808
  $REMOTE_HOST
5707
5809
  `;
5708
- await fs10.writeFile(path13.join(tunnelDir, "Dockerfile"), dockerfile);
5709
- await fs10.writeFile(path13.join(tunnelDir, "tunnel.sh"), tunnelScript);
5810
+ await fs11.writeFile(path14.join(tunnelDir, "Dockerfile"), dockerfile);
5811
+ await fs11.writeFile(path14.join(tunnelDir, "tunnel.sh"), tunnelScript);
5710
5812
  }
5711
5813
  function getServiceConfig(serviceName) {
5712
5814
  const configs = {
@@ -5816,9 +5918,9 @@ function printNextSteps(projectName, env, services) {
5816
5918
  }
5817
5919
 
5818
5920
  // src/deploy/deploy.ts
5819
- import fs11 from "fs-extra";
5921
+ import fs12 from "fs-extra";
5820
5922
  import yaml2 from "js-yaml";
5821
- import path14 from "path";
5923
+ import path15 from "path";
5822
5924
  import os from "os";
5823
5925
  import { NodeSSH } from "node-ssh";
5824
5926
  import chalk from "chalk";
@@ -5849,7 +5951,7 @@ function deepInterpolate(obj, context2) {
5849
5951
  }
5850
5952
  function expandTilde(fp) {
5851
5953
  if (!fp || typeof fp !== "string") return fp;
5852
- return fp.startsWith("~/") ? path14.join(os.homedir(), fp.slice(2)) : fp;
5954
+ return fp.startsWith("~/") ? path15.join(os.homedir(), fp.slice(2)) : fp;
5853
5955
  }
5854
5956
  function resolveLocalPaths(obj, cwd) {
5855
5957
  if (Array.isArray(obj)) {
@@ -5861,7 +5963,7 @@ function resolveLocalPaths(obj, cwd) {
5861
5963
  const isLocalPathKey = key === "keyPath" || key === "source";
5862
5964
  if (isLocalPathKey && typeof value === "string") {
5863
5965
  const expanded = expandTilde(value);
5864
- result[key] = path14.isAbsolute(expanded) ? expanded : path14.resolve(cwd, expanded);
5966
+ result[key] = path15.isAbsolute(expanded) ? expanded : path15.resolve(cwd, expanded);
5865
5967
  } else {
5866
5968
  result[key] = resolveLocalPaths(value, cwd);
5867
5969
  }
@@ -6044,7 +6146,7 @@ var SSHStrategy = class {
6044
6146
  const trimmed = cmd.trim();
6045
6147
  if (trimmed.startsWith("cd ")) {
6046
6148
  const newPath = trimmed.replace("cd ", "").trim();
6047
- this.currentDir = path14.posix.resolve(this.currentDir, newPath);
6149
+ this.currentDir = path15.posix.resolve(this.currentDir, newPath);
6048
6150
  if (!silent) console.log(chalk.gray(` [SSH Path: ${this.currentDir}]`));
6049
6151
  return { stdout: "", stderr: "", code: 0 };
6050
6152
  }
@@ -6072,13 +6174,13 @@ STDERR: ${result.stderr}`);
6072
6174
  }
6073
6175
  }
6074
6176
  async uploadContent(remotePath, content) {
6075
- const localTmp = path14.join(os.tmpdir(), `pod_tmp_${Date.now()}`);
6076
- fs11.writeFileSync(localTmp, content);
6177
+ const localTmp = path15.join(os.tmpdir(), `pod_tmp_${Date.now()}`);
6178
+ fs12.writeFileSync(localTmp, content);
6077
6179
  try {
6078
6180
  await this.ssh.execCommand(`mkdir -p $(dirname ${remotePath})`);
6079
6181
  await this.ssh.putFile(localTmp, remotePath);
6080
6182
  } finally {
6081
- if (fs11.existsSync(localTmp)) fs11.unlinkSync(localTmp);
6183
+ if (fs12.existsSync(localTmp)) fs12.unlinkSync(localTmp);
6082
6184
  }
6083
6185
  }
6084
6186
  async readJson(remotePath) {
@@ -6093,7 +6195,7 @@ STDERR: ${result.stderr}`);
6093
6195
  const putOptions = { recursive: true, concurrency: 10 };
6094
6196
  if (exclude?.length) {
6095
6197
  putOptions.validate = (filePath) => {
6096
- const relative = path14.relative(source, filePath);
6198
+ const relative = path15.relative(source, filePath);
6097
6199
  if (relative === "") return true;
6098
6200
  return !exclude.some((pattern) => {
6099
6201
  if (pattern.endsWith("/")) {
@@ -6125,7 +6227,7 @@ var LocalStrategy = class {
6125
6227
  const trimmed = cmd.trim();
6126
6228
  if (trimmed.startsWith("cd ")) {
6127
6229
  const newPath = trimmed.replace("cd ", "").trim();
6128
- this.currentDir = path14.resolve(this.currentDir, newPath);
6230
+ this.currentDir = path15.resolve(this.currentDir, newPath);
6129
6231
  if (!silent) console.log(chalk.gray(` [Local Path: ${this.currentDir}]`));
6130
6232
  return { stdout: "", stderr: "", code: 0 };
6131
6233
  }
@@ -6148,29 +6250,29 @@ STDERR: ${err.stderr || err.message}`
6148
6250
  }
6149
6251
  async runScript(name, content, context2) {
6150
6252
  const interpolated = interpolate(content, context2);
6151
- const scriptPath = path14.join(
6253
+ const scriptPath = path15.join(
6152
6254
  os.tmpdir(),
6153
6255
  `pod_script_${name}_${Date.now()}.sh`
6154
6256
  );
6155
- fs11.writeFileSync(scriptPath, interpolated);
6156
- fs11.chmodSync(scriptPath, "755");
6257
+ fs12.writeFileSync(scriptPath, interpolated);
6258
+ fs12.chmodSync(scriptPath, "755");
6157
6259
  try {
6158
6260
  await this.runCommand(scriptPath);
6159
6261
  } finally {
6160
- if (fs11.existsSync(scriptPath)) fs11.unlinkSync(scriptPath);
6262
+ if (fs12.existsSync(scriptPath)) fs12.unlinkSync(scriptPath);
6161
6263
  }
6162
6264
  }
6163
6265
  async uploadContent(localPath, content) {
6164
- const dir = path14.dirname(localPath);
6165
- if (!fs11.existsSync(dir)) {
6166
- fs11.mkdirSync(dir, { recursive: true });
6266
+ const dir = path15.dirname(localPath);
6267
+ if (!fs12.existsSync(dir)) {
6268
+ fs12.mkdirSync(dir, { recursive: true });
6167
6269
  }
6168
- fs11.writeFileSync(localPath, content);
6270
+ fs12.writeFileSync(localPath, content);
6169
6271
  }
6170
6272
  async readJson(localPath) {
6171
6273
  try {
6172
- if (!fs11.existsSync(localPath)) return null;
6173
- const content = fs11.readFileSync(localPath, "utf8");
6274
+ if (!fs12.existsSync(localPath)) return null;
6275
+ const content = fs12.readFileSync(localPath, "utf8");
6174
6276
  return JSON.parse(content);
6175
6277
  } catch {
6176
6278
  return null;
@@ -6178,8 +6280,8 @@ STDERR: ${err.stderr || err.message}`
6178
6280
  }
6179
6281
  async syncDirectory(source, destination, exclude) {
6180
6282
  console.log(chalk.gray(` Copying ${source} \u2192 ${destination}`));
6181
- if (!fs11.existsSync(destination)) {
6182
- fs11.mkdirSync(destination, { recursive: true });
6283
+ if (!fs12.existsSync(destination)) {
6284
+ fs12.mkdirSync(destination, { recursive: true });
6183
6285
  }
6184
6286
  const shouldExclude = (relativePath) => {
6185
6287
  if (!exclude?.length) return false;
@@ -6196,19 +6298,19 @@ STDERR: ${err.stderr || err.message}`
6196
6298
  });
6197
6299
  };
6198
6300
  const copyRecursive = (src, dest) => {
6199
- const entries = fs11.readdirSync(src, { withFileTypes: true });
6301
+ const entries = fs12.readdirSync(src, { withFileTypes: true });
6200
6302
  for (const entry of entries) {
6201
- const srcPath = path14.join(src, entry.name);
6202
- const destPath = path14.join(dest, entry.name);
6203
- const relativePath = path14.relative(source, srcPath);
6303
+ const srcPath = path15.join(src, entry.name);
6304
+ const destPath = path15.join(dest, entry.name);
6305
+ const relativePath = path15.relative(source, srcPath);
6204
6306
  if (shouldExclude(relativePath)) continue;
6205
6307
  if (entry.isDirectory()) {
6206
- if (!fs11.existsSync(destPath)) {
6207
- fs11.mkdirSync(destPath, { recursive: true });
6308
+ if (!fs12.existsSync(destPath)) {
6309
+ fs12.mkdirSync(destPath, { recursive: true });
6208
6310
  }
6209
6311
  copyRecursive(srcPath, destPath);
6210
6312
  } else {
6211
- fs11.copyFileSync(srcPath, destPath);
6313
+ fs12.copyFileSync(srcPath, destPath);
6212
6314
  }
6213
6315
  }
6214
6316
  };
@@ -6371,7 +6473,7 @@ var OperationHandler = class {
6371
6473
  async function deploy(targetName, options) {
6372
6474
  const cwd = process.cwd();
6373
6475
  const rawConfig = yaml2.load(
6374
- fs11.readFileSync(path14.join(cwd, "pod.deploy.yml"), "utf8"),
6476
+ fs12.readFileSync(path15.join(cwd, "pod.deploy.yml"), "utf8"),
6375
6477
  { schema: yaml2.DEFAULT_SCHEMA }
6376
6478
  );
6377
6479
  const rawTarget = rawConfig.targets?.[targetName];
@@ -6391,7 +6493,7 @@ Pod Deploy: ${rawConfig.name} v${rawConfig.version} \u2192 ${targetName}
6391
6493
  const strategy = StrategyFactory.create(target, cwd);
6392
6494
  try {
6393
6495
  await strategy.connect();
6394
- const lockPath = target.deployPath ? path14.posix.join(target.deployPath, "pod-lock.json") : path14.join(cwd, "pod-lock.json");
6496
+ const lockPath = target.deployPath ? path15.posix.join(target.deployPath, "pod-lock.json") : path15.join(cwd, "pod-lock.json");
6395
6497
  let lock = await strategy.readJson(lockPath) || {
6396
6498
  ensures: {},
6397
6499
  once_actions: []
@@ -6432,27 +6534,60 @@ Deployment Failed: ${err.message}`));
6432
6534
 
6433
6535
  // src/main.ts
6434
6536
  import chalk2 from "chalk";
6537
+
6538
+ // src/compile/compile.ts
6539
+ import * as esbuild3 from "esbuild";
6540
+ import { execSync } from "child_process";
6541
+ async function compileFiles(entryPoints) {
6542
+ const store = Store.getInstance();
6543
+ const userConfig = await loadConfig();
6544
+ const config = mergeConfig(getDefaultConfig(), userConfig);
6545
+ await esbuild3.build({
6546
+ entryPoints,
6547
+ bundle: true,
6548
+ outdir: config.build?.outDir || "dist",
6549
+ platform: "node",
6550
+ format: "esm",
6551
+ packages: "external",
6552
+ sourcemap: config.build?.sourcemap ?? true,
6553
+ minify: config.build?.minify ?? false,
6554
+ plugins: [
6555
+ ...config.plugins?.map((cb) => cb(store)) || [],
6556
+ useCompilePlugin({
6557
+ decorators: config.build?.decorators ?? false
6558
+ })
6559
+ ],
6560
+ write: true
6561
+ });
6562
+ if (config.build?.types) {
6563
+ execSync("npx tsc", {
6564
+ stdio: "inherit"
6565
+ });
6566
+ }
6567
+ }
6568
+
6569
+ // src/main.ts
6435
6570
  var program = new Command();
6436
- program.name("pod").description("Pod cli tool").version("1.0.30");
6571
+ program.name("pod").description("Pod cli tool").version("1.0.32");
6437
6572
  program.command("new <name> [type]").description("Start a new Orca Project").action(async (name, type) => {
6438
6573
  const orca = async () => {
6439
6574
  await addNew(name);
6440
- const appDir = path15.resolve(process.cwd());
6575
+ const appDir = path16.resolve(process.cwd());
6441
6576
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
6442
6577
  console.log("Installing dependencies...");
6443
- execSync("npm install", { stdio: "inherit", cwd: appDir, shell });
6578
+ execSync2("npm install", { stdio: "inherit", cwd: appDir, shell });
6444
6579
  console.log("Starting development server...");
6445
- execSync("npm run dev", { stdio: "inherit", cwd: appDir, shell });
6580
+ execSync2("npm run dev", { stdio: "inherit", cwd: appDir, shell });
6446
6581
  console.log(
6447
6582
  `All done! Your app "${name}" is running in development mode.`
6448
6583
  );
6449
6584
  };
6450
6585
  const ts4 = async () => {
6451
6586
  await addTs(name);
6452
- const appDir = path15.resolve(process.cwd());
6587
+ const appDir = path16.resolve(process.cwd());
6453
6588
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
6454
6589
  console.log("Installing dependencies...");
6455
- execSync("npm install", { stdio: "inherit", cwd: appDir, shell });
6590
+ execSync2("npm install", { stdio: "inherit", cwd: appDir, shell });
6456
6591
  };
6457
6592
  switch (type) {
6458
6593
  case "orca":
@@ -6466,6 +6601,9 @@ program.command("new <name> [type]").description("Start a new Orca Project").act
6466
6601
  program.command("dev").description("Start Pod development server").action(async (opts) => {
6467
6602
  await startDevServer();
6468
6603
  });
6604
+ program.command("compile <files...>").description("Compile ts files with pod").action(async (files) => {
6605
+ await compileFiles(files);
6606
+ });
6469
6607
  program.command("add <type> <name>").description("Add a component (c) or a feature (f)").action(async (type, name) => {
6470
6608
  try {
6471
6609
  if (type === "c") {
@@ -6502,6 +6640,7 @@ export {
6502
6640
  getDefaultConfig,
6503
6641
  getGlobalMacroGraph,
6504
6642
  loadConfig,
6643
+ macroContext,
6505
6644
  macros_exports as macros,
6506
6645
  mergeConfig,
6507
6646
  plugins_exports as plugins,