@kithinji/pod 1.0.26 → 1.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/main.js CHANGED
@@ -406,17 +406,17 @@ var MacroDependencyGraph = class {
406
406
  const visited = /* @__PURE__ */ new Set();
407
407
  const inProgress = /* @__PURE__ */ new Set();
408
408
  const sorted = [];
409
- const visit = (key, path15 = []) => {
409
+ const visit = (key, path16 = []) => {
410
410
  if (visited.has(key)) return;
411
411
  if (inProgress.has(key)) {
412
- const cycle = [...path15, key].join(" -> ");
412
+ const cycle = [...path16, key].join(" -> ");
413
413
  throw new Error(`Circular macro dependency detected: ${cycle}`);
414
414
  }
415
415
  const node = this.nodes.get(key);
416
416
  if (!node) return;
417
417
  inProgress.add(key);
418
418
  for (const depKey of node.dependencies) {
419
- visit(depKey, [...path15, key]);
419
+ visit(depKey, [...path16, key]);
420
420
  }
421
421
  inProgress.delete(key);
422
422
  visited.add(key);
@@ -1798,22 +1798,22 @@ var ElementTransformer = class {
1798
1798
  this.jsxUtils = jsxUtils;
1799
1799
  this.observableManager = observableManager;
1800
1800
  }
1801
- transformElement(path15, scope, context2) {
1802
- if (this.t.isJSXFragment(path15.node)) {
1801
+ transformElement(path16, scope, context2) {
1802
+ if (this.t.isJSXFragment(path16.node)) {
1803
1803
  return this.transformFragment(
1804
- path15,
1804
+ path16,
1805
1805
  scope,
1806
1806
  context2
1807
1807
  );
1808
1808
  }
1809
1809
  return this.transformJSXElement(
1810
- path15,
1810
+ path16,
1811
1811
  scope,
1812
1812
  context2
1813
1813
  );
1814
1814
  }
1815
- transformJSXElement(path15, scope, context2) {
1816
- const jsxElement = path15.node;
1815
+ transformJSXElement(path16, scope, context2) {
1816
+ const jsxElement = path16.node;
1817
1817
  const tag = this.jsxUtils.getComponentName(jsxElement.openingElement.name);
1818
1818
  const isComponent = this.jsxUtils.isComponentTag(tag);
1819
1819
  if (isComponent && tag) {
@@ -1928,7 +1928,7 @@ var ElementTransformer = class {
1928
1928
  }
1929
1929
  return { id: elId, statements };
1930
1930
  }
1931
- transformFragment(path15, scope, context2) {
1931
+ transformFragment(path16, scope, context2) {
1932
1932
  const fragId = scope.generateUidIdentifier("frag");
1933
1933
  const statements = [];
1934
1934
  statements.push(
@@ -1946,7 +1946,7 @@ var ElementTransformer = class {
1946
1946
  ])
1947
1947
  );
1948
1948
  this.processDOMChildren(
1949
- path15.node.children,
1949
+ path16.node.children,
1950
1950
  fragId,
1951
1951
  statements,
1952
1952
  scope,
@@ -2335,7 +2335,7 @@ function j2d({ types: t }) {
2335
2335
  name: "jsx-to-dom",
2336
2336
  visitor: {
2337
2337
  Program: {
2338
- exit(path15, state) {
2338
+ exit(path16, state) {
2339
2339
  if (state.helpersImported) return;
2340
2340
  const helpers = [
2341
2341
  { local: "$insert", imported: "insert" },
@@ -2346,7 +2346,7 @@ function j2d({ types: t }) {
2346
2346
  { local: "$effect", imported: "effect" }
2347
2347
  ];
2348
2348
  for (const helper of helpers) {
2349
- path15.unshiftContainer(
2349
+ path16.unshiftContainer(
2350
2350
  "body",
2351
2351
  t.importDeclaration(
2352
2352
  [
@@ -2362,10 +2362,10 @@ function j2d({ types: t }) {
2362
2362
  state.helpersImported = true;
2363
2363
  }
2364
2364
  },
2365
- ClassMethod(path15) {
2366
- if (path15.getData("processed")) return;
2365
+ ClassMethod(path16) {
2366
+ if (path16.getData("processed")) return;
2367
2367
  let hasJSX = false;
2368
- path15.traverse({
2368
+ path16.traverse({
2369
2369
  JSXElement() {
2370
2370
  hasJSX = true;
2371
2371
  },
@@ -2374,11 +2374,11 @@ function j2d({ types: t }) {
2374
2374
  }
2375
2375
  });
2376
2376
  if (!hasJSX) return;
2377
- path15.setData("processed", true);
2378
- const body = path15.node.body;
2377
+ path16.setData("processed", true);
2378
+ const body = path16.node.body;
2379
2379
  if (!t.isBlockStatement(body)) return;
2380
2380
  const observables = /* @__PURE__ */ new Map();
2381
- path15.traverse({
2381
+ path16.traverse({
2382
2382
  JSXElement(jsxPath) {
2383
2383
  observableManager.collectObservables(
2384
2384
  jsxPath.node,
@@ -2402,7 +2402,7 @@ function j2d({ types: t }) {
2402
2402
  const observableSignals = /* @__PURE__ */ new Map();
2403
2403
  const signalDeclarations = [];
2404
2404
  for (const [key, observable] of observables) {
2405
- const signalId = path15.scope.generateUidIdentifier("sig");
2405
+ const signalId = path16.scope.generateUidIdentifier("sig");
2406
2406
  observableSignals.set(key, signalId);
2407
2407
  signalDeclarations.push(
2408
2408
  t.variableDeclaration("const", [
@@ -2420,7 +2420,7 @@ function j2d({ types: t }) {
2420
2420
  astUtils.insertBeforeReturn(body.body, signalDeclarations);
2421
2421
  }
2422
2422
  const context2 = { observables, observableSignals };
2423
- path15.traverse({
2423
+ path16.traverse({
2424
2424
  JSXElement(jsxPath) {
2425
2425
  if (jsxPath.getData("processed")) return;
2426
2426
  jsxPath.setData("processed", true);
@@ -2953,8 +2953,8 @@ async function swcTransform(source, pathStr, tsx = false, react) {
2953
2953
  resolveDir
2954
2954
  };
2955
2955
  }
2956
- function parseFileMetadata(source, path15) {
2957
- const isTsx = path15.endsWith(".tsx");
2956
+ function parseFileMetadata(source, path16) {
2957
+ const isTsx = path16.endsWith(".tsx");
2958
2958
  const isInteractiveFile = source.startsWith('"use interactive"') || source.startsWith("'use interactive'");
2959
2959
  const isPublicFile = source.startsWith('"use public"') || source.startsWith("'use public'");
2960
2960
  let directive = null;
@@ -2962,7 +2962,7 @@ function parseFileMetadata(source, path15) {
2962
2962
  else if (isPublicFile) directive = "public";
2963
2963
  return {
2964
2964
  source,
2965
- path: path15,
2965
+ path: path16,
2966
2966
  isTsx,
2967
2967
  directive,
2968
2968
  isPublicFile,
@@ -2970,58 +2970,58 @@ function parseFileMetadata(source, path15) {
2970
2970
  };
2971
2971
  }
2972
2972
  var ServerBuildTransformer = class {
2973
- async transformPublicFile(source, path15) {
2974
- const controllerCode = generateController(path15, source);
2973
+ async transformPublicFile(source, path16) {
2974
+ const controllerCode = generateController(path16, source);
2975
2975
  if (controllerCode) {
2976
2976
  source = `${source}
2977
2977
 
2978
2978
  ${controllerCode}
2979
2979
  `;
2980
2980
  }
2981
- return swcTransform(source, path15);
2981
+ return swcTransform(source, path16);
2982
2982
  }
2983
- async transformRegularTypeScript(source, path15, isPublic) {
2983
+ async transformRegularTypeScript(source, path16, isPublic) {
2984
2984
  if (isPublic) {
2985
- return this.transformPublicFile(source, path15);
2985
+ return this.transformPublicFile(source, path16);
2986
2986
  }
2987
- return swcTransform(source, path15);
2987
+ return swcTransform(source, path16);
2988
2988
  }
2989
- async transformServerTsx(source, path15) {
2990
- return swcTransform(source, path15, true, {
2989
+ async transformServerTsx(source, path16) {
2990
+ return swcTransform(source, path16, true, {
2991
2991
  runtime: "automatic",
2992
2992
  importSource: "@kithinji/orca"
2993
2993
  });
2994
2994
  }
2995
- async transformInteractiveTsxStub(source, path15) {
2996
- const stubSource = generateServerStub(path15, source);
2997
- return swcTransform(stubSource, path15);
2995
+ async transformInteractiveTsxStub(source, path16) {
2996
+ const stubSource = generateServerStub(path16, source);
2997
+ return swcTransform(stubSource, path16);
2998
2998
  }
2999
2999
  async process(metadata, onClientFound) {
3000
3000
  const expandedSource = await expandMacros(metadata.source, metadata.path);
3001
3001
  const expandedMetadata = { ...metadata, source: expandedSource };
3002
- const { source, path: path15, isTsx, isInteractiveFile, isPublicFile } = expandedMetadata;
3002
+ const { source, path: path16, isTsx, isInteractiveFile, isPublicFile } = expandedMetadata;
3003
3003
  if (isTsx) {
3004
3004
  if (isInteractiveFile) {
3005
- onClientFound(path15);
3006
- const clientCode = await this.transformInteractiveTsxStub(source, path15);
3005
+ onClientFound(path16);
3006
+ const clientCode = await this.transformInteractiveTsxStub(source, path16);
3007
3007
  const store = Store.getInstance();
3008
- store.set(path15, clientCode.contents);
3008
+ store.set(path16, clientCode.contents);
3009
3009
  return clientCode;
3010
3010
  }
3011
- return this.transformServerTsx(source, path15);
3011
+ return this.transformServerTsx(source, path16);
3012
3012
  }
3013
- return this.transformRegularTypeScript(source, path15, isPublicFile);
3013
+ return this.transformRegularTypeScript(source, path16, isPublicFile);
3014
3014
  }
3015
3015
  };
3016
3016
  var ClientBuildTransformer = class {
3017
- async transformInteractiveTsx(source, path15) {
3018
- const swcResult = await swcTransform(source, path15, true, {
3017
+ async transformInteractiveTsx(source, path16) {
3018
+ const swcResult = await swcTransform(source, path16, true, {
3019
3019
  runtime: "preserve"
3020
3020
  });
3021
3021
  const babelResult = await babel.transformAsync(
3022
3022
  swcResult.contents,
3023
3023
  {
3024
- filename: path15,
3024
+ filename: path16,
3025
3025
  sourceType: "module",
3026
3026
  plugins: [j2d],
3027
3027
  parserOpts: {
@@ -3037,37 +3037,37 @@ var ClientBuildTransformer = class {
3037
3037
  resolveDir: swcResult.resolveDir
3038
3038
  };
3039
3039
  }
3040
- async transformServerComponent(node, source, path15) {
3041
- const scSource = generateServerComponent(path15, source);
3042
- return swcTransform(scSource, path15);
3040
+ async transformServerComponent(node, source, path16) {
3041
+ const scSource = generateServerComponent(path16, source);
3042
+ return swcTransform(scSource, path16);
3043
3043
  }
3044
- async transformPublicFileRpc(node, source, path15) {
3045
- const stubSource = generateRpcStub(path15, source);
3046
- return swcTransform(stubSource, path15);
3044
+ async transformPublicFileRpc(node, source, path16) {
3045
+ const stubSource = generateRpcStub(path16, source);
3046
+ return swcTransform(stubSource, path16);
3047
3047
  }
3048
- async transformSharedCode(source, path15) {
3049
- return swcTransform(source, path15);
3048
+ async transformSharedCode(source, path16) {
3049
+ return swcTransform(source, path16);
3050
3050
  }
3051
3051
  async process(node, metadata) {
3052
3052
  const expandedSource = await expandMacros(metadata.source, metadata.path);
3053
3053
  const expandedMetadata = { ...metadata, source: expandedSource };
3054
- const { source, path: path15, isTsx, directive } = expandedMetadata;
3054
+ const { source, path: path16, isTsx, directive } = expandedMetadata;
3055
3055
  if (isTsx) {
3056
3056
  if (directive === "interactive") {
3057
- return this.transformInteractiveTsx(source, path15);
3057
+ return this.transformInteractiveTsx(source, path16);
3058
3058
  } else if (directive === null) {
3059
- return this.transformServerComponent(node, source, path15);
3059
+ return this.transformServerComponent(node, source, path16);
3060
3060
  } else {
3061
3061
  throw new Error(
3062
- `Unexpected directive "${directive}" for TSX file: ${path15}`
3062
+ `Unexpected directive "${directive}" for TSX file: ${path16}`
3063
3063
  );
3064
3064
  }
3065
3065
  }
3066
3066
  if (directive === "public") {
3067
- return this.transformPublicFileRpc(node, source, path15);
3067
+ return this.transformPublicFileRpc(node, source, path16);
3068
3068
  }
3069
3069
  if (directive === null) {
3070
- return this.transformSharedCode(source, path15);
3070
+ return this.transformSharedCode(source, path16);
3071
3071
  }
3072
3072
  return {
3073
3073
  contents: source,
@@ -4815,18 +4815,398 @@ bootstrap();
4815
4815
  `;
4816
4816
  }
4817
4817
 
4818
+ // src/add/ts/index.ts
4819
+ import path12 from "path";
4820
+ import prompts from "prompts";
4821
+ async function addTs(name) {
4822
+ const baseDir = path12.join(process.cwd(), name);
4823
+ const response = await prompts({
4824
+ type: "select",
4825
+ name: "target",
4826
+ message: "Where will this project run?",
4827
+ choices: [
4828
+ { title: "Browser", value: "browser" },
4829
+ { title: "Node.js", value: "node" },
4830
+ { title: "Both (Browser & Node.js)", value: "both" }
4831
+ ],
4832
+ initial: 2
4833
+ });
4834
+ if (!response.target) {
4835
+ console.log("Project creation cancelled");
4836
+ process.exit(0);
4837
+ }
4838
+ const target = response.target;
4839
+ const structure = {
4840
+ files: [
4841
+ { name: "package.json", content: genPackageJson2(name, target) },
4842
+ { name: "tsconfig.json", content: genTsConfig(target) },
4843
+ { name: "build.js", content: genBuildConfig(name, target) },
4844
+ { name: "README.md", content: genReadMe2(name, target) },
4845
+ { name: ".gitignore", content: genGitIgnore2() },
4846
+ { name: ".env", content: genEnv2() }
4847
+ ],
4848
+ dirs: [
4849
+ {
4850
+ name: "src",
4851
+ files: getSrcFiles(target)
4852
+ }
4853
+ ]
4854
+ };
4855
+ createStructure(baseDir, structure);
4856
+ console.log(`TypeScript project created for ${target} environment`);
4857
+ }
4858
+ function getSrcFiles(target) {
4859
+ switch (target) {
4860
+ case "both":
4861
+ return [
4862
+ { name: "index.ts", content: genIndexTs() },
4863
+ { name: "index.browser.ts", content: genBrowserIndexTs() },
4864
+ { name: "index.node.ts", content: genNodeIndexTs() }
4865
+ ];
4866
+ case "browser":
4867
+ return [{ name: "index.ts", content: genBrowserIndexTs() }];
4868
+ case "node":
4869
+ return [{ name: "index.ts", content: genNodeIndexTs() }];
4870
+ }
4871
+ }
4872
+ function genPackageJson2(name, target) {
4873
+ const pkg = {
4874
+ name,
4875
+ version: "1.0.0",
4876
+ type: "module",
4877
+ scripts: {
4878
+ build: "node build.js",
4879
+ dev: "node build.js --watch",
4880
+ clean: "rm -rf dist"
4881
+ },
4882
+ devDependencies: {
4883
+ typescript: "^5.9.3",
4884
+ esbuild: "^0.27.2"
4885
+ }
4886
+ };
4887
+ if (target === "node") {
4888
+ pkg.main = "dist/index.mjs";
4889
+ pkg.types = "./dist/types/index.d.ts";
4890
+ } else if (target === "browser") {
4891
+ pkg.main = "dist/index.mjs";
4892
+ pkg.types = "./dist/types/index.d.ts";
4893
+ } else if (target === "both") {
4894
+ pkg.exports = {
4895
+ ".": {
4896
+ browser: {
4897
+ import: "./dist/browser/index.mjs"
4898
+ },
4899
+ node: {
4900
+ import: "./dist/node/index.mjs"
4901
+ },
4902
+ types: "./dist/types/index.d.ts"
4903
+ }
4904
+ };
4905
+ }
4906
+ return JSON.stringify(pkg, null, 2);
4907
+ }
4908
+ function genTsConfig(target) {
4909
+ const config = {
4910
+ compilerOptions: {
4911
+ target: "ES2020",
4912
+ module: "ESNext",
4913
+ moduleResolution: "bundler",
4914
+ declaration: true,
4915
+ declarationMap: true,
4916
+ emitDeclarationOnly: true,
4917
+ outDir: "./dist/types",
4918
+ rootDir: "./src",
4919
+ strict: true,
4920
+ esModuleInterop: true,
4921
+ skipLibCheck: true,
4922
+ forceConsistentCasingInFileNames: true,
4923
+ baseUrl: ".",
4924
+ paths: {
4925
+ "@/*": ["./src/*"]
4926
+ }
4927
+ },
4928
+ include: ["src/**/*"],
4929
+ exclude: ["node_modules", "dist"]
4930
+ };
4931
+ if (target === "browser" || target === "both") {
4932
+ config.compilerOptions.lib = ["ES2020", "DOM"];
4933
+ } else {
4934
+ config.compilerOptions.lib = ["ES2020"];
4935
+ }
4936
+ return JSON.stringify(config, null, 2);
4937
+ }
4938
+ function genBuildConfig(name, target) {
4939
+ return `const esbuild = require('esbuild');
4940
+ const { execSync } = require('child_process');
4941
+ const path = require('path');
4942
+
4943
+ const isWatch = process.argv.includes('--watch');
4944
+
4945
+
4946
+ const aliasPlugin = {
4947
+ name: 'alias',
4948
+ setup(build) {
4949
+ build.onResolve({ filter: /^@\\
4950
+ return {
4951
+ path: path.resolve(__dirname, 'src', args.path.slice(2))
4952
+ };
4953
+ });
4954
+ }
4955
+ };
4956
+
4957
+
4958
+ const buildConfigs = ${JSON.stringify(getBuildConfigs(target), null, 2).replace(
4959
+ /"plugins": null/g,
4960
+ '"plugins": [aliasPlugin]'
4961
+ )};
4962
+
4963
+ async function build() {
4964
+ try {
4965
+ execSync('rm -rf dist', { stdio: 'inherit' });
4966
+
4967
+
4968
+ for (const config of buildConfigs) {
4969
+ console.log(\`Building \${config.outfile}...\`);
4970
+
4971
+ if (isWatch) {
4972
+ const ctx = await esbuild.context(config);
4973
+ await ctx.watch();
4974
+ console.log(\`Watching \${config.outfile}...\`);
4975
+ } else {
4976
+ await esbuild.build(config);
4977
+ }
4978
+ }
4979
+
4980
+ console.log('Generating TypeScript declarations...');
4981
+ execSync("npx tsc", {
4982
+ stdio: "inherit",
4983
+ });
4984
+
4985
+ if (!isWatch) {
4986
+ console.log('Build successful!');
4987
+ } else {
4988
+ console.log('Initial build complete. Watching for changes...');
4989
+ }
4990
+ } catch (error) {
4991
+ console.error('Build failed:', error.message);
4992
+ process.exit(1);
4993
+ }
4994
+ }
4995
+
4996
+ build();
4997
+ `;
4998
+ }
4999
+ function getBuildConfigs(target) {
5000
+ const baseConfig = {
5001
+ bundle: true,
5002
+ sourcemap: true,
5003
+ minify: false,
5004
+ plugins: null
5005
+ };
5006
+ switch (target) {
5007
+ case "browser":
5008
+ return [
5009
+ {
5010
+ ...baseConfig,
5011
+ entryPoints: ["src/index.ts"],
5012
+ outfile: "dist/index.mjs",
5013
+ platform: "browser",
5014
+ format: "esm",
5015
+ target: ["es2020"],
5016
+ external: []
5017
+ }
5018
+ ];
5019
+ case "node":
5020
+ return [
5021
+ {
5022
+ ...baseConfig,
5023
+ entryPoints: ["src/index.ts"],
5024
+ outfile: "dist/index.mjs",
5025
+ platform: "node",
5026
+ format: "esm",
5027
+ target: ["node18"],
5028
+ packages: "external"
5029
+ }
5030
+ ];
5031
+ case "both":
5032
+ return [
5033
+ {
5034
+ ...baseConfig,
5035
+ entryPoints: ["src/index.browser.ts"],
5036
+ outfile: "dist/browser/index.mjs",
5037
+ platform: "browser",
5038
+ format: "esm",
5039
+ target: ["es2020"],
5040
+ external: []
5041
+ },
5042
+ {
5043
+ ...baseConfig,
5044
+ entryPoints: ["src/index.node.ts"],
5045
+ outfile: "dist/node/index.mjs",
5046
+ platform: "node",
5047
+ format: "esm",
5048
+ target: ["node18"],
5049
+ packages: "external"
5050
+ }
5051
+ ];
5052
+ }
5053
+ }
5054
+ function genReadMe2(name, target) {
5055
+ return `# ${name}
5056
+
5057
+ TypeScript project configured for **${target}** environment(s).
5058
+
5059
+ ## Features
5060
+
5061
+ - Fast builds with esbuild
5062
+ - Proper bundling for ${target}
5063
+ - Source maps for debugging
5064
+ - TypeScript declarations
5065
+ - Watch mode for development
5066
+
5067
+ ## Installation
5068
+
5069
+ \`\`\`bash
5070
+ npm install
5071
+ \`\`\`
5072
+
5073
+ ## Development
5074
+
5075
+ \`\`\`bash
5076
+ npm run dev
5077
+ \`\`\`
5078
+
5079
+ Watch mode will automatically rebuild when you change files.
5080
+
5081
+ ## Build
5082
+
5083
+ \`\`\`bash
5084
+ npm run build
5085
+ \`\`\`
5086
+
5087
+ This will:
5088
+ 1. Bundle your code with esbuild
5089
+ 2. Generate TypeScript declarations
5090
+ 3. Create source maps
5091
+
5092
+ ## Clean
5093
+
5094
+ \`\`\`bash
5095
+ npm run clean
5096
+ \`\`\`
5097
+
5098
+ ${target === "both" ? `
5099
+ ## Usage
5100
+
5101
+ This package builds separate bundles for browser and Node.js:
5102
+
5103
+ ### In Browser
5104
+ \`\`\`javascript
5105
+ import { platform } from '${name}';
5106
+
5107
+ console.log(platform);
5108
+ \`\`\`
5109
+
5110
+ ### In Node.js
5111
+ \`\`\`javascript
5112
+ import { platform } from '${name}';
5113
+
5114
+ console.log(platform);
5115
+ \`\`\`
5116
+ ` : target === "browser" ? `
5117
+ ## Usage
5118
+
5119
+ \`\`\`javascript
5120
+ import { platform } from '${name}';
5121
+ console.log(platform);
5122
+ \`\`\`
5123
+
5124
+ Include \`dist/index.mjs\` in your HTML or bundle with your favorite bundler.
5125
+ ` : `
5126
+ ## Usage
5127
+
5128
+ \`\`\`javascript
5129
+ import { platform } from '${name}';
5130
+ console.log(platform);
5131
+ \`\`\`
5132
+ `}
5133
+
5134
+ ## Build Output
5135
+
5136
+ - \`dist/*.mjs\` - Bundled JavaScript (ESM)
5137
+ - \`dist/types/*.d.ts\` - TypeScript declarations
5138
+ - \`dist/*.map\` - Source maps
5139
+ `;
5140
+ }
5141
+ function genGitIgnore2() {
5142
+ return `node_modules/
5143
+ dist/
5144
+ .env
5145
+ *.log
5146
+ .DS_Store
5147
+ coverage/
5148
+ .vscode/
5149
+ .idea/
5150
+ *.tsbuildinfo
5151
+ `;
5152
+ }
5153
+ function genEnv2() {
5154
+ return `# Environment variables
5155
+ `;
5156
+ }
5157
+ function genIndexTs() {
5158
+ return `
5159
+ export * from './index.browser.js';
5160
+ export * from './index.node.js';
5161
+ `;
5162
+ }
5163
+ function genBrowserIndexTs() {
5164
+ return `
5165
+ export const platform = 'browser' as const;
5166
+
5167
+ export function getBrowserInfo() {
5168
+ if (typeof window !== 'undefined') {
5169
+ return {
5170
+ userAgent: navigator.userAgent,
5171
+ language: navigator.language,
5172
+ };
5173
+ }
5174
+ return null;
5175
+ }
5176
+
5177
+ console.log('Running in browser environment');
5178
+ `;
5179
+ }
5180
+ function genNodeIndexTs() {
5181
+ return `
5182
+ import { platform as osPlatform, arch } from 'os';
5183
+
5184
+ export const platform = 'node' as const;
5185
+
5186
+ export function getNodeInfo() {
5187
+ return {
5188
+ platform: osPlatform(),
5189
+ arch: arch(),
5190
+ nodeVersion: process.version,
5191
+ };
5192
+ }
5193
+
5194
+ console.log('Running in Node.js environment');
5195
+ `;
5196
+ }
5197
+
4818
5198
  // src/main.ts
4819
- import path14 from "path";
5199
+ import path15 from "path";
4820
5200
  import { execSync } from "child_process";
4821
5201
 
4822
5202
  // src/docker/docker.ts
4823
5203
  import fs10 from "fs-extra";
4824
- import path12 from "path";
4825
- import prompts from "prompts";
5204
+ import path13 from "path";
5205
+ import prompts2 from "prompts";
4826
5206
  import yaml from "js-yaml";
4827
5207
  async function dockerize(env = "prod") {
4828
5208
  const cwd = process.cwd();
4829
- const packageJsonPath = path12.join(cwd, "package.json");
5209
+ const packageJsonPath = path13.join(cwd, "package.json");
4830
5210
  if (!fs10.existsSync(packageJsonPath)) {
4831
5211
  throw new Error("package.json not found. Are you in a Pod project?");
4832
5212
  }
@@ -4856,7 +5236,7 @@ function detectServices(packageJson) {
4856
5236
  }
4857
5237
  async function selectServices(detected) {
4858
5238
  if (detected.length === 0) return [];
4859
- const response = await prompts({
5239
+ const response = await prompts2({
4860
5240
  type: "multiselect",
4861
5241
  name: "services",
4862
5242
  message: "Select services to include:",
@@ -4870,7 +5250,7 @@ async function selectServices(detected) {
4870
5250
  return detected.filter((s) => response.services.includes(s.name));
4871
5251
  }
4872
5252
  async function restructureProject(cwd, projectName) {
4873
- const nestedDir = path12.join(cwd, projectName);
5253
+ const nestedDir = path13.join(cwd, projectName);
4874
5254
  if (fs10.existsSync(nestedDir)) {
4875
5255
  console.log("\u26A0\uFE0F Project already restructured, skipping...");
4876
5256
  return;
@@ -4879,18 +5259,18 @@ async function restructureProject(cwd, projectName) {
4879
5259
  const items = await fs10.readdir(cwd);
4880
5260
  const toMove = items.filter((item) => item !== projectName);
4881
5261
  for (const item of toMove) {
4882
- const src = path12.join(cwd, item);
4883
- const dest = path12.join(nestedDir, item);
5262
+ const src = path13.join(cwd, item);
5263
+ const dest = path13.join(nestedDir, item);
4884
5264
  await fs10.move(src, dest, { overwrite: true });
4885
5265
  }
4886
- const envSrc = path12.join(nestedDir, ".env");
4887
- const envDest = path12.join(cwd, ".env");
5266
+ const envSrc = path13.join(nestedDir, ".env");
5267
+ const envDest = path13.join(cwd, ".env");
4888
5268
  if (fs10.existsSync(envSrc)) {
4889
5269
  await fs10.move(envSrc, envDest, { overwrite: true });
4890
5270
  }
4891
5271
  }
4892
5272
  async function writeEnvVars(cwd, services, env) {
4893
- const envPath = path12.join(cwd, ".env");
5273
+ const envPath = path13.join(cwd, ".env");
4894
5274
  let existingEnv = {};
4895
5275
  let existingContent = "";
4896
5276
  if (fs10.existsSync(envPath)) {
@@ -4947,8 +5327,8 @@ function parseEnvFile(content) {
4947
5327
  return env;
4948
5328
  }
4949
5329
  async function createDockerfile(cwd, projectName) {
4950
- const dockerfilePath = path12.join(cwd, projectName, "Dockerfile");
4951
- const dockerignorePath = path12.join(cwd, projectName, ".dockerignore");
5330
+ const dockerfilePath = path13.join(cwd, projectName, "Dockerfile");
5331
+ const dockerignorePath = path13.join(cwd, projectName, ".dockerignore");
4952
5332
  const dockerfile = `FROM node:18-alpine
4953
5333
 
4954
5334
  WORKDIR /app
@@ -5026,10 +5406,9 @@ async function createDeployfile(cwd, projectName) {
5026
5406
  const deployFile = `name: ${projectName}
5027
5407
  version: 1.0.0
5028
5408
 
5029
- vars:
5030
- deploy_path: &deploy_path "/home/ubuntu/${projectName}"
5031
- backup_path: &backup_path "/home/ubuntu/backups"
5032
- user: &user "ubuntu"
5409
+ deploy_path: &deploy_path "/home/ubuntu/${projectName}"
5410
+ backup_path: &backup_path "/home/ubuntu/backups"
5411
+ user: &user "ubuntu"
5033
5412
 
5034
5413
  shared_operations:
5035
5414
  install_docker: &install_docker
@@ -5116,12 +5495,12 @@ targets:
5116
5495
  - name: "Navigate to Deploy Path"
5117
5496
  type: action
5118
5497
  action:
5119
- command: cd *deploy_path
5498
+ command: cd \${deploy_path}
5120
5499
 
5121
5500
  - name: "Create Pre-deployment Backup"
5122
5501
  type: action
5123
5502
  action:
5124
- command: tar -czf *backup_path/backup-$(date +%Y%m%d-%H%M%S).tar.gz .
5503
+ command: tar -czf \${backup_path}/backup-$(date +%Y%m%d-%H%M%S).tar.gz .
5125
5504
 
5126
5505
  - name: "Pull Latest Images"
5127
5506
  <<: *pull_images
@@ -5132,11 +5511,6 @@ targets:
5132
5511
  - name: "Build and Launch"
5133
5512
  <<: *build_and_start
5134
5513
 
5135
- - name: "Verify Health Status"
5136
- type: verify
5137
- verify:
5138
- command: ! "[ $(docker compose ps --format json | grep -qv 'running\\|healthy') ]"
5139
-
5140
5514
  - name: "Maintenance: Cleanup"
5141
5515
  type: action
5142
5516
  action:
@@ -5144,7 +5518,7 @@ targets:
5144
5518
  find *backup_path -name "backup-*.tar.gz" -mtime +7 -delete
5145
5519
  docker image prune -af --filter "until=24h"
5146
5520
  `;
5147
- const deployFilePath = path12.join(cwd, "pod.deploy.yml");
5521
+ const deployFilePath = path13.join(cwd, "pod.deploy.yml");
5148
5522
  await fs10.writeFile(deployFilePath, deployFile);
5149
5523
  }
5150
5524
  async function setupProduction(cwd, projectName, services) {
@@ -5215,14 +5589,14 @@ async function setupProduction(cwd, projectName, services) {
5215
5589
  }
5216
5590
  compose.services[projectName].depends_on.push(service.name);
5217
5591
  }
5218
- const composePath = path12.join(cwd, "docker-compose.yml");
5592
+ const composePath = path13.join(cwd, "docker-compose.yml");
5219
5593
  await fs10.writeFile(
5220
5594
  composePath,
5221
5595
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
5222
5596
  );
5223
5597
  }
5224
5598
  async function setupDevelopment(cwd, projectName, services) {
5225
- const existingCompose = path12.join(cwd, "docker-compose.yml");
5599
+ const existingCompose = path13.join(cwd, "docker-compose.yml");
5226
5600
  let existingServices = [];
5227
5601
  if (fs10.existsSync(existingCompose)) {
5228
5602
  const content = await fs10.readFile(existingCompose, "utf8");
@@ -5233,14 +5607,14 @@ async function setupDevelopment(cwd, projectName, services) {
5233
5607
  }
5234
5608
  const servicesToTunnel = [];
5235
5609
  if (existingServices.length > 0) {
5236
- const { tunnel } = await prompts({
5610
+ const { tunnel } = await prompts2({
5237
5611
  type: "confirm",
5238
5612
  name: "tunnel",
5239
5613
  message: "Tunnel to remote database services?",
5240
5614
  initial: false
5241
5615
  });
5242
5616
  if (tunnel) {
5243
- const { selected } = await prompts({
5617
+ const { selected } = await prompts2({
5244
5618
  type: "multiselect",
5245
5619
  name: "selected",
5246
5620
  message: "Select services to tunnel:",
@@ -5294,14 +5668,14 @@ async function setupDevelopment(cwd, projectName, services) {
5294
5668
  };
5295
5669
  compose.services[projectName].depends_on.push(tunnelName);
5296
5670
  }
5297
- const devComposePath = path12.join(cwd, "docker-compose.dev.yml");
5671
+ const devComposePath = path13.join(cwd, "docker-compose.dev.yml");
5298
5672
  await fs10.writeFile(
5299
5673
  devComposePath,
5300
5674
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
5301
5675
  );
5302
5676
  }
5303
5677
  async function createTunnelService(projectDir, serviceName) {
5304
- const tunnelDir = path12.join(projectDir, `${serviceName}-tunnel`);
5678
+ const tunnelDir = path13.join(projectDir, `${serviceName}-tunnel`);
5305
5679
  await fs10.ensureDir(tunnelDir);
5306
5680
  const dockerfile = `FROM alpine:latest
5307
5681
 
@@ -5330,8 +5704,8 @@ ssh -i $SSH_KEY \\
5330
5704
  -o ServerAliveInterval=60 \\
5331
5705
  $REMOTE_HOST
5332
5706
  `;
5333
- await fs10.writeFile(path12.join(tunnelDir, "Dockerfile"), dockerfile);
5334
- await fs10.writeFile(path12.join(tunnelDir, "tunnel.sh"), tunnelScript);
5707
+ await fs10.writeFile(path13.join(tunnelDir, "Dockerfile"), dockerfile);
5708
+ await fs10.writeFile(path13.join(tunnelDir, "tunnel.sh"), tunnelScript);
5335
5709
  }
5336
5710
  function getServiceConfig(serviceName) {
5337
5711
  const configs = {
@@ -5443,7 +5817,7 @@ function printNextSteps(projectName, env, services) {
5443
5817
  // src/deploy/deploy.ts
5444
5818
  import fs11 from "fs-extra";
5445
5819
  import yaml2 from "js-yaml";
5446
- import path13 from "path";
5820
+ import path14 from "path";
5447
5821
  import os from "os";
5448
5822
  import { NodeSSH } from "node-ssh";
5449
5823
  import chalk from "chalk";
@@ -5474,7 +5848,7 @@ function deepInterpolate(obj, context2) {
5474
5848
  }
5475
5849
  function expandTilde(fp) {
5476
5850
  if (!fp || typeof fp !== "string") return fp;
5477
- return fp.startsWith("~/") ? path13.join(os.homedir(), fp.slice(2)) : fp;
5851
+ return fp.startsWith("~/") ? path14.join(os.homedir(), fp.slice(2)) : fp;
5478
5852
  }
5479
5853
  function resolveLocalPaths(obj, cwd) {
5480
5854
  if (Array.isArray(obj)) {
@@ -5486,7 +5860,7 @@ function resolveLocalPaths(obj, cwd) {
5486
5860
  const isLocalPathKey = key === "keyPath" || key === "source";
5487
5861
  if (isLocalPathKey && typeof value === "string") {
5488
5862
  const expanded = expandTilde(value);
5489
- result[key] = path13.isAbsolute(expanded) ? expanded : path13.resolve(cwd, expanded);
5863
+ result[key] = path14.isAbsolute(expanded) ? expanded : path14.resolve(cwd, expanded);
5490
5864
  } else {
5491
5865
  result[key] = resolveLocalPaths(value, cwd);
5492
5866
  }
@@ -5669,7 +6043,7 @@ var SSHStrategy = class {
5669
6043
  const trimmed = cmd.trim();
5670
6044
  if (trimmed.startsWith("cd ")) {
5671
6045
  const newPath = trimmed.replace("cd ", "").trim();
5672
- this.currentDir = path13.posix.resolve(this.currentDir, newPath);
6046
+ this.currentDir = path14.posix.resolve(this.currentDir, newPath);
5673
6047
  if (!silent) console.log(chalk.gray(` [SSH Path: ${this.currentDir}]`));
5674
6048
  return { stdout: "", stderr: "", code: 0 };
5675
6049
  }
@@ -5697,7 +6071,7 @@ STDERR: ${result.stderr}`);
5697
6071
  }
5698
6072
  }
5699
6073
  async uploadContent(remotePath, content) {
5700
- const localTmp = path13.join(os.tmpdir(), `pod_tmp_${Date.now()}`);
6074
+ const localTmp = path14.join(os.tmpdir(), `pod_tmp_${Date.now()}`);
5701
6075
  fs11.writeFileSync(localTmp, content);
5702
6076
  try {
5703
6077
  await this.ssh.execCommand(`mkdir -p $(dirname ${remotePath})`);
@@ -5718,7 +6092,7 @@ STDERR: ${result.stderr}`);
5718
6092
  const putOptions = { recursive: true, concurrency: 10 };
5719
6093
  if (exclude?.length) {
5720
6094
  putOptions.validate = (filePath) => {
5721
- const relative = path13.relative(source, filePath);
6095
+ const relative = path14.relative(source, filePath);
5722
6096
  if (relative === "") return true;
5723
6097
  return !exclude.some((pattern) => {
5724
6098
  if (pattern.endsWith("/")) {
@@ -5750,7 +6124,7 @@ var LocalStrategy = class {
5750
6124
  const trimmed = cmd.trim();
5751
6125
  if (trimmed.startsWith("cd ")) {
5752
6126
  const newPath = trimmed.replace("cd ", "").trim();
5753
- this.currentDir = path13.resolve(this.currentDir, newPath);
6127
+ this.currentDir = path14.resolve(this.currentDir, newPath);
5754
6128
  if (!silent) console.log(chalk.gray(` [Local Path: ${this.currentDir}]`));
5755
6129
  return { stdout: "", stderr: "", code: 0 };
5756
6130
  }
@@ -5773,7 +6147,7 @@ STDERR: ${err.stderr || err.message}`
5773
6147
  }
5774
6148
  async runScript(name, content, context2) {
5775
6149
  const interpolated = interpolate(content, context2);
5776
- const scriptPath = path13.join(
6150
+ const scriptPath = path14.join(
5777
6151
  os.tmpdir(),
5778
6152
  `pod_script_${name}_${Date.now()}.sh`
5779
6153
  );
@@ -5786,7 +6160,7 @@ STDERR: ${err.stderr || err.message}`
5786
6160
  }
5787
6161
  }
5788
6162
  async uploadContent(localPath, content) {
5789
- const dir = path13.dirname(localPath);
6163
+ const dir = path14.dirname(localPath);
5790
6164
  if (!fs11.existsSync(dir)) {
5791
6165
  fs11.mkdirSync(dir, { recursive: true });
5792
6166
  }
@@ -5823,9 +6197,9 @@ STDERR: ${err.stderr || err.message}`
5823
6197
  const copyRecursive = (src, dest) => {
5824
6198
  const entries = fs11.readdirSync(src, { withFileTypes: true });
5825
6199
  for (const entry of entries) {
5826
- const srcPath = path13.join(src, entry.name);
5827
- const destPath = path13.join(dest, entry.name);
5828
- const relativePath = path13.relative(source, srcPath);
6200
+ const srcPath = path14.join(src, entry.name);
6201
+ const destPath = path14.join(dest, entry.name);
6202
+ const relativePath = path14.relative(source, srcPath);
5829
6203
  if (shouldExclude(relativePath)) continue;
5830
6204
  if (entry.isDirectory()) {
5831
6205
  if (!fs11.existsSync(destPath)) {
@@ -5996,7 +6370,7 @@ var OperationHandler = class {
5996
6370
  async function deploy(targetName, options) {
5997
6371
  const cwd = process.cwd();
5998
6372
  const rawConfig = yaml2.load(
5999
- fs11.readFileSync(path13.join(cwd, "pod.deploy.yml"), "utf8"),
6373
+ fs11.readFileSync(path14.join(cwd, "pod.deploy.yml"), "utf8"),
6000
6374
  { schema: yaml2.DEFAULT_SCHEMA }
6001
6375
  );
6002
6376
  const rawTarget = rawConfig.targets?.[targetName];
@@ -6016,7 +6390,7 @@ Pod Deploy: ${rawConfig.name} v${rawConfig.version} \u2192 ${targetName}
6016
6390
  const strategy = StrategyFactory.create(target, cwd);
6017
6391
  try {
6018
6392
  await strategy.connect();
6019
- const lockPath = target.deployPath ? path13.posix.join(target.deployPath, "pod-lock.json") : path13.join(cwd, "pod-lock.json");
6393
+ const lockPath = target.deployPath ? path14.posix.join(target.deployPath, "pod-lock.json") : path14.join(cwd, "pod-lock.json");
6020
6394
  let lock = await strategy.readJson(lockPath) || {
6021
6395
  ensures: {},
6022
6396
  once_actions: []
@@ -6058,16 +6432,31 @@ Deployment Failed: ${err.message}`));
6058
6432
  // src/main.ts
6059
6433
  import chalk2 from "chalk";
6060
6434
  var program = new Command();
6061
- program.name("pod").description("Pod cli tool").version("1.0.26");
6062
- program.command("new <name>").description("Start a new Orca Project").action(async (name) => {
6063
- await addNew(name);
6064
- const appDir = path14.resolve(process.cwd());
6065
- const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
6066
- console.log("Installing dependencies...");
6067
- execSync("npm install", { stdio: "inherit", cwd: appDir, shell });
6068
- console.log("Starting development server...");
6069
- execSync("npm run dev", { stdio: "inherit", cwd: appDir, shell });
6070
- console.log(`All done! Your app "${name}" is running in development mode.`);
6435
+ program.name("pod").description("Pod cli tool").version("1.0.28");
6436
+ program.command("new <name> [type]").description("Start a new Orca Project").action(async (name, type) => {
6437
+ const orca = async () => {
6438
+ await addNew(name);
6439
+ const appDir = path15.resolve(process.cwd());
6440
+ const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "/bin/sh";
6441
+ console.log("Installing dependencies...");
6442
+ execSync("npm install", { stdio: "inherit", cwd: appDir, shell });
6443
+ console.log("Starting development server...");
6444
+ execSync("npm run dev", { stdio: "inherit", cwd: appDir, shell });
6445
+ console.log(
6446
+ `All done! Your app "${name}" is running in development mode.`
6447
+ );
6448
+ };
6449
+ const ts4 = () => {
6450
+ addTs(name);
6451
+ };
6452
+ switch (type) {
6453
+ case "orca":
6454
+ return await orca();
6455
+ case "ts":
6456
+ return await ts4();
6457
+ default:
6458
+ return await orca();
6459
+ }
6071
6460
  });
6072
6461
  program.command("dev").description("Start Pod development server").action(async (opts) => {
6073
6462
  await startDevServer();