@velastack/patterns 0.0.10 → 0.0.11

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.
@@ -1,6 +1,6 @@
1
1
  import { readFileSync as s } from "node:fs";
2
- import { l as c } from "./index-DrD7d78j.js";
3
- import { w as l, g as u } from "./pocketbase-ByyTgVI6.js";
2
+ import { l as c } from "./index-Dv0XurQu.js";
3
+ import { w as l, g as u } from "./pocketbase-CpbH-4-D.js";
4
4
  function m(o) {
5
5
  var n, a, t, e;
6
6
  if (((t = (a = (n = o.response) == null ? void 0 : n.data) == null ? void 0 : a.name) == null ? void 0 : t.code) === "validation_not_unique")
@@ -35,4 +35,4 @@ async function h(o, r) {
35
35
  export {
36
36
  h as createCollections
37
37
  };
38
- //# sourceMappingURL=collections-Bo7ZRBqp.js.map
38
+ //# sourceMappingURL=collections-CVHa6B6X.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections-Bo7ZRBqp.js","sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { CollectionSpec, File, Options } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return message.includes(\"already exists\") || message.includes(\"must be unique\");\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n\n const migrationFile = getMigrationFile(collection.name, \"created\", options);\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n return migrations;\n}\n"],"names":["isCollectionAlreadyExistsError","error","_c","_b","_a","message","_d","createCollections","collections","options","migrations","withPocketbase","pb","collection","migrationFile","getMigrationFile","languageFromPath","readFileSync"],"mappings":";;;AAgBA,SAASA,EACPC,GACS;;AACT,QAAIC,KAAAC,KAAAC,IAAAH,EAAM,aAAN,gBAAAG,EAAgB,SAAhB,gBAAAD,EAAsB,SAAtB,gBAAAD,EAA4B,UAAS;AACvC,WAAO;AAGT,QAAMG,MAAUC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,kBAAiB;AAChD,SAAOD,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAChF;AAEA,eAAsBE,EACpBC,GACAC,GACiB;AACjB,MAAID,EAAY,WAAW;AACzB,WAAO,CAAA;AAGT,QAAME,IAAqB,CAAA;AAE3B,eAAMC,EAAeF,EAAQ,MAAM,OAAOG,MAAO;AAC/C,eAAWC,KAAcL,GAAa;AACpC,UAAI;AACF,cAAMI,EAAG,YAAY,OAAOC,CAAU;AAAA,MACxC,SAASZ,GAAO;AACd,cACED;AAAA,UACEC;AAAA,QAAA,IAGI,IAAI;AAAA,UACR,eAAeY,EAAW,IAAI;AAAA,QAAA,IAG5BZ;AAAA,MACR;AAEA,YAAMa,IAAgBC,EAAiBF,EAAW,MAAM,WAAWJ,CAAO;AAC1E,MAAKK,KAILJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IACH;AAAA,EACF,CAAC,GAEMJ;AACT;"}
1
+ {"version":3,"file":"collections-CVHa6B6X.js","sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { CollectionSpec, File, Options } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return message.includes(\"already exists\") || message.includes(\"must be unique\");\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n\n const migrationFile = getMigrationFile(collection.name, \"created\", options);\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n return migrations;\n}\n"],"names":["isCollectionAlreadyExistsError","error","_c","_b","_a","message","_d","createCollections","collections","options","migrations","withPocketbase","pb","collection","migrationFile","getMigrationFile","languageFromPath","readFileSync"],"mappings":";;;AAgBA,SAASA,EACPC,GACS;;AACT,QAAIC,KAAAC,KAAAC,IAAAH,EAAM,aAAN,gBAAAG,EAAgB,SAAhB,gBAAAD,EAAsB,SAAtB,gBAAAD,EAA4B,UAAS;AACvC,WAAO;AAGT,QAAMG,MAAUC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,kBAAiB;AAChD,SAAOD,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAChF;AAEA,eAAsBE,EACpBC,GACAC,GACiB;AACjB,MAAID,EAAY,WAAW;AACzB,WAAO,CAAA;AAGT,QAAME,IAAqB,CAAA;AAE3B,eAAMC,EAAeF,EAAQ,MAAM,OAAOG,MAAO;AAC/C,eAAWC,KAAcL,GAAa;AACpC,UAAI;AACF,cAAMI,EAAG,YAAY,OAAOC,CAAU;AAAA,MACxC,SAASZ,GAAO;AACd,cACED;AAAA,UACEC;AAAA,QAAA,IAGI,IAAI;AAAA,UACR,eAAeY,EAAW,IAAI;AAAA,QAAA,IAG5BZ;AAAA,MACR;AAEA,YAAMa,IAAgBC,EAAiBF,EAAW,MAAM,WAAWJ,CAAO;AAC1E,MAAKK,KAILJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IACH;AAAA,EACF,CAAC,GAEMJ;AACT;"}
@@ -2,7 +2,7 @@ import { getCollections as i } from "@velastack/pocketbase/internal";
2
2
  import s from "node:fs";
3
3
  import r from "node:path";
4
4
  import t from "node:process";
5
- import { D as c } from "./index-DrD7d78j.js";
5
+ import { D as c } from "./index-Dv0XurQu.js";
6
6
  function a(o) {
7
7
  return s.existsSync(r.join(o, "package.json")) && s.existsSync(r.join(o, c));
8
8
  }
@@ -33,4 +33,4 @@ export {
33
33
  S as getCollections,
34
34
  p as resolveProjectRoot
35
35
  };
36
- //# sourceMappingURL=env.runtime-DhK42aCc.js.map
36
+ //# sourceMappingURL=env.runtime-DSiCFHzi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.runtime-DhK42aCc.js","sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { DATA_DIR } from \"../core/constants\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, DATA_DIR))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json, and ${DATA_DIR}.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"env.runtime-DSiCFHzi.js","sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { DATA_DIR } from \"../core/constants\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, DATA_DIR))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json, and ${DATA_DIR}.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
@@ -1,7 +1,7 @@
1
1
  import y from "node:path";
2
2
  import m from "node:fs";
3
- import { w as v, g as S } from "./pocketbase-ByyTgVI6.js";
4
- import { d as A } from "./index-DrD7d78j.js";
3
+ import { w as v, g as S } from "./pocketbase-CpbH-4-D.js";
4
+ import { d as A } from "./index-Dv0XurQu.js";
5
5
  import { Project as b, SyntaxKind as s } from "ts-morph";
6
6
  function w(u) {
7
7
  if (!m.existsSync(u)) {
@@ -256,7 +256,7 @@ function K(u) {
256
256
  }
257
257
  n.formatText(), n.saveSync();
258
258
  }
259
- async function R(u) {
259
+ async function T(u) {
260
260
  const { input: o } = u;
261
261
  let n = [];
262
262
  await v(u.root, async (d) => {
@@ -348,6 +348,6 @@ async function R(u) {
348
348
  };
349
349
  }
350
350
  export {
351
- R as generate
351
+ T as generate
352
352
  };
353
- //# sourceMappingURL=generate.runtime-BhWmEK-_.js.map
353
+ //# sourceMappingURL=generate.runtime-Q3r4DJ7e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-Q3r4DJ7e.js","sources":["../../src/patterns/enable/auth/modifies/+layout.server.ts","../../src/patterns/enable/auth/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth/modifies/hooks.server.ts","../../src/patterns/enable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyLayoutServer(layoutPath: string) {\n if (!fs.existsSync(layoutPath)) {\n // write file directly\n\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return;\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\n\nexport function modifyRootLayoutSvelte(layoutPath: string) {\n let layout = fs.readFileSync(layoutPath, \"utf8\");\n // TODO: use magic-string to modify the layout\n\n // find the navbar.root > navbar.list\n const navbarRoot = layout.match(/<Navbar\\.Root>([\\s\\S]*?)<\\/Navbar\\.Root>/);\n if (!navbarRoot) {\n return;\n }\n\n const navbarList = navbarRoot[1].match(\n /<Navbar\\.List>([\\s\\S]*?)<\\/Navbar\\.List>/,\n );\n if (!navbarList) {\n return;\n }\n\n // add imports\n const imports = dedent`\n\t\timport * as AuthMenu from '$lib/components/ui/auth-menu';\n\t\timport * as Avatar from '$lib/components/ui/avatar';\n\t`;\n\n // Insert imports after the last existing import inside the first <script> block (if any)\n const scriptOpenIdx = layout.indexOf(\"<script\");\n if (scriptOpenIdx !== -1) {\n const scriptOpenEnd = layout.indexOf(\">\", scriptOpenIdx);\n const scriptCloseIdx =\n scriptOpenEnd !== -1\n ? layout.indexOf(\"</script>\", scriptOpenEnd + 1)\n : -1;\n if (scriptOpenEnd !== -1 && scriptCloseIdx !== -1) {\n const scriptContent = layout.slice(scriptOpenEnd + 1, scriptCloseIdx);\n let lastImportEnd = -1;\n const importRegex = /^\\s*import[\\s\\S]*?;[ \\t]*$/gm;\n let match: RegExpExecArray | null;\n while ((match = importRegex.exec(scriptContent)) !== null) {\n lastImportEnd = match.index + match[0].length;\n }\n\n if (lastImportEnd !== -1) {\n const before = scriptContent.slice(0, lastImportEnd);\n const after = scriptContent.slice(lastImportEnd);\n const newScriptContent = `${before}\\n${imports}\\n${after}`;\n layout =\n layout.slice(0, scriptOpenEnd + 1) +\n newScriptContent +\n layout.slice(scriptCloseIdx);\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n\n // add the auth menu to the navbar.list\n const newNavbarList =\n navbarList[1] +\n `\n\t\t\t<Navbar.Item\n\t\t\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t\t>\n\t\t\t\t\t<AuthMenu.Root>\n\t\t\t\t\t\t\t{#snippet user()}\n\t\t\t\t\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t\t\t\t{/snippet}\n\n\t\t\t\t\t\t\t{#snippet guest()}\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/snippet}\n\t\t\t\t\t</AuthMenu.Root>\n\t\t\t</Navbar.Item>\n\t\t`;\n\n // replace the navbar.list with the new one\n layout = layout.replace(navbarList[1], newNavbarList);\n\n fs.writeFileSync(layoutPath, layout);\n}\n","import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n // Create an options object if missing\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n // Replace non-object first arg with an object including auth\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n // Replace non-array with desired value\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getMigrationFile, withPocketbase } from \"../../../runtime/pocketbase\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-password-reset/{TOKEN}\",\n \"{APP_URL}/confirm-password-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n // Modify files\n let modifies: File[] = [];\n\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n\n await modifyLayoutServer(layoutServerFile);\n modifies.push({\n path: layoutServerFile,\n language: \"ts\",\n content: fs.readFileSync(layoutServerFile, \"utf8\"),\n });\n\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n let layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\");\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"+layout.svelte\",\n );\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n }\n\n if (fs.existsSync(layoutFile)) {\n modifyRootLayoutSvelte(layoutFile);\n modifies.push({\n path: layoutFile,\n language: \"svelte\",\n content: fs.readFileSync(layoutFile, \"utf8\"),\n });\n }\n\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n\n if (fs.existsSync(hooksServerFile)) {\n modifyHooksServer(hooksServerFile);\n modifies.push({\n path: hooksServerFile,\n language: \"ts\",\n content: fs.readFileSync(hooksServerFile, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyLayoutServer","layoutPath","fs","snippet","dedent","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","vs","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","ret","expr","inner","bodyExpr","modifyRootLayoutSvelte","layout","navbarRoot","navbarList","imports","scriptOpenIdx","scriptOpenEnd","scriptCloseIdx","scriptContent","lastImportEnd","importRegex","match","before","after","newScriptContent","newNavbarList","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","generate","options","input","creates","withPocketbase","pb","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","getMigrationFile","modifies","layoutServerFile","path","layoutFile","hooksServerFile"],"mappings":";;;;;AAIO,SAASA,EAAmBC,GAAoB;AACrD,MAAI,CAACC,EAAG,WAAWD,CAAU,GAAG;AAG9B,UAAME,IAAUC;AAAA;AAAA;AAAA;AAAA;AAMhB,IAAAF,EAAG,cAAcD,GAAYE,CAAO;AACpC;AAAA,EACF;AAGA,QAAME,IADU,IAAIC,EAAA,EACO,oBAAoBL,CAAU,GAGnDM,IAAc,CAACC,MAAoD;AAEvE,IADgB,CAAC,CAACA,EAAI,YAAY,MAAM,KAEtCA,EAAI,sBAAsB;AAAA,MACxB,MAAM;AAAA,MACN,aAAa;AAAA,IAAA,CACd;AAAA,EAEL;AAGA,MAAI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AA,IACN,UAAU;AAAA,IACV,SAAS1E,EAAG,aAAa0E,GAAkB,MAAM;AAAA,EAAA,CAClD;AAID,MAAIE,IAAaD,EAAK;AAAA,IACpBb,EAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,EAAK9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,oBAAoB,IAGvE9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK;AAAA,IAChBb,EAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IAIC9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,gBAAgB,IAGpE9D,EAAG,WAAW4E,CAAU,MAC1B5C,EAAuB4C,CAAU,GACjCH,EAAS,KAAK;AAAA,IACZ,MAAMG;AAAA,IACN,UAAU;AAAA,IACV,SAAS5E,EAAG,aAAa4E,GAAY,MAAM;AAAA,EAAA,CAC5C;AAGH,QAAMC,IAAkBF,EAAK,KAAKb,EAAQ,MAAM,OAAO,iBAAiB;AAExE,SAAI9D,EAAG,WAAW6E,CAAe,MAC/B7B,EAAkB6B,CAAe,GACjCJ,EAAS,KAAK;AAAA,IACZ,MAAMI;AAAA,IACN,UAAU;AAAA,IACV,SAAS7E,EAAG,aAAa6E,GAAiB,MAAM;AAAA,EAAA,CACjD,IAGI;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAJ;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
@@ -1637,7 +1637,7 @@ function tn(t, e, n, r) {
1637
1637
  async function J(t, e, n) {
1638
1638
  let r;
1639
1639
  if (n.env === "runtime") {
1640
- const { getCollections: o } = await import("./env.runtime-DhK42aCc.js");
1640
+ const { getCollections: o } = await import("./env.runtime-DSiCFHzi.js");
1641
1641
  r = await o();
1642
1642
  } else {
1643
1643
  const { getPreviewCollections: o } = await import("./env.preview-HlXZOEL4.js");
@@ -2191,7 +2191,7 @@ function V(t, e) {
2191
2191
  async function xn(t) {
2192
2192
  const { modelPath: e, fields: n } = fn(t.argv);
2193
2193
  W(e);
2194
- const r = M(e, t), s = (await J(n, r, t)).fields, { pagePath: i, pageUrl: a } = pn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
2194
+ const r = M(e, t), s = (await J(n, r, t)).fields, { pagePath: i, pageUrl: a } = pn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
2195
2195
  t
2196
2196
  ), m = [
2197
2197
  V(`${i}/+page.svelte`, yn(r, s)),
@@ -2508,7 +2508,7 @@ async function An(t, e, n) {
2508
2508
  const i = await J(n, r, t);
2509
2509
  return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
2510
2510
  }
2511
- const o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
2511
+ const o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
2512
2512
  return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
2513
2513
  }
2514
2514
  async function Nn(t) {
@@ -2534,7 +2534,7 @@ async function Vn(t) {
2534
2534
  const e = await Nn(t);
2535
2535
  if (t.env !== "runtime")
2536
2536
  return k(e);
2537
- const { createCollections: n } = await import("./collections-Bo7ZRBqp.js"), r = await n(
2537
+ const { createCollections: n } = await import("./collections-CVHa6B6X.js"), r = await n(
2538
2538
  e.collections,
2539
2539
  t
2540
2540
  ), o = {
@@ -3281,7 +3281,7 @@ function er(t, e, n, r) {
3281
3281
  }
3282
3282
  async function nr(t, e, n) {
3283
3283
  W(e);
3284
- const r = M(e, t), o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
3284
+ const r = M(e, t), o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(
3285
3285
  t
3286
3286
  );
3287
3287
  if (n.length > 0) {
@@ -3385,7 +3385,7 @@ async function lr(t) {
3385
3385
  const e = await rr(t);
3386
3386
  if (t.env !== "runtime")
3387
3387
  return k(e);
3388
- const { createCollections: n } = await import("./collections-Bo7ZRBqp.js"), r = await n(
3388
+ const { createCollections: n } = await import("./collections-CVHa6B6X.js"), r = await n(
3389
3389
  e.collections,
3390
3390
  t
3391
3391
  ), o = {
@@ -3438,7 +3438,7 @@ async function dr(t, e, n) {
3438
3438
  const i = await J(n, r, t);
3439
3439
  return { model: r, fields: i.fields, includeModelFields: !1 };
3440
3440
  }
3441
- const o = t.env === "runtime" ? await (await import("./env.runtime-DhK42aCc.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
3441
+ const o = t.env === "runtime" ? await (await import("./env.runtime-DSiCFHzi.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, o, t);
3442
3442
  return { model: r, fields: s, includeModelFields: !0 };
3443
3443
  }
3444
3444
  async function pr(t) {
@@ -5434,14 +5434,14 @@ export const handle = handlePocketbase({
5434
5434
  pocketbaseUrl: POCKETBASE_URL,
5435
5435
  superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
5436
5436
  superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,
5437
- auth: { protectedRoutes: ["/(app)"] }, // [!code ++]
5437
+ + auth: { protectedRoutes: ["/(app)"] },
5438
5438
  });
5439
5439
  `, ua = `<script lang="ts">
5440
5440
  import { toggleMode } from "mode-watcher";
5441
5441
  import * as Navbar from "$lib/components/ui/navbar";
5442
5442
  import { Button } from "$lib/components/ui/button";
5443
- import * as AuthMenu from "$lib/components/ui/auth-menu";
5444
- import * as Avatar from "$lib/components/ui/avatar";
5443
+ + import * as AuthMenu from "$lib/components/ui/auth-menu";
5444
+ + import * as Avatar from "$lib/components/ui/avatar";
5445
5445
 
5446
5446
  let { children, data } = $props();
5447
5447
  <\/script>
@@ -5465,52 +5465,52 @@ export const handle = handlePocketbase({
5465
5465
  </Button>
5466
5466
  </Navbar.Item>
5467
5467
 
5468
- <Navbar.Item
5469
- class="flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4"
5470
- >
5471
- <AuthMenu.Root>
5472
- {#snippet user()}
5473
- <AuthMenu.Trigger>
5474
- <Avatar.Root>
5475
- {#if data.user?.avatar}
5476
- <Avatar.Image
5477
- src="/api/files/users/{data.user?.id}/{data.user?.avatar}"
5478
- alt={data.user?.email}
5479
- />
5480
- {/if}
5481
- <Avatar.Fallback>
5482
- {data.user?.email?.charAt(0).toUpperCase()}
5483
- </Avatar.Fallback>
5484
- </Avatar.Root>
5485
- </AuthMenu.Trigger>
5486
-
5487
- <AuthMenu.Content align="end">
5488
- <AuthMenu.Item href="/dashboard">Dashboard</AuthMenu.Item>
5489
- <AuthMenu.Group>
5490
- <AuthMenu.Item href="/settings">Settings</AuthMenu.Item>
5491
- <AuthMenu.Item>
5492
- <form action="/logout" method="post">
5493
- <button type="submit" class="contents">Logout</button>
5494
- </form>
5495
- </AuthMenu.Item>
5496
- </AuthMenu.Group>
5497
- </AuthMenu.Content>
5498
- {/snippet}
5499
-
5500
- {#snippet guest()}
5501
- <Button
5502
- class="w-full justify-start md:justify-center md:w-auto"
5503
- variant="ghost"
5504
- href="/login">Login</Button
5505
- >
5506
- <Button
5507
- class="w-full justify-start md:justify-center md:w-auto"
5508
- variant="outline"
5509
- href="/signup">Sign up</Button
5510
- >
5511
- {/snippet}
5512
- </AuthMenu.Root>
5513
- </Navbar.Item>
5468
+ + <Navbar.Item
5469
+ + class="flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4"
5470
+ + >
5471
+ + <AuthMenu.Root>
5472
+ + {#snippet user()}
5473
+ + <AuthMenu.Trigger>
5474
+ + <Avatar.Root>
5475
+ + {#if data.user?.avatar}
5476
+ + <Avatar.Image
5477
+ + src="/api/files/users/{data.user?.id}/{data.user?.avatar}"
5478
+ + alt={data.user?.email}
5479
+ + />
5480
+ + {/if}
5481
+ + <Avatar.Fallback>
5482
+ + {data.user?.email?.charAt(0).toUpperCase()}
5483
+ + </Avatar.Fallback>
5484
+ + </Avatar.Root>
5485
+ + </AuthMenu.Trigger>
5486
+ +
5487
+ + <AuthMenu.Content align="end">
5488
+ + <AuthMenu.Item href="/dashboard">Dashboard</AuthMenu.Item>
5489
+ + <AuthMenu.Group>
5490
+ + <AuthMenu.Item href="/settings">Settings</AuthMenu.Item>
5491
+ + <AuthMenu.Item>
5492
+ + <form action="/logout" method="post">
5493
+ + <button type="submit" class="contents">Logout</button>
5494
+ + </form>
5495
+ + </AuthMenu.Item>
5496
+ + </AuthMenu.Group>
5497
+ + </AuthMenu.Content>
5498
+ + {/snippet}
5499
+ +
5500
+ + {#snippet guest()}
5501
+ + <Button
5502
+ + class="w-full justify-start md:justify-center md:w-auto"
5503
+ + variant="ghost"
5504
+ + href="/login">Login</Button
5505
+ + >
5506
+ + <Button
5507
+ + class="w-full justify-start md:justify-center md:w-auto"
5508
+ + variant="outline"
5509
+ + href="/signup">Sign up</Button
5510
+ + >
5511
+ + {/snippet}
5512
+ + </AuthMenu.Root>
5513
+ + </Navbar.Item>
5514
5514
  </Navbar.List>
5515
5515
  </Navbar.Root>
5516
5516
 
@@ -5547,7 +5547,7 @@ export const handle = handlePocketbase({
5547
5547
 
5548
5548
  export const load = loadFlash(async ({ locals }) => {
5549
5549
  return {
5550
- user: locals.pb.authStore.record, // [!code ++]
5550
+ + user: locals.pb.authStore.record,
5551
5551
  };
5552
5552
  });
5553
5553
  `, pa = /* @__PURE__ */ Object.assign({
@@ -5580,7 +5580,7 @@ async function ya(t) {
5580
5580
  const s = await ga();
5581
5581
  return k(dt([e, s]));
5582
5582
  }
5583
- const { generate: n } = await import("./generate.runtime-BhWmEK-_.js"), r = await n(t), { writeResult: o } = await import("./write-result-CbUTMeAc.js");
5583
+ const { generate: n } = await import("./generate.runtime-Q3r4DJ7e.js"), r = await n(t), { writeResult: o } = await import("./write-result-CbUTMeAc.js");
5584
5584
  return o(
5585
5585
  await k(dt([e, r])),
5586
5586
  t
@@ -5634,4 +5634,4 @@ export {
5634
5634
  Ra as i,
5635
5635
  j as l
5636
5636
  };
5637
- //# sourceMappingURL=index-DrD7d78j.js.map
5637
+ //# sourceMappingURL=index-Dv0XurQu.js.map