one 1.12.5 → 1.12.6-1774155963695

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.
Files changed (104) hide show
  1. package/devtools/source-inspector.mjs +7 -27
  2. package/dist/cjs/babel-plugins/remove-server-code.cjs +42 -46
  3. package/dist/cjs/babel-plugins/remove-server-code.native.js +44 -84
  4. package/dist/cjs/babel-plugins/remove-server-code.native.js.map +1 -1
  5. package/dist/cjs/cli/build.cjs +12 -17
  6. package/dist/cjs/cli/build.native.js +12 -17
  7. package/dist/cjs/cli/build.native.js.map +1 -1
  8. package/dist/cjs/cli/securityScan.cjs +2 -1
  9. package/dist/cjs/cli/securityScan.native.js +2 -1
  10. package/dist/cjs/cli/securityScan.native.js.map +1 -1
  11. package/dist/cjs/createApp.cjs +2 -15
  12. package/dist/cjs/headless.cjs +45 -0
  13. package/dist/cjs/headless.native.js +54 -0
  14. package/dist/cjs/headless.native.js.map +1 -0
  15. package/dist/cjs/serve-worker.cjs +16 -23
  16. package/dist/cjs/serve-worker.native.js +16 -23
  17. package/dist/cjs/serve-worker.native.js.map +1 -1
  18. package/dist/cjs/server/oneServe.cjs +4 -1
  19. package/dist/cjs/server/oneServe.native.js +4 -1
  20. package/dist/cjs/server/oneServe.native.js.map +1 -1
  21. package/dist/cjs/server/workerHandler.cjs +492 -0
  22. package/dist/cjs/server/workerHandler.native.js +673 -0
  23. package/dist/cjs/server/workerHandler.native.js.map +1 -0
  24. package/dist/cjs/utils/findRootLayout.cjs +39 -0
  25. package/dist/cjs/utils/findRootLayout.native.js +44 -0
  26. package/dist/cjs/utils/findRootLayout.native.js.map +1 -0
  27. package/dist/cjs/vite/one.cjs +6 -2
  28. package/dist/cjs/vite/one.native.js +5 -2
  29. package/dist/cjs/vite/one.native.js.map +1 -1
  30. package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +33 -29
  31. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +53 -44
  32. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  33. package/dist/esm/babel-plugins/remove-server-code.mjs +41 -45
  34. package/dist/esm/babel-plugins/remove-server-code.mjs.map +1 -1
  35. package/dist/esm/babel-plugins/remove-server-code.native.js +43 -83
  36. package/dist/esm/babel-plugins/remove-server-code.native.js.map +1 -1
  37. package/dist/esm/cli/build.mjs +12 -17
  38. package/dist/esm/cli/build.mjs.map +1 -1
  39. package/dist/esm/cli/build.native.js +12 -17
  40. package/dist/esm/cli/build.native.js.map +1 -1
  41. package/dist/esm/cli/securityScan.mjs +2 -1
  42. package/dist/esm/cli/securityScan.mjs.map +1 -1
  43. package/dist/esm/cli/securityScan.native.js +2 -1
  44. package/dist/esm/cli/securityScan.native.js.map +1 -1
  45. package/dist/esm/createApp.mjs +2 -15
  46. package/dist/esm/createApp.mjs.map +1 -1
  47. package/dist/esm/headless.mjs +20 -0
  48. package/dist/esm/headless.mjs.map +1 -0
  49. package/dist/esm/headless.native.js +26 -0
  50. package/dist/esm/headless.native.js.map +1 -0
  51. package/dist/esm/serve-worker.mjs +11 -7
  52. package/dist/esm/serve-worker.mjs.map +1 -1
  53. package/dist/esm/serve-worker.native.js +11 -7
  54. package/dist/esm/serve-worker.native.js.map +1 -1
  55. package/dist/esm/server/oneServe.mjs +4 -1
  56. package/dist/esm/server/oneServe.mjs.map +1 -1
  57. package/dist/esm/server/oneServe.native.js +4 -1
  58. package/dist/esm/server/oneServe.native.js.map +1 -1
  59. package/dist/esm/server/workerHandler.mjs +469 -0
  60. package/dist/esm/server/workerHandler.mjs.map +1 -0
  61. package/dist/esm/server/workerHandler.native.js +647 -0
  62. package/dist/esm/server/workerHandler.native.js.map +1 -0
  63. package/dist/esm/utils/findRootLayout.mjs +16 -0
  64. package/dist/esm/utils/findRootLayout.mjs.map +1 -0
  65. package/dist/esm/utils/findRootLayout.native.js +18 -0
  66. package/dist/esm/utils/findRootLayout.native.js.map +1 -0
  67. package/dist/esm/vite/one.mjs +6 -2
  68. package/dist/esm/vite/one.mjs.map +1 -1
  69. package/dist/esm/vite/one.native.js +5 -2
  70. package/dist/esm/vite/one.native.js.map +1 -1
  71. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +34 -30
  72. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -1
  73. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +54 -45
  74. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  75. package/package.json +15 -11
  76. package/src/babel-plugins/remove-server-code.ts +117 -189
  77. package/src/cli/build.ts +12 -15
  78. package/src/cli/securityScan.ts +1 -1
  79. package/src/createApp.tsx +2 -38
  80. package/src/headless.tsx +46 -0
  81. package/src/serve-worker.ts +20 -22
  82. package/src/server/oneServe.ts +1 -1
  83. package/src/server/workerHandler.ts +767 -0
  84. package/src/utils/findRootLayout.ts +25 -0
  85. package/src/vite/one.ts +2 -1
  86. package/src/vite/plugins/sourceInspectorPlugin.ts +44 -64
  87. package/src/vite/types.ts +8 -0
  88. package/types/babel-plugins/remove-server-code.d.ts +8 -11
  89. package/types/babel-plugins/remove-server-code.d.ts.map +1 -1
  90. package/types/cli/build.d.ts.map +1 -1
  91. package/types/createApp.d.ts.map +1 -1
  92. package/types/headless.d.ts +13 -0
  93. package/types/headless.d.ts.map +1 -0
  94. package/types/serve-worker.d.ts +10 -21
  95. package/types/serve-worker.d.ts.map +1 -1
  96. package/types/server/workerHandler.d.ts +23 -0
  97. package/types/server/workerHandler.d.ts.map +1 -0
  98. package/types/utils/findRootLayout.d.ts +2 -0
  99. package/types/utils/findRootLayout.d.ts.map +1 -0
  100. package/types/vite/one.d.ts.map +1 -1
  101. package/types/vite/plugins/sourceInspectorPlugin.d.ts +3 -1
  102. package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -1
  103. package/types/vite/types.d.ts +7 -0
  104. package/types/vite/types.d.ts.map +1 -1
@@ -772,50 +772,30 @@
772
772
 
773
773
  renderPickerList(chain)
774
774
 
775
- // position picker near click, smart about viewport edges
775
+ // position picker near click, clamped to viewport
776
776
  const pickerWidth = 320
777
777
  const pickerHeight = Math.min(300, 80 + chain.length * 36)
778
778
  const pad = 10
779
779
 
780
780
  let left = x + 10
781
781
  let top = y + 10
782
- let flippedUp = false
783
782
 
784
- // flip to left if too close to right edge
785
- if (left + pickerWidth > window.innerWidth - pad) {
786
- left = x - pickerWidth - 10
787
- }
788
- // flip up if too close to bottom
789
- if (top + pickerHeight > window.innerHeight - pad) {
790
- top = y - pickerHeight - 10
791
- flippedUp = true
792
- }
793
783
  // clamp to viewport
794
784
  left = Math.max(pad, Math.min(left, window.innerWidth - pickerWidth - pad))
795
785
  top = Math.max(pad, Math.min(top, window.innerHeight - pickerHeight - pad))
796
786
 
797
- // reorder elements so actions row is closest to mouse
787
+ // consistent layout order
798
788
  const picker = shadow.getElementById('picker')
799
789
  const header = picker.querySelector('.picker-header')
800
790
  const actions = picker.querySelector('.picker-actions')
801
791
  const pickerTabs = picker.querySelector('.picker-tabs')
802
792
  const list = picker.querySelector('.picker-list')
803
793
 
804
- if (flippedUp) {
805
- // picker is above click, put actions at bottom (closest to mouse)
806
- picker.style.flexDirection = 'column'
807
- header.style.order = '0'
808
- pickerTabs.style.order = '1'
809
- list.style.order = '2'
810
- actions.style.order = '3'
811
- } else {
812
- // picker is below click, put actions at top (closest to mouse)
813
- picker.style.flexDirection = 'column'
814
- header.style.order = '2'
815
- pickerTabs.style.order = '1'
816
- list.style.order = '3'
817
- actions.style.order = '0'
818
- }
794
+ picker.style.flexDirection = 'column'
795
+ header.style.order = '0'
796
+ actions.style.order = '1'
797
+ pickerTabs.style.order = '2'
798
+ list.style.order = '3'
819
799
 
820
800
  pickerDialog.style.left = left + 'px'
821
801
  pickerDialog.style.top = top + 'px'
@@ -34,9 +34,13 @@ __export(remove_server_code_exports, {
34
34
  default: () => remove_server_code_default
35
35
  });
36
36
  module.exports = __toCommonJS(remove_server_code_exports);
37
- var t = __toESM(require("@babel/types"), 1),
37
+ var import_generator = __toESM(require("@babel/generator"), 1),
38
+ import_parser = require("@babel/parser"),
39
+ import_traverse = __toESM(require("@babel/traverse"), 1),
40
+ t = __toESM(require("@babel/types"), 1),
38
41
  import_babel_dead_code_elimination = require("babel-dead-code-elimination");
39
- const SERVER_EXPORTS = ["loader", "generateStaticParams"];
42
+ const generate = import_generator.default.default || import_generator.default,
43
+ traverse = import_traverse.default.default || import_traverse.default;
40
44
  function removeServerCodePlugin(_, options) {
41
45
  const {
42
46
  routerRoot = "app"
@@ -45,58 +49,50 @@ function removeServerCodePlugin(_, options) {
45
49
  name: "one-remove-server-code",
46
50
  visitor: {
47
51
  Program: {
48
- enter(path, state) {
52
+ exit(path, state) {
49
53
  const filename = state.filename;
50
54
  if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules")) return;
51
55
  const code = path.toString();
52
56
  if (/generateStaticParams|loader/.test(code)) try {
53
- state.referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(path.node);
54
- } catch (error) {
55
- console.warn(`[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`, error instanceof Error ? error.message : String(error));
56
- }
57
- },
58
- exit(path, state) {
59
- const filename = state.filename;
60
- if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules") || !state.referenced) return;
61
- const removedExports = /* @__PURE__ */new Set();
62
- if (path.traverse({
63
- ExportNamedDeclaration(exportPath) {
64
- const declaration = exportPath.node.declaration;
65
- if (t.isFunctionDeclaration(declaration) && declaration.id) {
66
- const name = declaration.id.name;
67
- SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
68
- } else if (t.isVariableDeclaration(declaration)) for (let i = declaration.declarations.length - 1; i >= 0; i--) {
69
- const declarator = declaration.declarations[i];
70
- if (t.isIdentifier(declarator.id)) {
71
- const name = declarator.id.name;
72
- SERVER_EXPORTS.includes(name) && (removedExports.add(name), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
73
- }
74
- }
75
- },
76
- // Also remove helper functions created by babel's async-to-generator transform
77
- // These are named _loader, _generateStaticParams, etc.
78
- FunctionDeclaration(funcPath) {
79
- if (!funcPath.node.id) return;
80
- const name = funcPath.node.id.name;
81
- for (const serverExport of SERVER_EXPORTS) if (name === `_${serverExport}`) {
82
- let isAsyncHelper = !1;
83
- funcPath.traverse({
84
- Identifier(idPath) {
85
- idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
57
+ const freshAst = (0, import_parser.parse)(code, {
58
+ sourceType: "module",
59
+ plugins: ["typescript", "jsx"]
60
+ }),
61
+ referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(freshAst),
62
+ removed = {
63
+ loader: !1,
64
+ generateStaticParams: !1
65
+ };
66
+ traverse(freshAst, {
67
+ ExportNamedDeclaration(expPath) {
68
+ if (expPath.node.declaration?.type === "FunctionDeclaration" && expPath.node.declaration.id) {
69
+ const name = expPath.node.declaration.id.name;
70
+ (name === "loader" || name === "generateStaticParams") && (expPath.remove(), removed[name] = !0);
71
+ } else if (expPath.node.declaration?.type === "VariableDeclaration") {
72
+ const declarators = expPath.get("declaration").get("declarations");
73
+ for (let i = declarators.length - 1; i >= 0; i--) {
74
+ const declarator = declarators[i],
75
+ id = declarator.node.id;
76
+ id.type === "Identifier" && (id.name === "loader" || id.name === "generateStaticParams") && (declarator.remove(), removed[id.name] = !0);
86
77
  }
87
- }), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
78
+ expPath.node.declaration?.type === "VariableDeclaration" && expPath.node.declaration.declarations.length === 0 && expPath.remove();
79
+ }
88
80
  }
89
- }
90
- }), removedExports.size === 0) return;
91
- try {
92
- (0, import_babel_dead_code_elimination.deadCodeElimination)(path.node, state.referenced);
81
+ });
82
+ const removedFunctions = Object.keys(removed).filter(key => removed[key]);
83
+ if (removedFunctions.length === 0) return;
84
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(freshAst, referenced), removed.loader && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removed.generateStaticParams && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
85
+ const out = generate(freshAst, {
86
+ retainLines: !0
87
+ }),
88
+ finalAst = (0, import_parser.parse)(out.code, {
89
+ sourceType: "module",
90
+ plugins: ["typescript", "jsx"]
91
+ });
92
+ path.node.body = finalAst.program.body, path.node.directives = finalAst.program.directives, process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedFunctions.length} server-only exports`);
93
93
  } catch (error) {
94
- console.warn(`[one/metro] Dead code elimination failed for ${filename}:`, error instanceof Error ? error.message : String(error));
94
+ console.warn(`[one/metro] Tree shaking failed for ${filename}:`, error instanceof Error ? error.message : String(error));
95
95
  }
96
- const stubs = [];
97
- removedExports.has("loader") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removedExports.has("generateStaticParams") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
98
- for (const stub of stubs) path.pushContainer("body", stub);
99
- process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
100
96
  }
101
97
  }
102
98
  }
@@ -36,12 +36,16 @@ __export(remove_server_code_exports, {
36
36
  default: () => remove_server_code_default
37
37
  });
38
38
  module.exports = __toCommonJS(remove_server_code_exports);
39
- var t = __toESM(require("@babel/types"), 1),
39
+ var import_generator = __toESM(require("@babel/generator"), 1),
40
+ import_parser = require("@babel/parser"),
41
+ import_traverse = __toESM(require("@babel/traverse"), 1),
42
+ t = __toESM(require("@babel/types"), 1),
40
43
  import_babel_dead_code_elimination = require("babel-dead-code-elimination");
41
44
  function _instanceof(left, right) {
42
45
  return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
43
46
  }
44
- var SERVER_EXPORTS = ["loader", "generateStaticParams"];
47
+ var generate = import_generator.default.default || import_generator.default,
48
+ traverse = import_traverse.default.default || import_traverse.default;
45
49
  function removeServerCodePlugin(_, options) {
46
50
  var {
47
51
  routerRoot = "app"
@@ -50,97 +54,53 @@ function removeServerCodePlugin(_, options) {
50
54
  name: "one-remove-server-code",
51
55
  visitor: {
52
56
  Program: {
53
- enter(path, state) {
57
+ exit(path, state) {
54
58
  var filename = state.filename;
55
59
  if (filename) {
56
60
  var routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`);
57
61
  if (routerRootPattern.test(filename) && !filename.includes("node_modules")) {
58
62
  var code = path.toString();
59
63
  if (/generateStaticParams|loader/.test(code)) try {
60
- state.referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(path.node);
61
- } catch (error) {
62
- console.warn(`[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`, _instanceof(error, Error) ? error.message : String(error));
63
- }
64
- }
65
- }
66
- },
67
- exit(path, state) {
68
- var filename = state.filename;
69
- if (filename) {
70
- var routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`);
71
- if (routerRootPattern.test(filename) && !filename.includes("node_modules") && state.referenced) {
72
- var removedExports = /* @__PURE__ */new Set();
73
- if (path.traverse({
74
- ExportNamedDeclaration(exportPath) {
75
- var declaration = exportPath.node.declaration;
76
- if (t.isFunctionDeclaration(declaration) && declaration.id) {
77
- var name = declaration.id.name;
78
- SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
79
- } else if (t.isVariableDeclaration(declaration)) for (var i = declaration.declarations.length - 1; i >= 0; i--) {
80
- var declarator = declaration.declarations[i];
81
- if (t.isIdentifier(declarator.id)) {
82
- var name1 = declarator.id.name;
83
- SERVER_EXPORTS.includes(name1) && (removedExports.add(name1), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
84
- }
85
- }
86
- },
87
- // Also remove helper functions created by babel's async-to-generator transform
88
- // These are named _loader, _generateStaticParams, etc.
89
- FunctionDeclaration(funcPath) {
90
- if (funcPath.node.id) {
91
- var name = funcPath.node.id.name,
92
- _iteratorNormalCompletion2 = !0,
93
- _didIteratorError2 = !1,
94
- _iteratorError2 = void 0;
95
- try {
96
- for (var _loop = function () {
97
- var serverExport = _step2.value;
98
- if (name === `_${serverExport}`) {
99
- var isAsyncHelper = !1;
100
- funcPath.traverse({
101
- Identifier(idPath) {
102
- idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
103
- }
104
- }), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
105
- }
106
- }, _iterator2 = SERVER_EXPORTS[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) _loop();
107
- } catch (err) {
108
- _didIteratorError2 = !0, _iteratorError2 = err;
109
- } finally {
110
- try {
111
- !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
112
- } finally {
113
- if (_didIteratorError2) throw _iteratorError2;
64
+ var freshAst = (0, import_parser.parse)(code, {
65
+ sourceType: "module",
66
+ plugins: ["typescript", "jsx"]
67
+ }),
68
+ referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(freshAst),
69
+ removed = {
70
+ loader: !1,
71
+ generateStaticParams: !1
72
+ };
73
+ traverse(freshAst, {
74
+ ExportNamedDeclaration(expPath) {
75
+ var _expPath_node_declaration, _expPath_node_declaration1;
76
+ if (((_expPath_node_declaration = expPath.node.declaration) === null || _expPath_node_declaration === void 0 ? void 0 : _expPath_node_declaration.type) === "FunctionDeclaration" && expPath.node.declaration.id) {
77
+ var name = expPath.node.declaration.id.name;
78
+ (name === "loader" || name === "generateStaticParams") && (expPath.remove(), removed[name] = !0);
79
+ } else if (((_expPath_node_declaration1 = expPath.node.declaration) === null || _expPath_node_declaration1 === void 0 ? void 0 : _expPath_node_declaration1.type) === "VariableDeclaration") {
80
+ for (var _expPath_node_declaration2, decl = expPath.get("declaration"), declarators = decl.get("declarations"), i = declarators.length - 1; i >= 0; i--) {
81
+ var declarator = declarators[i],
82
+ id = declarator.node.id;
83
+ id.type === "Identifier" && (id.name === "loader" || id.name === "generateStaticParams") && (declarator.remove(), removed[id.name] = !0);
114
84
  }
85
+ ((_expPath_node_declaration2 = expPath.node.declaration) === null || _expPath_node_declaration2 === void 0 ? void 0 : _expPath_node_declaration2.type) === "VariableDeclaration" && expPath.node.declaration.declarations.length === 0 && expPath.remove();
115
86
  }
116
87
  }
117
- }
118
- }), removedExports.size !== 0) {
119
- try {
120
- (0, import_babel_dead_code_elimination.deadCodeElimination)(path.node, state.referenced);
121
- } catch (error) {
122
- console.warn(`[one/metro] Dead code elimination failed for ${filename}:`, _instanceof(error, Error) ? error.message : String(error));
123
- }
124
- var stubs = [];
125
- removedExports.has("loader") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removedExports.has("generateStaticParams") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
126
- var _iteratorNormalCompletion = !0,
127
- _didIteratorError = !1,
128
- _iteratorError = void 0;
129
- try {
130
- for (var _iterator = stubs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
131
- var stub = _step.value;
132
- path.pushContainer("body", stub);
133
- }
134
- } catch (err) {
135
- _didIteratorError = !0, _iteratorError = err;
136
- } finally {
137
- try {
138
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
139
- } finally {
140
- if (_didIteratorError) throw _iteratorError;
141
- }
142
- }
143
- process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
88
+ });
89
+ var removedFunctions = Object.keys(removed).filter(function (key) {
90
+ return removed[key];
91
+ });
92
+ if (removedFunctions.length === 0) return;
93
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(freshAst, referenced), removed.loader && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removed.generateStaticParams && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
94
+ var out = generate(freshAst, {
95
+ retainLines: !0
96
+ }),
97
+ finalAst = (0, import_parser.parse)(out.code, {
98
+ sourceType: "module",
99
+ plugins: ["typescript", "jsx"]
100
+ });
101
+ path.node.body = finalAst.program.body, path.node.directives = finalAst.program.directives, process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedFunctions.length} server-only exports`);
102
+ } catch (error) {
103
+ console.warn(`[one/metro] Tree shaking failed for ${filename}:`, _instanceof(error, Error) ? error.message : String(error));
144
104
  }
145
105
  }
146
106
  }
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","remove_server_code_exports","__export","default","remove_server_code_default","module","exports","t","__toESM","require","import_babel_dead_code_elimination","_instanceof","left","right","Symbol","hasInstance","SERVER_EXPORTS","removeServerCodePlugin","_","options","routerRoot","name","visitor","Program","enter","path","state","filename","routerRootPattern","RegExp","test","includes","code","toString","referenced","findReferencedIdentifiers","node","error","console","warn","Error","message","String","exit","removedExports","Set","traverse","ExportNamedDeclaration","exportPath","declaration","isFunctionDeclaration","id","add","remove","isVariableDeclaration","i","declarations","length","declarator","isIdentifier","name1","splice","FunctionDeclaration","funcPath","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_loop","serverExport","_step2","isAsyncHelper","Identifier","idPath","stop","_iterator2","iterator","next","done","err","return","size","deadCodeElimination","stubs","has","push","exportNamedDeclaration","functionDeclaration","identifier","blockStatement","returnStatement","stringLiteral","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","_step","stub","pushContainer"],"sources":["../../../src/babel-plugins/remove-server-code.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAC;AAAA;AAkBAC,MAAA,CAAAC,OAAmB,GAAAV,YAAA,CAAAK,0BACnB;AAKA,IAAAM,CAAA,GAAMC,OAAA,CAAAC,OAAiB,CAAC,cAAU;EAAAC,kCAAsB,GAAAD,OAAA;AAQxD,SAASE,YAAAC,IAAA,EAAAC,KAAuB;EAC9B,OAAMA,KAAE,YAAa,OAAUC,MAAA,UAAAD,KAAA,CAAAC,MAAA,CAAAC,WAAA,MAAAF,KAAA,CAAAC,MAAA,CAAAC,WAAA,EAAAH,IAAA,IAAAA,IAAA,YAAAC,KAAA;AAE/B;AAAO,IACLG,cAAM,YACN,EAAS,sBACE;AAKL,SAAAC,sBAAiBA,CAAAC,CAAM,EAAAC,OAAA;EAcvB;IAAAC,UAXK;EAMD,CADsB,GAAAD,OAAI;EAO5B;IAIFE,IAAA,0BAAkB;IAClBC,OAAA;MAMAC,OAAA;QACEC,MAAAC,IAAA,EAAMC,KAAA;UAAuD,IAC/DC,QAAS,GAAAD,KAAO,CAAAC,QAAA;UACd,IAAAA,QAAQ;YAAA,IACNC,iBAAA,OAAAC,MAAA,WAAyCT,UAAQ;YAAA,IACjDQ,iBAAiB,CAAAE,IAAA,CAAAH,QAAc,MAAAA,QAAU,CAAAI,QAAY;cACvD,IAAAC,IAAA,GAAAP,IAAA,CAAAQ,QAAA;cACF,kCAAAH,IAAA,CAAAE,IAAA,GACF;gBAGEN,KACA,CAAAQ,UACA,OAAAxB,kCAAA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","__export","default","remove_server_code_default","module","exports","import_generator","__toESM","require","import_parser","import_traverse","t","import_babel_dead_code_elimination","_instanceof","left","right","Symbol","hasInstance","generate","traverse","removeServerCodePlugin","_","options","routerRoot","name","visitor","Program","exit","path","state","filename","routerRootPattern","RegExp","test","includes","code","toString","freshAst","parse","sourceType","plugins","referenced","findReferencedIdentifiers","removed","loader","generateStaticParams","ExportNamedDeclaration","expPath","_expPath_node_declaration","_expPath_node_declaration1","node","declaration","type","id","remove","_expPath_node_declaration2","decl","get","declarators","i","length","declarator","declarations","removedFunctions","Object","keys","filter","key","deadCodeElimination","program","body","push","exportNamedDeclaration","functionDeclaration","identifier","blockStatement","returnStatement","stringLiteral","out","retainLines","finalAst","directives","process","env","DEBUG","console","info","error","warn","Error","message","String"],"sources":["../../../src/babel-plugins/remove-server-code.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAC;AAAA;AAeAC,MAAA,CAAAC,OAAA,GAAAV,YAA0B,CAAAK,0BAAA;AAS1B,IAAAM,gBAAkB,GAAAC,OAAA,CAAAC,OAAA,mBAChB;EAAAC,aAAA,GACID,OAAA,gBAAY;EAAAE,eAAc,GAAAH,OAAc,CAAAC,OAAA;EAAAG,CAAA,GAAAJ,OAAA,CAAAC,OAAA;EAAAI,kCAAA,GAAAJ,OAAA;AAM9C,SAASK,YAAAC,IAAA,EAAAC,KAAuB;EAC9B,OAAMA,KAAE,YAAa,OAAUC,MAAA,UAAAD,KAAA,CAAAC,MAAA,CAAAC,WAAA,MAAAF,KAAA,CAAAC,MAAA,CAAAC,WAAA,EAAAH,IAAA,IAAAA,IAAA,YAAAC,KAAA;AAE/B;AAAO,IACLG,QAAM,GAAAZ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A,CAAA+D,UAAA,gBAAA/D,CAAA,CAAAgE,cAAA,EACAhE,CAAA,CAAEiE,eAAW,CAAAjE,CAAA,CAAAkE,aAAA,mBAAsB,IACnC,CAAC,IAAAlC,OAAA,CAAAE,oBAAA,IAAAR,QAAA,CAAAgC,OAAA,CAAAC,IAAA,CAAAC,IAAA,CAAA5D,CAAA,CAAA6D,sBAAA,CAAA7D,CAAA,CAAA8D,mBAAA,CAAA9D,CAAA,CAAA+D,UAAA,8BAAA/D,CAAA,CAAAgE,cAAA;gBAAA,IACCG,GAAA,GAAA5D,QAAA,CAAemB,QAAE;oBACrB0C,WAAA;kBACF;kBAAAC,QAAA,OAAAvE,aAAA,CAAA6B,KAAA,EAAAwC,GAAA,CAAA3C,IAAA;oBACFI,UAAA;oBAIIC,OAAM,GAEV,YAAY,EACZ,KAAU;kBAGZ,CAAK;gBAKDZ,IAAA,CAAAsB,IAAA,CAAAoB,IAAA,GAAAU,QAAmB,CAAAX,OAAQ,CAAAC,IAAA,EAAA1C,IAAY,CAAAsB,IAAA,CAAA+B,UAAA,GAAiBD,QAAM,CAAAX,OAAA,CAAAY,UAAA,EAAAC,OAAA,CAAAC,GAAA,CAAAC,KAAA,IAAAC,OAAA,CAAAC,IAAA,2BAAAxD,QAAA,YAAAiC,gBAAA,CAAAH,MAAA;cAChE,SAAA2B,KAAA;gBAEJF,OAAS,CAAAG,IAAO,wCAAA1D,QAAA,KAAAjB,WAAA,CAAA0E,KAAA,EAAAE,KAAA,IAAAF,KAAA,CAAAG,OAAA,GAAAC,MAAA,CAAAJ,KAAA;cACd;YAAQ;UACyC;QACM;MACvD;IACF;EACF;AACF;AACF,IACFpF,0BAAA,GAAAiB,sBAAA","ignoreList":[]}
@@ -113,7 +113,7 @@ async function build(args) {
113
113
  if (!process.env.ONE_SERVER_URL && deployConfig) {
114
114
  const url = deployConfig.url ?? (deployConfig.target === "cloudflare" ? `https://${await getCloudflareProjectName(process.cwd())}.workers.dev` : void 0);
115
115
  url && (process.env.ONE_SERVER_URL = url, console.info(`
116
- \u2601\uFE0F ONE_SERVER_URL: ${url}
116
+ \u2601\uFE0F ONE_SERVER_URL: ${url}
117
117
  `));
118
118
  }
119
119
  const outDir = viteLoadedConfig?.config?.build?.outDir ?? "dist",
@@ -134,7 +134,7 @@ async function build(args) {
134
134
  }, args),
135
135
  bundleTime = performance.now() - buildStartTime;
136
136
  if (console.info(`
137
- \u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
137
+ \u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
138
138
  `), !vxrnOutput || args.platform !== "web") return;
139
139
  const options = await (0, import_vxrn.fillOptions)(vxrnOutput.options, {
140
140
  mode: "prod"
@@ -508,7 +508,7 @@ async function build(args) {
508
508
  workerPool && (await (0, import_workerPool.terminateWorkerPool)());
509
509
  const staticTime = performance.now() - staticStartTime;
510
510
  console.info(`
511
- \u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
511
+ \u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
512
512
  `), (0, import_buildPage.printBuildTimings)(), await moveAllFiles(staticDir, clientDir), await import_fs_extra.default.rm(staticDir, {
513
513
  force: !0,
514
514
  recursive: !0
@@ -644,15 +644,15 @@ ${middlewareRouteMap.join(`,
644
644
 
645
645
  const buildInfo = ${JSON.stringify(buildInfoForWriting)}
646
646
 
647
- let app
647
+ let server
648
648
 
649
649
  export default {
650
650
  async fetch(request, env, ctx) {
651
- if (!app) {
652
- app = await serve(buildInfo, lazyRoutes)
651
+ if (!server) {
652
+ server = await serve(buildInfo, lazyRoutes)
653
653
  }
654
654
 
655
- // Set up static HTML fetcher for this request (uses ASSETS binding)
655
+ // set up static HTML fetcher for this request (uses ASSETS binding)
656
656
  if (env.ASSETS) {
657
657
  setFetchStaticHtml(async (path) => {
658
658
  try {
@@ -663,34 +663,31 @@ export default {
663
663
  return await assetResponse.text()
664
664
  }
665
665
  } catch (e) {
666
- // Asset not found
666
+ // asset not found
667
667
  }
668
668
  return null
669
669
  })
670
670
  }
671
671
 
672
672
  try {
673
- // Try the app first
674
- const response = await app.fetch(request, env, ctx)
673
+ const response = await server.fetch(request)
675
674
 
676
- // If no route matched (404) or no response, try serving static assets
675
+ // no route matched or 404 \u2192 try static assets
677
676
  if (!response || response.status === 404) {
678
677
  if (env.ASSETS) {
679
678
  try {
680
679
  const assetResponse = await env.ASSETS.fetch(request)
681
- // If asset exists, return it
682
680
  if (assetResponse && assetResponse.status !== 404) {
683
681
  return assetResponse
684
682
  }
685
683
  } catch (e) {
686
- // Asset not found, continue with original response
684
+ // asset not found, continue with original response
687
685
  }
688
686
  }
689
687
  }
690
688
 
691
689
  return response
692
690
  } finally {
693
- // Clean up per-request state
694
691
  setFetchStaticHtml(null)
695
692
  }
696
693
  }
@@ -783,9 +780,7 @@ export default {
783
780
  `), postBuildLogs.forEach(log => {
784
781
  console.info(` \xB7 ${log}`);
785
782
  })), console.info(`
786
-
787
- \u{1F49B} build complete
788
-
783
+ \u{1F49B} build complete
789
784
  `);
790
785
  }
791
786
  const TRAILING_INDEX_REGEX = /\/index(\.(web))?/;
@@ -139,7 +139,7 @@ async function build(args) {
139
139
  var _deployConfig_url,
140
140
  url = (_deployConfig_url = deployConfig.url) !== null && _deployConfig_url !== void 0 ? _deployConfig_url : deployConfig.target === "cloudflare" ? `https://${await getCloudflareProjectName(process.cwd())}.workers.dev` : void 0;
141
141
  url && (process.env.ONE_SERVER_URL = url, console.info(`
142
- \u2601\uFE0F ONE_SERVER_URL: ${url}
142
+ \u2601\uFE0F ONE_SERVER_URL: ${url}
143
143
  `));
144
144
  }
145
145
  var outDir = (_ref = viteLoadedConfig == null || (_viteLoadedConfig_config = viteLoadedConfig.config) === null || _viteLoadedConfig_config === void 0 || (_viteLoadedConfig_config_build = _viteLoadedConfig_config.build) === null || _viteLoadedConfig_config_build === void 0 ? void 0 : _viteLoadedConfig_config_build.outDir) !== null && _ref !== void 0 ? _ref : "dist",
@@ -160,7 +160,7 @@ async function build(args) {
160
160
  }, args),
161
161
  bundleTime = performance.now() - buildStartTime;
162
162
  if (console.info(`
163
- \u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
163
+ \u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
164
164
  `), !vxrnOutput || args.platform !== "web") return;
165
165
  var options = await (0, import_vxrn.fillOptions)(vxrnOutput.options, {
166
166
  mode: "prod"
@@ -775,7 +775,7 @@ async function build(args) {
775
775
  workerPool && (await (0, import_workerPool.terminateWorkerPool)());
776
776
  var staticTime = performance.now() - staticStartTime;
777
777
  console.info(`
778
- \u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
778
+ \u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
779
779
  `), (0, import_buildPage.printBuildTimings)(), await moveAllFiles(staticDir, clientDir), await import_fs_extra.default.rm(staticDir, {
780
780
  force: !0,
781
781
  recursive: !0
@@ -1012,15 +1012,15 @@ ${middlewareRouteMap.join(`,
1012
1012
 
1013
1013
  const buildInfo = ${JSON.stringify(buildInfoForWriting)}
1014
1014
 
1015
- let app
1015
+ let server
1016
1016
 
1017
1017
  export default {
1018
1018
  async fetch(request, env, ctx) {
1019
- if (!app) {
1020
- app = await serve(buildInfo, lazyRoutes)
1019
+ if (!server) {
1020
+ server = await serve(buildInfo, lazyRoutes)
1021
1021
  }
1022
1022
 
1023
- // Set up static HTML fetcher for this request (uses ASSETS binding)
1023
+ // set up static HTML fetcher for this request (uses ASSETS binding)
1024
1024
  if (env.ASSETS) {
1025
1025
  setFetchStaticHtml(async (path) => {
1026
1026
  try {
@@ -1031,34 +1031,31 @@ export default {
1031
1031
  return await assetResponse.text()
1032
1032
  }
1033
1033
  } catch (e) {
1034
- // Asset not found
1034
+ // asset not found
1035
1035
  }
1036
1036
  return null
1037
1037
  })
1038
1038
  }
1039
1039
 
1040
1040
  try {
1041
- // Try the app first
1042
- const response = await app.fetch(request, env, ctx)
1041
+ const response = await server.fetch(request)
1043
1042
 
1044
- // If no route matched (404) or no response, try serving static assets
1043
+ // no route matched or 404 \u2192 try static assets
1045
1044
  if (!response || response.status === 404) {
1046
1045
  if (env.ASSETS) {
1047
1046
  try {
1048
1047
  const assetResponse = await env.ASSETS.fetch(request)
1049
- // If asset exists, return it
1050
1048
  if (assetResponse && assetResponse.status !== 404) {
1051
1049
  return assetResponse
1052
1050
  }
1053
1051
  } catch (e) {
1054
- // Asset not found, continue with original response
1052
+ // asset not found, continue with original response
1055
1053
  }
1056
1054
  }
1057
1055
  }
1058
1056
 
1059
1057
  return response
1060
1058
  } finally {
1061
- // Clean up per-request state
1062
1059
  setFetchStaticHtml(null)
1063
1060
  }
1064
1061
  }
@@ -1152,9 +1149,7 @@ export default {
1152
1149
  `), postBuildLogs.forEach(function (log) {
1153
1150
  console.info(` \xB7 ${log}`);
1154
1151
  })), console.info(`
1155
-
1156
- \u{1F49B} build complete
1157
-
1152
+ \u{1F49B} build complete
1158
1153
  `);
1159
1154
  }
1160
1155
  var TRAILING_INDEX_REGEX = /\/index(\.(web))?/;