@fragno-dev/unplugin-fragno 0.0.2 → 0.0.4

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 (37) hide show
  1. package/LICENSE.md +16 -0
  2. package/dist/{index-DxDbJ0wz.d.ts → index-C_Qj2XYR.d.ts} +3 -3
  3. package/dist/{index-DxDbJ0wz.d.ts.map → index-C_Qj2XYR.d.ts.map} +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/integrations/astro.d.ts +1 -1
  7. package/dist/integrations/astro.js +2 -2
  8. package/dist/integrations/esbuild.d.ts +4 -4
  9. package/dist/integrations/esbuild.js +2 -2
  10. package/dist/integrations/farm.d.ts +4 -3
  11. package/dist/integrations/farm.js +2 -2
  12. package/dist/integrations/nuxt.d.ts +1 -1
  13. package/dist/integrations/nuxt.js +4 -4
  14. package/dist/integrations/rollup.d.ts +2 -2
  15. package/dist/integrations/rollup.js +2 -2
  16. package/dist/integrations/rspack.d.ts +2 -2
  17. package/dist/integrations/rspack.js +2 -2
  18. package/dist/integrations/vite.d.ts +2 -2
  19. package/dist/integrations/vite.js +3 -3
  20. package/dist/integrations/webpack.d.ts +2 -2
  21. package/dist/integrations/webpack.js +3 -3
  22. package/dist/macros.js +1 -1
  23. package/dist/{package-DVqxmLAc.js → package-C_uRIjY-.js} +2 -2
  24. package/dist/package-C_uRIjY-.js.map +1 -0
  25. package/dist/{src-CgL952Dn.js → src-CTS5acja.js} +64 -8
  26. package/dist/src-CTS5acja.js.map +1 -0
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/dist/{types-B2lQo1ln.d.ts → types-DI0A616D.d.ts} +2 -2
  29. package/dist/types-DI0A616D.d.ts.map +1 -0
  30. package/dist/{vite-D3fvyjiQ.js → vite-CQ79v0ua.js} +3 -3
  31. package/dist/{vite-D3fvyjiQ.js.map → vite-CQ79v0ua.js.map} +1 -1
  32. package/dist/{webpack-Ci7_UEVJ.js → webpack-BDF_ZF_n.js} +3 -3
  33. package/dist/{webpack-Ci7_UEVJ.js.map → webpack-BDF_ZF_n.js.map} +1 -1
  34. package/package.json +19 -22
  35. package/dist/package-DVqxmLAc.js.map +0 -1
  36. package/dist/src-CgL952Dn.js.map +0 -1
  37. package/dist/types-B2lQo1ln.d.ts.map +0 -1
package/LICENSE.md ADDED
@@ -0,0 +1,16 @@
1
+ Copyright 2025 - present "ReJot Nederland B.V.", and individual contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the “Software”), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
15
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-B2lQo1ln.js";
1
+ import { t as Options } from "./types-DI0A616D.js";
2
2
  import * as unplugin0 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
  import "@babel/types";
@@ -12,5 +12,5 @@ declare const isMacroBinding: (binding: Binding, macro: string) => boolean;
12
12
  declare const unpluginFactory: UnpluginFactory<Options | undefined>;
13
13
  declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
14
14
  //#endregion
15
- export { isMacroBinding, unplugin, unpluginFactory };
16
- //# sourceMappingURL=index-DxDbJ0wz.d.ts.map
15
+ export { unpluginFactory as n, isMacroBinding as r, unplugin as t };
16
+ //# sourceMappingURL=index-C_Qj2XYR.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DxDbJ0wz.d.ts","names":[],"sources":["../../src/transform-macros.ts","../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgBa,0BAA2B;;;cCX3B,iBAAiB,gBAAgB;cA2BjC,UAAQ,SAAA,CAAA,iBAAA"}
1
+ {"version":3,"file":"index-C_Qj2XYR.d.ts","names":[],"sources":["../../src/transform-macros.ts","../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgBa,0BAA2B;;;cCX3B,iBAAiB,gBAAgB;cA2BjC,UAAQ,SAAA,CAAA,iBAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Options } from "./types-B2lQo1ln.js";
2
- import { isMacroBinding, unplugin, unpluginFactory } from "./index-DxDbJ0wz.js";
1
+ import { t as Options } from "./types-DI0A616D.js";
2
+ import { n as unpluginFactory, r as isMacroBinding, t as unplugin } from "./index-C_Qj2XYR.js";
3
3
  export { Options, unplugin as default, unplugin, isMacroBinding, unpluginFactory };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./package-DVqxmLAc.js";
2
- import { isMacroBinding, src_default, unplugin, unpluginFactory } from "./src-CgL952Dn.js";
1
+ import "./package-C_uRIjY-.js";
2
+ import { i as isMacroBinding, n as unplugin, r as unpluginFactory, t as src_default } from "./src-CTS5acja.js";
3
3
 
4
4
  export { src_default as default, isMacroBinding, unplugin, unpluginFactory };
@@ -1,4 +1,4 @@
1
- import { Options } from "../types-B2lQo1ln.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
2
 
3
3
  //#region src/integrations/astro.d.ts
4
4
  declare const _default: (options: Options) => any;
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { src_default } from "../src-CgL952Dn.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { t as src_default } from "../src-CTS5acja.js";
3
3
 
4
4
  //#region src/integrations/astro.ts
5
5
  var astro_default = (options) => ({
@@ -1,9 +1,9 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
3
- import * as unplugin0 from "unplugin";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
+ import * as esbuild0 from "esbuild";
4
4
 
5
5
  //#region src/integrations/esbuild.d.ts
6
- declare const _default: (options?: Options | undefined) => unplugin0.EsbuildPlugin;
6
+ declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
7
7
  //#endregion
8
8
  export { _default as default };
9
9
  //# sourceMappingURL=esbuild.d.ts.map
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src-CgL952Dn.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CTS5acja.js";
3
3
  import { createEsbuildPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/esbuild.ts
@@ -1,8 +1,9 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
+ import * as _farmfe_core0 from "@farmfe/core";
3
4
 
4
5
  //#region src/integrations/farm.d.ts
5
- declare const _default: (options?: Options | undefined) => JsPlugin;
6
+ declare const _default: (options?: Options | undefined) => _farmfe_core0.JsPlugin;
6
7
  //#endregion
7
8
  export { _default as default };
8
9
  //# sourceMappingURL=farm.d.ts.map
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src-CgL952Dn.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CTS5acja.js";
3
3
  import { createFarmPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/farm.ts
@@ -1,4 +1,4 @@
1
- import { Options } from "../types-B2lQo1ln.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
2
  import * as _nuxt_schema0 from "@nuxt/schema";
3
3
 
4
4
  //#region src/integrations/nuxt.d.ts
@@ -1,7 +1,7 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src-CgL952Dn.js";
3
- import { vite_default } from "../vite-D3fvyjiQ.js";
4
- import { webpack_default } from "../webpack-Ci7_UEVJ.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CTS5acja.js";
3
+ import { t as vite_default } from "../vite-CQ79v0ua.js";
4
+ import { t as webpack_default } from "../webpack-BDF_ZF_n.js";
5
5
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
6
6
 
7
7
  //#region src/integrations/nuxt.ts
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
  import * as rollup0 from "rollup";
4
4
 
5
5
  //#region src/integrations/rollup.d.ts
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src-CgL952Dn.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CTS5acja.js";
3
3
  import { createRollupPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/rollup.ts
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
 
4
4
  //#region src/integrations/rspack.d.ts
5
5
  declare const _default: (options?: Options | undefined) => RspackPluginInstance;
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src-CgL952Dn.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CTS5acja.js";
3
3
  import { createRspackPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/rspack.ts
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
  import * as vite0 from "vite";
4
4
 
5
5
  //#region src/integrations/vite.d.ts
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src-CgL952Dn.js";
3
- import { vite_default } from "../vite-D3fvyjiQ.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CTS5acja.js";
3
+ import { t as vite_default } from "../vite-CQ79v0ua.js";
4
4
 
5
5
  export { vite_default as default };
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
  import * as webpack0 from "webpack";
4
4
 
5
5
  //#region src/integrations/webpack.d.ts
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src-CgL952Dn.js";
3
- import { webpack_default } from "../webpack-Ci7_UEVJ.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CTS5acja.js";
3
+ import { t as webpack_default } from "../webpack-BDF_ZF_n.js";
4
4
 
5
5
  export { webpack_default as default };
package/dist/macros.js CHANGED
@@ -1,4 +1,4 @@
1
- import { name } from "./package-DVqxmLAc.js";
1
+ import { t as name } from "./package-C_uRIjY-.js";
2
2
 
3
3
  //#region src/macros.ts
4
4
  const maybe = (_) => {
@@ -2,5 +2,5 @@
2
2
  var name = "@fragno-dev/unplugin-fragno";
3
3
 
4
4
  //#endregion
5
- export { name };
6
- //# sourceMappingURL=package-DVqxmLAc.js.map
5
+ export { name as t };
6
+ //# sourceMappingURL=package-C_uRIjY-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-C_uRIjY-.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@fragno-dev/unplugin-fragno\",\n \"type\": \"module\",\n \"version\": \"0.0.4\",\n \"description\": \"\",\n \"keywords\": [\n \"fragno\",\n \"unplugin\"\n ],\n \"exports\": {\n \".\": {\n \"development\": \"./src/index.ts\",\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./macros\": {\n \"development\": \"./src/macros.ts\",\n \"types\": \"./dist/macros.d.ts\",\n \"default\": \"./dist/macros.js\"\n },\n \"./astro\": {\n \"development\": \"./src/integrations/astro.ts\",\n \"types\": \"./dist/integrations/astro.d.ts\",\n \"default\": \"./dist/integrations/astro.js\"\n },\n \"./esbuild\": {\n \"development\": \"./src/integrations/esbuild.ts\",\n \"types\": \"./dist/integrations/esbuild.d.ts\",\n \"default\": \"./dist/integrations/esbuild.js\"\n },\n \"./farm\": {\n \"development\": \"./src/integrations/farm.ts\",\n \"types\": \"./dist/integrations/farm.d.ts\",\n \"default\": \"./dist/integrations/farm.js\"\n },\n \"./nuxt\": {\n \"development\": \"./src/integrations/nuxt.ts\",\n \"types\": \"./dist/integrations/nuxt.d.ts\",\n \"default\": \"./dist/integrations/nuxt.js\"\n },\n \"./rollup\": {\n \"development\": \"./src/integrations/rollup.ts\",\n \"types\": \"./dist/integrations/rollup.d.ts\",\n \"default\": \"./dist/integrations/rollup.js\"\n },\n \"./rspack\": {\n \"development\": \"./src/integrations/rspack.ts\",\n \"types\": \"./dist/integrations/rspack.d.ts\",\n \"default\": \"./dist/integrations/rspack.js\"\n },\n \"./vite\": {\n \"development\": \"./src/integrations/vite.ts\",\n \"types\": \"./dist/integrations/vite.d.ts\",\n \"default\": \"./dist/integrations/vite.js\"\n },\n \"./webpack\": {\n \"development\": \"./src/integrations/webpack.ts\",\n \"types\": \"./dist/integrations/webpack.d.ts\",\n \"default\": \"./dist/integrations/webpack.js\"\n },\n \"./types\": \"./dist/types.js\",\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"./dist/*\",\n \"./*\"\n ]\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"types:check\": \"tsc --noEmit\",\n \"build\": \"tsdown\",\n \"build:watch\": \"tsdown --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest --watch\"\n },\n \"peerDependencies\": {\n \"@farmfe/core\": \">=1\",\n \"@nuxt/kit\": \"^3 || ^4\",\n \"@nuxt/schema\": \"^3 || ^4\",\n \"esbuild\": \"*\",\n \"rollup\": \"^3\",\n \"vite\": \">=3\",\n \"webpack\": \"^4 || ^5\"\n },\n \"peerDependenciesMeta\": {\n \"@farmfe/core\": {\n \"optional\": true\n },\n \"@nuxt/kit\": {\n \"optional\": true\n },\n \"@nuxt/schema\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"rollup\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n },\n \"webpack\": {\n \"optional\": true\n }\n },\n \"dependencies\": {\n \"unplugin\": \"^2.3.4\",\n \"@babel/core\": \"^7.23.7\",\n \"@babel/generator\": \"^7.23.6\",\n \"@babel/parser\": \"^7.23.6\",\n \"@babel/traverse\": \"^7.23.7\",\n \"@babel/types\": \"^7.23.6\",\n \"babel-dead-code-elimination\": \"^1.0.6\"\n },\n \"devDependencies\": {\n \"@antfu/eslint-config\": \"^4.13.2\",\n \"@fragno-private/typescript-config\": \"workspace:*\",\n \"@fragno-private/vitest-config\": \"workspace:*\",\n \"@nuxt/kit\": \"^4.0.3\",\n \"@nuxt/schema\": \"^4.0.3\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/babel__generator\": \"^7.6.8\",\n \"@types/babel__traverse\": \"^7.20.5\",\n \"@types/node\": \"^22.15.21\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"dedent\": \"^1.7.0\",\n \"eslint\": \"^9.27.0\",\n \"nodemon\": \"^3.1.10\",\n \"rollup\": \"^4.41.0\",\n \"tsdown\": \"^0.12.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vite\": \"^6.3.5\",\n \"vitest\": \"^3.2.4\",\n \"webpack\": \"^5.99.9\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/rejot-dev/fragno.git\",\n \"directory\": \"packages/unplugin-fragno\"\n },\n \"homepage\": \"https://fragno.dev\",\n \"license\": \"MIT\"\n}\n"],"mappings":";WACU"}
@@ -1,4 +1,4 @@
1
- import { name } from "./package-DVqxmLAc.js";
1
+ import { t as name } from "./package-C_uRIjY-.js";
2
2
  import { createUnplugin } from "unplugin";
3
3
  import * as babel from "@babel/core";
4
4
  import { traverse } from "@babel/core";
@@ -107,13 +107,13 @@ function transformDefineRoute(ast, options) {
107
107
  const FRAGNO_PACKAGE_DEFINITIONS = {
108
108
  "@fragno-dev/core": {
109
109
  fragmentDefinitions: ["defineFragment"],
110
- chainMethods: ["withDependencies", "withServices"]
110
+ chainMethods: ["withDependencies", "providesService"]
111
111
  },
112
112
  "@fragno-dev/db": {
113
113
  fragmentDefinitions: ["defineFragmentWithDatabase"],
114
114
  chainMethods: [
115
115
  "withDependencies",
116
- "withServices",
116
+ "providesService",
117
117
  "withDatabase"
118
118
  ],
119
119
  utilityFunctions: ["schema"]
@@ -152,12 +152,20 @@ const isUtilityFunctionBinding = (binding) => {
152
152
  const isDefineLibraryCall = (node, scope) => {
153
153
  if (!t.isIdentifier(node.callee)) return false;
154
154
  const binding = scope.getBinding(node.callee.name);
155
- if (!binding) return false;
156
- return isDefineLibraryBinding(binding);
155
+ if (!binding) return node.callee.name === "defineFragment";
156
+ return isDefineLibraryBinding(binding) || isDefineFragmentWithDatabaseBinding(binding);
157
157
  };
158
158
  const createNoOpArrowFunction = () => {
159
159
  return t.arrowFunctionExpression([], t.blockStatement([]));
160
160
  };
161
+ /**
162
+ * Create an arrow function that returns its first parameter.
163
+ * Used for utility functions like schema() where the callback needs to return a builder.
164
+ */
165
+ const createPassThroughArrowFunction = () => {
166
+ const param = t.identifier("s");
167
+ return t.arrowFunctionExpression([param], param);
168
+ };
161
169
  const isDefineLibraryChain = (node, scope) => {
162
170
  if (t.isCallExpression(node) && isDefineLibraryCall(node, scope)) return true;
163
171
  if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) return isDefineLibraryChain(node.callee.object, scope);
@@ -170,15 +178,58 @@ const isDefineLibraryChain = (node, scope) => {
170
178
  }
171
179
  return false;
172
180
  };
181
+ /**
182
+ * Ensures that 'defineFragment' from '@fragno-dev/core' is imported in the AST.
183
+ * If it's not imported, adds the import statement.
184
+ */
185
+ const ensureDefineFragmentImport = (ast) => {
186
+ let hasDefineFragmentImport = false;
187
+ let foundCoreImport = false;
188
+ const newImportSpecifier = t.importSpecifier(t.identifier("defineFragment"), t.identifier("defineFragment"));
189
+ traverse(ast, { ImportDeclaration(path) {
190
+ const source = path.node.source.value;
191
+ if (source === "@fragno-dev/core" || source.startsWith("@fragno-dev/core/")) {
192
+ foundCoreImport = true;
193
+ for (const specifier of path.node.specifiers) if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported) && specifier.imported.name === "defineFragment") {
194
+ hasDefineFragmentImport = true;
195
+ return;
196
+ }
197
+ if (!hasDefineFragmentImport) {
198
+ path.node.specifiers.push(newImportSpecifier);
199
+ hasDefineFragmentImport = true;
200
+ }
201
+ }
202
+ } });
203
+ if (!foundCoreImport && !hasDefineFragmentImport) {
204
+ const newImport = t.importDeclaration([newImportSpecifier], t.stringLiteral("@fragno-dev/core"));
205
+ if (t.isProgram(ast)) ast.body.unshift(newImport);
206
+ else if (t.isFile(ast)) ast.program.body.unshift(newImport);
207
+ }
208
+ };
209
+ const isDefineFragmentWithDatabaseBinding = (binding) => {
210
+ if (!t.isImportDeclaration(binding?.path.parent)) return false;
211
+ const source = binding.path.parent.source.value;
212
+ if (source !== "@fragno-dev/db" && !source.startsWith("@fragno-dev/db/")) return false;
213
+ if (!t.isImportSpecifier(binding?.path.node)) return false;
214
+ const { imported } = binding.path.node;
215
+ if (!t.isIdentifier(imported)) return false;
216
+ return imported.name === "defineFragmentWithDatabase";
217
+ };
173
218
  function transformDefineLibrary(ast, options) {
174
219
  if (options.ssr) return;
175
220
  const chainMethods = getAllChainMethods();
221
+ let needsDefineFragmentImport = false;
176
222
  traverse(ast, { CallExpression(path) {
177
223
  const { callee } = path.node;
178
224
  if (t.isIdentifier(callee)) {
179
225
  const binding = path.scope.getBinding(callee.name);
180
226
  if (binding && isUtilityFunctionBinding(binding)) {
181
- path.node.arguments = [createNoOpArrowFunction()];
227
+ path.node.arguments = [createPassThroughArrowFunction()];
228
+ return;
229
+ }
230
+ if (binding && isDefineFragmentWithDatabaseBinding(binding)) {
231
+ path.node.callee = t.identifier("defineFragment");
232
+ needsDefineFragmentImport = true;
182
233
  return;
183
234
  }
184
235
  }
@@ -186,10 +237,15 @@ function transformDefineLibrary(ast, options) {
186
237
  const { property, object } = callee;
187
238
  if (!t.isIdentifier(property)) return;
188
239
  const methodName = property.name;
240
+ if (methodName === "withDatabase" && isDefineLibraryChain(object, path.scope)) {
241
+ path.replaceWith(object);
242
+ return;
243
+ }
189
244
  if (!chainMethods.has(methodName)) return;
190
245
  if (!isDefineLibraryChain(object, path.scope)) return;
191
246
  path.node.arguments = [createNoOpArrowFunction()];
192
247
  } });
248
+ if (needsDefineFragmentImport) ensureDefineFragmentImport(ast);
193
249
  }
194
250
 
195
251
  //#endregion
@@ -235,5 +291,5 @@ const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
235
291
  var src_default = unplugin;
236
292
 
237
293
  //#endregion
238
- export { isMacroBinding, src_default, unplugin, unpluginFactory };
239
- //# sourceMappingURL=src-CgL952Dn.js.map
294
+ export { isMacroBinding as i, unplugin as n, unpluginFactory as r, src_default as t };
295
+ //# sourceMappingURL=src-CTS5acja.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-CTS5acja.js","names":["pkgName","unpluginFactory: UnpluginFactory<Options | undefined>"],"sources":["../src/transform-macros.ts","../src/transform-define-route.ts","../src/transform-define-library.ts","../src/transform.ts","../src/index.ts"],"sourcesContent":["/**\n * Modified from: pcattori/vite-env-only\n * Original source: https://github.com/pcattori/vite-env-only/blob/45a39e7fb52e9fae4300e95aa51ed0880374f507/src/transform.ts\n * License: MIT\n * Date obtained: September 4 2025\n * Copyright (c) 2024 Pedro Cattori\n */\n\nimport { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\nimport { name as pkgName } from \"../package.json\";\n\nconst macrosSpecifier = `${pkgName}/macros`;\n\nexport const isMacroBinding = (binding: Binding, macro: string): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n if (binding.path.parent.source.value !== macrosSpecifier) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n if (imported.name !== macro) {\n return false;\n }\n return true;\n};\n\nconst isMacro = (path: NodePath<t.CallExpression>, macro: string) => {\n if (!t.isIdentifier(path.node.callee)) {\n return false;\n }\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) {\n return false;\n }\n if (!isMacroBinding(binding, macro)) {\n return false;\n }\n\n if (path.node.arguments.length !== 1) {\n throw path.buildCodeFrameError(`'${macro}' must take exactly one argument`);\n }\n return true;\n};\n\nexport function transformMacros(ast: Node, options: { ssr: boolean }) {\n traverse(ast, {\n CallExpression(path) {\n if (isMacro(path, options.ssr ? \"clientOnly$\" : \"serverOnly$\")) {\n path.replaceWith(t.identifier(\"undefined\"));\n }\n if (isMacro(path, options.ssr ? \"serverOnly$\" : \"clientOnly$\")) {\n const arg = path.node.arguments[0];\n if (t.isExpression(arg)) {\n path.replaceWith(arg);\n }\n }\n },\n\n Identifier(path) {\n if (t.isImportSpecifier(path.parent)) {\n return;\n }\n\n const binding = path.scope.getBinding(path.node.name);\n if (!binding) {\n return;\n }\n if (!isMacroBinding(binding, \"serverOnly$\") && !isMacroBinding(binding, \"clientOnly$\")) {\n return;\n }\n if (t.isCallExpression(path.parent)) {\n return;\n }\n throw path.buildCodeFrameError(\n `'${path.node.name}' macro cannot be manipulated at runtime as it must be statically analysable`,\n );\n },\n\n ImportDeclaration(path) {\n if (path.node.source.value !== macrosSpecifier) {\n return;\n }\n path.node.specifiers.forEach((specifier, i) => {\n if (t.isImportNamespaceSpecifier(specifier)) {\n const subpath = path.get(`specifiers.${i}`);\n if (Array.isArray(subpath)) {\n throw new Error(\"unreachable\");\n }\n throw subpath.buildCodeFrameError(\n `Namespace import is not supported by '${macrosSpecifier}'`,\n );\n }\n });\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGES = [\"@fragno-dev/core\"];\n\nconst isAddRouteBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n if (imported.name !== \"addRoute\" && imported.name !== \"defineRoute\") {\n return false;\n }\n\n return true;\n};\n\nconst isAddRouteCall = (path: NodePath<t.CallExpression>): boolean => {\n if (!t.isIdentifier(path.node.callee)) {\n return false;\n }\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) {\n return false;\n }\n\n return isAddRouteBinding(binding);\n};\n\nfunction replaceHandlerWithNoop(routeConfig: t.Expression) {\n if (!t.isObjectExpression(routeConfig)) {\n return;\n }\n\n const handlerProp = routeConfig.properties.find((prop) => {\n if (t.isObjectProperty(prop) || t.isObjectMethod(prop)) {\n const key = prop.key;\n return t.isIdentifier(key) && key.name === \"handler\";\n }\n return false;\n });\n\n if (!handlerProp) {\n return;\n }\n\n if (t.isObjectProperty(handlerProp)) {\n handlerProp.value = t.arrowFunctionExpression([], t.blockStatement([]));\n } else if (t.isObjectMethod(handlerProp)) {\n handlerProp.body = t.blockStatement([]);\n handlerProp.params = [];\n }\n}\n\nexport function transformDefineRoute(ast: Node, options: { ssr: boolean }) {\n if (options.ssr) {\n return;\n }\n\n traverse(ast, {\n CallExpression(path) {\n if (!isAddRouteCall(path)) {\n return;\n }\n\n if (path.node.arguments.length > 0) {\n const firstArg = path.node.arguments[0];\n if (t.isExpression(firstArg)) {\n replaceHandlerWithNoop(firstArg);\n }\n }\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, Scope } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGE_DEFINITIONS = {\n \"@fragno-dev/core\": {\n fragmentDefinitions: [\"defineFragment\"],\n chainMethods: [\"withDependencies\", \"providesService\"],\n },\n \"@fragno-dev/db\": {\n fragmentDefinitions: [\"defineFragmentWithDatabase\"],\n chainMethods: [\"withDependencies\", \"providesService\", \"withDatabase\"],\n utilityFunctions: [\"schema\"],\n },\n} as const;\n\ntype PackageDefinition =\n (typeof FRAGNO_PACKAGE_DEFINITIONS)[keyof typeof FRAGNO_PACKAGE_DEFINITIONS];\n\nconst getPackageDefinition = (source: string): PackageDefinition | undefined => {\n for (const [pkg, definition] of Object.entries(FRAGNO_PACKAGE_DEFINITIONS)) {\n if (source === pkg || source.startsWith(`${pkg}/`)) {\n return definition;\n }\n }\n return undefined;\n};\n\nconst getAllChainMethods = (): Set<string> => {\n const methods = new Set<string>();\n for (const definition of Object.values(FRAGNO_PACKAGE_DEFINITIONS)) {\n if (\"chainMethods\" in definition) {\n for (const method of definition.chainMethods) {\n methods.add(method);\n }\n }\n }\n return methods;\n};\n\nconst isDefineLibraryBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n const definition = getPackageDefinition(source);\n\n if (!definition || !(\"fragmentDefinitions\" in definition)) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n // Safe cast: we checked that fragmentDefinitions exists above\n if (!(definition.fragmentDefinitions as readonly string[]).includes(imported.name)) {\n return false;\n }\n\n return true;\n};\n\nconst isUtilityFunctionBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n const definition = getPackageDefinition(source);\n\n if (!definition || !(\"utilityFunctions\" in definition)) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n // Safe cast: we checked that utilityFunctions exists above\n if (!(definition.utilityFunctions as readonly string[]).includes(imported.name)) {\n return false;\n }\n\n return true;\n};\n\nconst isDefineLibraryCall = (node: t.CallExpression, scope: Scope): boolean => {\n if (!t.isIdentifier(node.callee)) {\n return false;\n }\n\n const binding = scope.getBinding(node.callee.name);\n\n if (!binding) {\n // After transformation, we might have created a defineFragment identifier\n // that doesn't have a binding yet. Check by name as a fallback.\n return node.callee.name === \"defineFragment\";\n }\n\n return isDefineLibraryBinding(binding) || isDefineFragmentWithDatabaseBinding(binding);\n};\n\nconst createNoOpArrowFunction = (): t.ArrowFunctionExpression => {\n return t.arrowFunctionExpression([], t.blockStatement([]));\n};\n\n/**\n * Create an arrow function that returns its first parameter.\n * Used for utility functions like schema() where the callback needs to return a builder.\n */\nconst createPassThroughArrowFunction = (): t.ArrowFunctionExpression => {\n const param = t.identifier(\"s\");\n return t.arrowFunctionExpression([param], param);\n};\n\nconst isDefineLibraryChain = (node: t.Node, scope: Scope): boolean => {\n // Check direct defineFragment call\n if (t.isCallExpression(node) && isDefineLibraryCall(node, scope)) {\n return true;\n }\n\n // Check chained method calls\n if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) {\n return isDefineLibraryChain(node.callee.object, scope);\n }\n\n // Check if it's an identifier that refers to a defineFragment result\n if (t.isIdentifier(node)) {\n const binding = scope.getBinding(node.name);\n if (binding && binding.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init) {\n return isDefineLibraryChain(init, scope);\n }\n }\n }\n\n return false;\n};\n\n/**\n * Ensures that 'defineFragment' from '@fragno-dev/core' is imported in the AST.\n * If it's not imported, adds the import statement.\n */\nconst ensureDefineFragmentImport = (ast: Node): void => {\n let hasDefineFragmentImport = false;\n let foundCoreImport = false;\n\n const newImportSpecifier = t.importSpecifier(\n t.identifier(\"defineFragment\"),\n t.identifier(\"defineFragment\"),\n );\n\n // Check if defineFragment is already imported, and add it if not\n traverse(ast, {\n ImportDeclaration(path) {\n const source = path.node.source.value;\n if (source === \"@fragno-dev/core\" || source.startsWith(\"@fragno-dev/core/\")) {\n foundCoreImport = true;\n for (const specifier of path.node.specifiers) {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n specifier.imported.name === \"defineFragment\"\n ) {\n hasDefineFragmentImport = true;\n return;\n }\n }\n\n // If we found the core import but not defineFragment, add it\n if (!hasDefineFragmentImport) {\n path.node.specifiers.push(newImportSpecifier);\n hasDefineFragmentImport = true;\n }\n }\n },\n });\n\n // If no @fragno-dev/core import exists, create one\n if (!foundCoreImport && !hasDefineFragmentImport) {\n const newImport = t.importDeclaration(\n [newImportSpecifier],\n t.stringLiteral(\"@fragno-dev/core\"),\n );\n\n // Add at the beginning of the file\n if (t.isProgram(ast)) {\n ast.body.unshift(newImport);\n } else if (t.isFile(ast)) {\n ast.program.body.unshift(newImport);\n }\n }\n};\n\nconst isDefineFragmentWithDatabaseBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n if (source !== \"@fragno-dev/db\" && !source.startsWith(\"@fragno-dev/db/\")) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n return imported.name === \"defineFragmentWithDatabase\";\n};\n\nexport function transformDefineLibrary(ast: Node, options: { ssr: boolean }): void {\n if (options.ssr) {\n return;\n }\n\n const chainMethods = getAllChainMethods();\n let needsDefineFragmentImport = false;\n\n traverse(ast, {\n CallExpression(path) {\n const { callee } = path.node;\n\n // Check if this is a utility function call (like schema)\n if (t.isIdentifier(callee)) {\n const binding = path.scope.getBinding(callee.name);\n if (binding && isUtilityFunctionBinding(binding)) {\n // Replace with a pass-through function that returns its parameter\n // This prevents errors like \"Cannot read properties of undefined (reading 'build')\"\n // when schema(() => {}) would return undefined\n path.node.arguments = [createPassThroughArrowFunction()];\n return;\n }\n\n // Check if this is a defineFragmentWithDatabase call\n if (binding && isDefineFragmentWithDatabaseBinding(binding)) {\n // Replace with defineFragment\n path.node.callee = t.identifier(\"defineFragment\");\n needsDefineFragmentImport = true;\n return;\n }\n }\n\n // Check if this is a method call\n if (!t.isMemberExpression(callee)) {\n return;\n }\n\n const { property, object } = callee;\n\n // Check if the method is a chain method\n if (!t.isIdentifier(property)) {\n return;\n }\n\n const methodName = property.name;\n\n // Check if this is a withDatabase call - remove it entirely\n if (methodName === \"withDatabase\" && isDefineLibraryChain(object, path.scope)) {\n // Replace the entire call expression with just the object (removes .withDatabase(...))\n path.replaceWith(object);\n return;\n }\n\n if (!chainMethods.has(methodName)) {\n return;\n }\n\n // Check if this is part of a defineFragment chain\n if (!isDefineLibraryChain(object, path.scope)) {\n return;\n }\n\n // Replace the argument with a no-op function\n path.node.arguments = [createNoOpArrowFunction()];\n },\n });\n\n // Add defineFragment import if needed\n if (needsDefineFragmentImport) {\n ensureDefineFragmentImport(ast);\n }\n}\n","import * as babel from \"@babel/core\";\nimport { parse } from \"@babel/parser\";\nimport { generate } from \"@babel/generator\";\nimport type { GeneratorResult } from \"@babel/generator\";\n\nimport { deadCodeElimination, findReferencedIdentifiers } from \"babel-dead-code-elimination\";\nimport { transformMacros } from \"./transform-macros\";\nimport { transformDefineRoute } from \"./transform-define-route\";\nimport { transformDefineLibrary } from \"./transform-define-library\";\n\nexport const transform = (code: string, id: string, options: { ssr: boolean }): GeneratorResult => {\n const ast = parse(code, { sourceType: \"module\", plugins: [[\"typescript\", {}]] });\n\n // - https://github.com/babel/babel/issues/11889\n // - https://github.com/babel/babel/issues/11350#issuecomment-606169054\n // @ts-expect-error `@types/babel__core` is missing types for `File`\n new babel.File({ filename: undefined }, { code, ast });\n\n const refs = findReferencedIdentifiers(ast);\n\n transformMacros(ast, options);\n transformDefineRoute(ast, options);\n transformDefineLibrary(ast, options);\n\n deadCodeElimination(ast, refs);\n return generate(ast, { sourceMaps: true, sourceFileName: id }, code);\n};\n","import type { UnpluginFactory } from \"unplugin\";\nimport type { Options } from \"./types\";\nimport { createUnplugin } from \"unplugin\";\nimport { transform } from \"./transform\";\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const { platform } = options;\n\n if (platform !== \"browser\") {\n return [];\n }\n\n return {\n name: \"unplugin-fragno\",\n\n transformInclude(id) {\n if (id.endsWith(\".d.ts\")) {\n return false;\n }\n\n if (id.includes(\"@fragno-dev/unplugin-fragno\") || id.includes(\"@fragno-dev/core\")) {\n return false;\n }\n\n return true;\n },\n transform(code, id) {\n return transform(code, id, { ssr: false });\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\nexport type { Options };\nexport { isMacroBinding } from \"./transform-macros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