@velastack/patterns 0.0.43 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-VC2LOzBB.js → collections-DeT38X6O.js} +2 -2
- package/dist/chunks/{collections-VC2LOzBB.js.map → collections-DeT38X6O.js.map} +1 -1
- package/dist/chunks/{generate.runtime-LKYA2LrJ.js → generate.runtime-4F-eepmc.js} +23 -85
- package/dist/chunks/generate.runtime-4F-eepmc.js.map +1 -0
- package/dist/chunks/{generate.runtime-CczM1Zuw.js → generate.runtime-8Ciy0dLy.js} +3 -3
- package/dist/chunks/{generate.runtime-CczM1Zuw.js.map → generate.runtime-8Ciy0dLy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DrU9LGRv.js → generate.runtime-BM00PfQB.js} +2 -2
- package/dist/chunks/{generate.runtime-DrU9LGRv.js.map → generate.runtime-BM00PfQB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B07nsq-H.js → generate.runtime-BhJKZmLN.js} +2 -2
- package/dist/chunks/{generate.runtime-B07nsq-H.js.map → generate.runtime-BhJKZmLN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DZbx8giO.js → generate.runtime-C0kTnsI4.js} +1 -1
- package/dist/chunks/{generate.runtime-DZbx8giO.js.map → generate.runtime-C0kTnsI4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wy4PDbqn.js → generate.runtime-Cf_EwiYf.js} +2 -2
- package/dist/chunks/{generate.runtime-wy4PDbqn.js.map → generate.runtime-Cf_EwiYf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D5pHSGv2.js → generate.runtime-Cjr2Xa3e.js} +2 -2
- package/dist/chunks/{generate.runtime-D5pHSGv2.js.map → generate.runtime-Cjr2Xa3e.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B9YSOuDJ.js → generate.runtime-Cp5n_QqA.js} +1 -1
- package/dist/chunks/{generate.runtime-B9YSOuDJ.js.map → generate.runtime-Cp5n_QqA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-33rNLYvg.js → generate.runtime-DBAtF_T_.js} +7 -7
- package/dist/chunks/generate.runtime-DBAtF_T_.js.map +1 -0
- package/dist/chunks/{generate.runtime-DuAbZVdC.js → generate.runtime-DL1Ik7b6.js} +1 -1
- package/dist/chunks/{generate.runtime-DuAbZVdC.js.map → generate.runtime-DL1Ik7b6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DWi7AATX.js → generate.runtime-DprX2Upp.js} +3 -3
- package/dist/chunks/{generate.runtime-DWi7AATX.js.map → generate.runtime-DprX2Upp.js.map} +1 -1
- package/dist/chunks/{generate.runtime-KJTobj9H.js → generate.runtime-Dqa95On4.js} +22 -11
- package/dist/chunks/{generate.runtime-KJTobj9H.js.map → generate.runtime-Dqa95On4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CznAdWvM.js → generate.runtime-JZeLiMFO.js} +3 -3
- package/dist/chunks/{generate.runtime-CznAdWvM.js.map → generate.runtime-JZeLiMFO.js.map} +1 -1
- package/dist/chunks/generate.runtime-RfPLo7XV.js +289 -0
- package/dist/chunks/generate.runtime-RfPLo7XV.js.map +1 -0
- package/dist/chunks/{generate.runtime-PK7amfVR.js → generate.runtime-WWvlaFF2.js} +2 -2
- package/dist/chunks/{generate.runtime-PK7amfVR.js.map → generate.runtime-WWvlaFF2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dw6iUo_7.js → generate.runtime-kovRoEUU.js} +1 -1
- package/dist/chunks/{generate.runtime-Dw6iUo_7.js.map → generate.runtime-kovRoEUU.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-BUt0Wt_p.js → modify-svelte-config-remote-DenOsWro.js} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-BUt0Wt_p.js.map → modify-svelte-config-remote-DenOsWro.js.map} +1 -1
- package/dist/chunks/modify-utils-FsEBGzju.js +69 -0
- package/dist/chunks/modify-utils-FsEBGzju.js.map +1 -0
- package/dist/chunks/{pocketbase-CjSrDiqR.js → pocketbase-DYaSZ9lS.js} +1 -1
- package/dist/chunks/{pocketbase-CjSrDiqR.js.map → pocketbase-DYaSZ9lS.js.map} +1 -1
- package/dist/chunks/{shared-C55q8tz4.js → shared-B_6tQpQF.js} +2 -2
- package/dist/chunks/{shared-C55q8tz4.js.map → shared-B_6tQpQF.js.map} +1 -1
- package/dist/chunks/write-result-B5eX8Cjw.js +247 -0
- package/dist/chunks/{write-result-ByDzyVll.js.map → write-result-B5eX8Cjw.js.map} +1 -1
- package/dist/index.js +482 -483
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/generate.runtime-33rNLYvg.js.map +0 -1
- package/dist/chunks/generate.runtime-B2xOWBKK.js +0 -148
- package/dist/chunks/generate.runtime-B2xOWBKK.js.map +0 -1
- package/dist/chunks/generate.runtime-LKYA2LrJ.js.map +0 -1
- package/dist/chunks/write-result-ByDzyVll.js +0 -234
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velastack/patterns",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"description": "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"prettier-plugin-svelte": "^3.5.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@velastack/pocketbase": "^0.0.
|
|
51
|
+
"@velastack/pocketbase": "^0.0.51",
|
|
52
52
|
"cross-spawn": "^7.0.6",
|
|
53
53
|
"magic-string": "^0.30.21",
|
|
54
54
|
"package-manager-detector": "^1.6.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@types/cross-spawn": "^6.0.6",
|
|
88
88
|
"@types/node": "^22.0.0",
|
|
89
89
|
"@types/pluralize": "^0.0.33",
|
|
90
|
-
"@velastack/pocketbase": "^0.0.
|
|
90
|
+
"@velastack/pocketbase": "^0.0.51",
|
|
91
91
|
"change-case": "^5.4.4",
|
|
92
92
|
"cross-spawn": "^7.0.6",
|
|
93
93
|
"dedent": "^1.7.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-33rNLYvg.js","names":[],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-stripe-hooks.ts","../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Matches the entire cronAdd(\"stripe-subscriptions\", ...) {...}); block with\n// optional surrounding blank lines. Tolerates single- or double-quoted name\n// and trailing semicolon variants.\nconst SUBSCRIPTION_CRON_RE =\n /\\n*cronAdd\\(\\s*[\"']stripe-subscriptions[\"'][\\s\\S]*?\\}\\s*\\)\\s*;?\\s*\\n?/m;\n\nexport function unmodifyStripeHooks(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"stripe-subscriptions\")) {\n return { status: \"success\", changed: false };\n }\n const next = original.replace(SUBSCRIPTION_CRON_RE, \"\\n\");\n if (next === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n '\"customer.subscription.created\"',\n '\"customer.subscription.updated\"',\n '\"customer.subscription.deleted\"',\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/created\");\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./handlers/subscription/deleted\");\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const exprText = caseClause.getExpression().getText();\n return SUBSCRIPTION_CASE_VALUES.has(exprText);\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n sf.formatText();\n });\n\n if (source === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction updateScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"))\n .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n sf.formatText();\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import dedent from \"dedent\";\nimport { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Baseline velastack-auth (app)/+layout.server.ts — the state of the file\n// before enable-subscriptions wrapped it with loadActiveSubscription.\nconst BASELINE =\n dedent`\n export const load = ({ locals }) => {\n \\tconst user = locals.pb.authStore.record!;\n \\tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];\n\n \\treturn { user, breadcrumbs };\n };\n` + \"\\n\";\n\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n return revertByTemplate(filePath, BASELINE, \"loadActiveSubscription\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(\n filePath: string,\n paymentsNavUserTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(filePath, paymentsNavUserTemplate, \"planLabel\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\n );\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyStripeHooks } from \"./modifies/modify-stripe-hooks\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsNavUserTemplate from \"../../enable/payments/preview-modifies/src/lib/components/nav-user.svelte?raw\";\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte?raw\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting data/hooks/stripe.pb.js\");\n const stripeHooksPath = path.join(\n options.root,\n \"data\",\n \"hooks\",\n \"stripe.pb.js\",\n );\n pushResult(\n modifyOutcomeToFile(stripeHooksPath, unmodifyStripeHooks(stripeHooksPath)),\n );\n\n logger.info(\"Reverting webhooks/stripe/+server.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"+server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n unmodifyNavUser(navUserPath, paymentsNavUserTemplate),\n ),\n );\n\n logger.info(\"Reverting billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;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EACE,EACE,GACA,EAAwB,EAAoB,CAC7C,CACF,EAED,EAAO,KAAK,+BAA+B;CAC3C,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,OACA,cACA,qBACD;AAKD,CAJA,EACE,EAAoB,GAAgB,EAAmB,EAAe,CAAC,CACxE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AAQD,CAPA,EACE,EACE,GACA,EAAgB,GAAa,EAAwB,CACtD,CACF,EAED,EAAO,KAAK,oCAAoC;CAChD,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,kBACD;AAWD,CAVA,EACE,EACE,GACA,EACE,GACA,EACD,CACF,CACF,EAED,EAAO,KAAK,iCAAiC;CAC7C,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,eACD;AAgBD,QAfA,EACE,EACE,GACA,EACE,GACA,EACD,CACF,CACF,EAOM;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B,CAAC,uBAAuB,EACxB,EACD;EAWA"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./dedent-C4qKBQXh.js";
|
|
2
|
-
import { i as t } from "./util-BNtpm1tP.js";
|
|
3
|
-
import { n } from "./logger-BpgCb-ZG.js";
|
|
4
|
-
import { t as r } from "./pocketbase-Dm2SF3vM.js";
|
|
5
|
-
import { modifyOutcomeToFile as i } from "./modify-file-DE7tPADZ.js";
|
|
6
|
-
import { a, n as o, o as s } from "./ts-morph-helpers-bR0-x04t.js";
|
|
7
|
-
import { getMigrationFile as c, migrationDelay as l, withPocketbase as u } from "./pocketbase-CjSrDiqR.js";
|
|
8
|
-
import { applyCollectionRulePatches as d, createCollectionIdempotent as f } from "./collections-VC2LOzBB.js";
|
|
9
|
-
import p from "node:fs";
|
|
10
|
-
import m from "node:path";
|
|
11
|
-
//#region src/patterns/enable/notifications/modifies/modify-app-layout.ts
|
|
12
|
-
var h = "\n <div class=\"ml-auto px-4\">\n <NotificationsBell />\n </div>\n ", g = e`
|
|
13
|
-
import NotificationsBell from '$lib/components/notifications-bell.svelte';
|
|
14
|
-
`, _ = [
|
|
15
|
-
"Add the notifications bell inside the (app) layout's <header>.",
|
|
16
|
-
"",
|
|
17
|
-
"Imports to add to the <script> tag:",
|
|
18
|
-
"",
|
|
19
|
-
g,
|
|
20
|
-
"",
|
|
21
|
-
"Markup to add inside <header>:",
|
|
22
|
-
h
|
|
23
|
-
].join("\n"), v = [
|
|
24
|
-
"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.",
|
|
25
|
-
"",
|
|
26
|
-
"Imports for the <script> tag:",
|
|
27
|
-
"",
|
|
28
|
-
g,
|
|
29
|
-
"",
|
|
30
|
-
"Markup inside <header>:",
|
|
31
|
-
h
|
|
32
|
-
].join("\n");
|
|
33
|
-
function y(e) {
|
|
34
|
-
if (!p.existsSync(e)) return {
|
|
35
|
-
status: "not-found",
|
|
36
|
-
message: v
|
|
37
|
-
};
|
|
38
|
-
let t = s.fromPath(e);
|
|
39
|
-
return t.hasElement("header") ? t.hasElement("NotificationsBell") ? {
|
|
40
|
-
status: "success",
|
|
41
|
-
changed: !1
|
|
42
|
-
} : (t.modifyScript((e) => {
|
|
43
|
-
let { source: t } = a(e, (e) => {
|
|
44
|
-
o(e, [{
|
|
45
|
-
defaultImport: "NotificationsBell",
|
|
46
|
-
moduleSpecifier: "$lib/components/notifications-bell.svelte"
|
|
47
|
-
}]);
|
|
48
|
-
});
|
|
49
|
-
return t;
|
|
50
|
-
}), t.insertBeforeClosingTag("header", h), t.writeTo(e), {
|
|
51
|
-
status: "success",
|
|
52
|
-
changed: t.hasChanged()
|
|
53
|
-
}) : {
|
|
54
|
-
status: "failed",
|
|
55
|
-
message: _
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/patterns/enable/notifications/generate.runtime.ts
|
|
60
|
-
async function b(e, n, r, i = !0) {
|
|
61
|
-
if (!i) return;
|
|
62
|
-
await l();
|
|
63
|
-
let a = c(n, "created", r);
|
|
64
|
-
a && e.push({
|
|
65
|
-
path: a,
|
|
66
|
-
language: t(a),
|
|
67
|
-
content: p.readFileSync(a, "utf8"),
|
|
68
|
-
status: "success"
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async function x(e) {
|
|
72
|
-
let t = n(e), a = [];
|
|
73
|
-
await u(e.root, async (n) => {
|
|
74
|
-
let i = await n.collections.getOne("users");
|
|
75
|
-
t.info("Creating notifications collection"), await b(a, "notifications", e, (await ((e) => f(n, e, t))({
|
|
76
|
-
name: "notifications",
|
|
77
|
-
type: "base",
|
|
78
|
-
fields: [
|
|
79
|
-
{
|
|
80
|
-
name: "id",
|
|
81
|
-
type: "text",
|
|
82
|
-
primaryKey: !0,
|
|
83
|
-
autogeneratePattern: "[a-z0-9]{15}",
|
|
84
|
-
max: 15,
|
|
85
|
-
min: 15,
|
|
86
|
-
pattern: "^[a-z0-9]+$",
|
|
87
|
-
required: !0
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "user",
|
|
91
|
-
type: "relation",
|
|
92
|
-
cascadeDelete: !0,
|
|
93
|
-
collectionId: i.id,
|
|
94
|
-
maxSelect: 1,
|
|
95
|
-
minSelect: 0,
|
|
96
|
-
required: !0
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: "title",
|
|
100
|
-
type: "text",
|
|
101
|
-
required: !0
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "body",
|
|
105
|
-
type: "text"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "read",
|
|
109
|
-
type: "bool"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: "created",
|
|
113
|
-
type: "autodate",
|
|
114
|
-
onCreate: !0,
|
|
115
|
-
onUpdate: !1
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: "updated",
|
|
119
|
-
type: "autodate",
|
|
120
|
-
onCreate: !0,
|
|
121
|
-
onUpdate: !0
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"]
|
|
125
|
-
})).created), t.info("Applying notifications rule patches");
|
|
126
|
-
let o = await d(n, r, e, t);
|
|
127
|
-
a.push(...o);
|
|
128
|
-
});
|
|
129
|
-
let o = [], s = (e) => {
|
|
130
|
-
e && o.push(e);
|
|
131
|
-
};
|
|
132
|
-
t.info("Modifying (app) +layout.svelte");
|
|
133
|
-
let c = m.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
134
|
-
return s(i(c, y(c))), {
|
|
135
|
-
creates: a,
|
|
136
|
-
modifies: o,
|
|
137
|
-
deletes: [],
|
|
138
|
-
components: [],
|
|
139
|
-
packages: [],
|
|
140
|
-
collections: [],
|
|
141
|
-
collectionPatches: [],
|
|
142
|
-
collectionDrops: []
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
export { x as generate };
|
|
147
|
-
|
|
148
|
-
//# sourceMappingURL=generate.runtime-B2xOWBKK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-B2xOWBKK.js","names":[],"sources":["../../src/patterns/enable/notifications/modifies/modify-app-layout.ts","../../src/patterns/enable/notifications/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BELL_SNIPPET = `\n\t\t<div class=\"ml-auto px-4\">\n\t\t\t<NotificationsBell />\n\t\t</div>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import NotificationsBell from '$lib/components/notifications-bell.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the notifications bell inside the (app) layout's <header>.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyAppLayout(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"NotificationsBell\",\n moduleSpecifier: \"$lib/components/notifications-bell.svelte\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"header\", BELL_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { NOTIFICATION_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating notifications collection\");\n const result = await create({\n name: \"notifications\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"user\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"title\",\n type: \"text\",\n required: true,\n },\n {\n name: \"body\",\n type: \"text\",\n },\n {\n name: \"read\",\n type: \"bool\",\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n indexes: [\n \"CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"notifications\",\n options,\n result.created,\n );\n\n logger.info(\"Applying notifications rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n NOTIFICATION_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayout(appLayoutPath)),\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAM,IAAe,2EAMf,IAAiB,CAAM;;GAIvB,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EAAgB,GAAmC;AACjE,KAAI,CAAC,EAAG,WAAW,EAAW,CAC5B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAO,EAAW,SAAS,EAAW;AAsB5C,QArBK,EAAK,WAAW,SAAS,GAG1B,EAAK,WAAW,oBAAoB,GAC/B;EAAE,QAAQ;EAAW,SAAS;EAAO,IAG9C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;AACzD,KAAc,GAAI,CAChB;IACE,eAAe;IACf,iBAAiB;IAClB,CACF,CAAC;IACF;AACF,SAAO;GACP,EAEF,EAAK,uBAAuB,UAAU,EAAa,EACnD,EAAK,QAAQ,EAAW,EACjB;EAAE,QAAQ;EAAW,SAAS,EAAK,YAAY;EAAE,IApB/C;EAAE,QAAQ;EAAU,SAAS;EAAc;;;;AC9BtD,eAAe,EACb,GACA,GACA,GACA,IAAU,IACV;AACA,KAAI,CAAC,EAAS;AACd,OAAM,GAAgB;CACtB,IAAM,IAAgB,EAAiB,GAAgB,WAAW,EAAQ;AACrE,MACL,EAAQ,KAAK;EACX,MAAM;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ACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-LKYA2LrJ.js","names":[],"sources":["../../src/patterns/enable/api-keys/modifies/hooks.server.ts","../../src/patterns/enable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/enable/api-keys/modifies/utils.ts","../../src/patterns/enable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with API keys in hooks.server.ts:\n\n handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(\n 0,\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true, apiKeys: { enabled: true } }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n apiObj.addPropertyAssignment({\n name: \"apiKeys\",\n initializer: `{ enabled: true }`,\n });\n } else if (apiKeysProp.getKind() === SyntaxKind.PropertyAssignment) {\n const keysInit = (\n apiKeysProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (\n keysInit &&\n keysInit.getKind() === SyntaxKind.ObjectLiteralExpression\n ) {\n const keysObj =\n keysInit as import(\"ts-morph\").ObjectLiteralExpression;\n const keysEnabled = keysObj.getProperty(\"enabled\");\n if (!keysEnabled) {\n keysObj.addPropertyAssignment({\n name: \"enabled\",\n initializer: \"true\",\n });\n }\n } else {\n (apiKeysProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `{ enabled: true }`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst API_KEYS_NAV_SNIPPET = [\n \"import KeyRoundIcon from '@lucide/svelte/icons/key-round';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'API Keys', url: '/api-keys', icon: KeyRoundIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add an API Keys nav item to nav-user.svelte:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with an API Keys entry:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"API Keys\",\n \"/api-keys\",\n \"KeyRoundIcon\",\n \"@lucide/svelte/icons/key-round\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst TIME_AGO_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/lib/utils.ts with a timeAgo helper:\n\n ${TIME_AGO_SNIPPET}\n`;\n\nconst UNITS_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n`;\n\nconst FUNCTION_SNIPPET = dedent`\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nexport function modifyUtils(utilsPath: string): ModifyOutcome {\n if (!fs.existsSync(utilsPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(utilsPath, \"utf8\");\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(utilsPath);\n\n const hasTimeAgo =\n sourceFile.getFunction(\"timeAgo\") !== undefined ||\n sourceFile.getVariableDeclaration(\"timeAgo\") !== undefined;\n const hasUnits =\n sourceFile.getVariableDeclaration(\"TIME_AGO_UNITS\") !== undefined;\n\n if (hasTimeAgo && hasUnits) {\n return { status: \"success\", changed: false };\n }\n\n const toAppend: string[] = [];\n if (!hasUnits) toAppend.push(UNITS_SNIPPET);\n if (!hasTimeAgo) toAppend.push(FUNCTION_SNIPPET);\n\n sourceFile.addStatements(\"\\n\" + toAppend.join(\"\\n\\n\") + \"\\n\");\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { modifyUtils } from \"./modifies/utils\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, modifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Modifying nav-user\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying utils.ts\");\n const utilsPath = path.join(options.root, \"src\", \"lib\", \"utils.ts\");\n pushResult(modifyOutcomeToFile(utilsPath, modifyUtils(utilsPath)));\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAKA,IAAM,IAAe,CAAM;;;;;;;;;GAWrB,IAAiB,CAAM;;;;;;;;;;;;AAa7B,SAAgB,EAAkB,GAAwC;AACxE,KAAI,CAAC,EAAG,WAAW,EAAgB,CACjC,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAiB,EAAG,aAAa,GAAiB,OAAO,EAEzD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AAEpE,KAAI,CAAC,EACH,QAAO;EAAE,QAAQ;EAAU,SAAS;EAAc;CAGpD,IAAM,IAAO,EAAS,cAAc;AACpC,KAAI,EAAK,WAAW,EAMlB,QALA,EAAS,YACP,yDACD,EACD,EAAW,YAAY,EACvB,EAAW,UAAU,EACd;EAAE,QAAQ;EAAW,SAAS;EAAM;CAG7C,IAAM,IAAW,EAAK;AACtB,KAAI,EAAS,SAAS,KAAK,EAAW,wBAOpC,QANA,EAAS,eACP,GACA,yDACD,EACD,EAAW,YAAY,EACvB,EAAW,UAAU,EACd;EAAE,QAAQ;EAAW,SAAS;EAAM;CAG7C,IAAM,IAAa,EAAS,cAAc,EAAW,wBAAwB,EAEvE,IAAU,EAAW,YAAY,MAAM;AAC7C,KAAI,CAAC,EAOH,QANA,EAAW,sBAAsB;EAC/B,MAAM;EACN,aAAa;EACd,CAAC,EACF,EAAW,YAAY,EACvB,EAAW,UAAU,EACd;EAAE,QAAQ;EAAW,SAAS;EAAM;AAG7C,KAAI,EAAQ,SAAS,KAAK,EAAW,oBAAoB;EACvD,IAAM,IACJ,EACA,gBAAgB;AAClB,MAAI,KAAW,EAAQ,SAAS,KAAK,EAAW,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,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAKzE,CAJA,EACE,EAAoB,GAAiB,EAAkB,EAAgB,CAAC,CACzE,EAED,EAAO,KAAK,qBAAqB;CACjC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AAGD,CAFA,EAAW,EAAoB,GAAa,EAAc,EAAY,CAAC,CAAC,EAExE,EAAO,KAAK,qBAAqB;CACjC,IAAM,IAAY,EAAK,KAAK,EAAQ,MAAM,OAAO,OAAO,WAAW;AAGnE,QAFA,EAAW,EAAoB,GAAW,EAAY,EAAU,CAAC,CAAC,EAE3D;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./logger-BpgCb-ZG.js";
|
|
2
|
-
import { existsSync as n, mkdirSync as r, readFileSync as i, rmSync as a, writeFileSync as o } from "node:fs";
|
|
3
|
-
import s from "node:path";
|
|
4
|
-
import { detect as c } from "package-manager-detector";
|
|
5
|
-
import { resolveCommand as l } from "package-manager-detector/commands";
|
|
6
|
-
import u from "cross-spawn";
|
|
7
|
-
//#region src/ui/components/auth-menu/auth-menu-content.svelte?raw
|
|
8
|
-
var d = "<script lang=\"ts\">\n import { cn } from '$lib/utils';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n\n let {\n children,\n class: className,\n ...restProps\n }: DropdownMenuPrimitive.ContentProps & {\n portalProps?: DropdownMenuPrimitive.PortalProps;\n } = $props();\n\n let { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Content class={className} {...restProps}>\n {@render children?.()}\n </DropdownMenu.Content>\n{:else}\n <div class={cn('flex flex-col w-full', className)}>\n {@render children?.()}\n </div>\n{/if}\n", f = "<script lang=\"ts\">\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n let { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n let { children, ...restProps } = $props();\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Group {...restProps}>\n {@render children?.()}\n </DropdownMenu.Group>\n{:else}\n {@render children?.()}\n{/if}\n", p = "<script lang=\"ts\">\n import { goto } from '$app/navigation';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import { Button } from '$lib/components/ui/button';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n let { children, href = undefined, ...restProps } = $props();\n\n const { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n\n const handleClick = () => {\n if (restProps.onclick) {\n restProps.onclick();\n } else {\n if (href) {\n goto(href);\n }\n }\n };\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Item {...restProps} onclick={handleClick}>\n {@render children?.()}\n </DropdownMenu.Item>\n{:else}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n {href}\n {...restProps}\n >\n {@render children?.()}\n </Button>\n{/if}\n", m = "<script lang=\"ts\">\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n const { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n let { children, ...restProps } = $props();\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Label {...restProps}>\n {@render children?.()}\n </DropdownMenu.Label>\n{/if}\n", h = "<script lang=\"ts\">\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n const { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n let restProps = $props();\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Separator {...restProps} />\n{/if}\n", ee = "<script lang=\"ts\">\n import { cn } from '$lib/utils';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { getContext } from 'svelte';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n let { class: className = '', ...restProps } = $props();\n\n const { isDesktop } =\n getContext<AuthMenuContext>(AUTH_MENU_CONTEXT_KEY) ?? ({ isDesktop: false } as AuthMenuContext);\n<\/script>\n\n{#if isDesktop}\n <DropdownMenu.Trigger class={cn('inline-flex', className)} {...restProps} />\n{/if}\n", te = "<script lang=\"ts\">\n import { page } from '$app/state';\n import { browser } from '$app/environment';\n import { onMount, setContext } from 'svelte';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import { AUTH_MENU_CONTEXT_KEY, type AuthMenuContext } from './context.js';\n\n let { user, guest } = $props();\n\n const breakpoint = 768;\n const breakpointQuery = `(min-width: ${breakpoint}px)`;\n\n let hasMounted = $state(false);\n let authMenuContext = $state<AuthMenuContext>({ isDesktop: true });\n\n setContext(AUTH_MENU_CONTEXT_KEY, authMenuContext);\n\n function updateIsDesktop() {\n if (!browser) return;\n authMenuContext.isDesktop = window.matchMedia(breakpointQuery).matches;\n }\n\n onMount(() => {\n updateIsDesktop();\n hasMounted = true;\n const mq = window.matchMedia(breakpointQuery);\n const listener = () => (authMenuContext.isDesktop = mq.matches);\n mq.addEventListener('change', listener);\n return () => mq.removeEventListener('change', listener);\n });\n<\/script>\n\n{#if page.data.user}\n {#if authMenuContext.isDesktop}\n <DropdownMenu.Root>\n {@render user?.()}\n </DropdownMenu.Root>\n {:else}\n <!-- This prevents the menu from being rendered twice before we know if we're on desktop or not -->\n {#if hasMounted}\n {@render user?.()}\n {/if}\n {/if}\n{:else}\n {@render guest?.()}\n{/if}\n", ne = "export type AuthMenuContext = {\n isDesktop: boolean;\n};\n\nexport const AUTH_MENU_CONTEXT_KEY = Symbol(\"auth-menu-context\");\n", re = "import Root from \"./auth-menu.svelte\";\nimport Content from \"./auth-menu-content.svelte\";\nimport Trigger from \"./auth-menu-trigger.svelte\";\nimport Group from \"./auth-menu-group.svelte\";\nimport Label from \"./auth-menu-label.svelte\";\nimport Separator from \"./auth-menu-separator.svelte\";\nimport Item from \"./auth-menu-item.svelte\";\n\nexport { Root, Content, Trigger, Group, Label, Separator, Item };\n", ie = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value}\n {new Date(value).toLocaleDateString()}\n {/if}\n</div>\n", ae = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: boolean | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {value ? 'Yes' : 'No'}\n</div>\n", oe = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value}\n {new Date(value).toLocaleDateString()}\n {/if}\n</div>\n", se = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {value}\n</div>\n", g = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {value}\n</div>\n", _ = "<script lang=\"ts\">\n import FileIcon from '@lucide/svelte/icons/file';\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n collectionId,\n id,\n class: className,\n ...restProps\n }: {\n value: string[] | string | undefined;\n collectionId: string;\n id: string;\n } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value}\n {#if Array.isArray(value)}\n {#each value.slice(0, 2) as filename}\n {#if ['.jpg', '.png', '.jpeg', '.webp', '.gif'].some((ext) => filename.endsWith(ext))}\n <img\n src=\"/api/files/{collectionId}/{id}/{filename}\"\n class=\"w-8 h-8 rounded-sm object-cover inline-block mr-2\"\n alt={filename}\n title={filename}\n />\n {:else}\n <div\n class=\"inline-flex items-center justify-center w-8 h-8 bg-muted rounded-sm mr-2\"\n title={filename}\n >\n <FileIcon class=\"w-4 h-4\" />\n </div>\n {/if}\n {/each}\n {#if value.length > 2}\n and {value.length - 2} more files\n {/if}\n {:else if ['.jpg', '.png', '.jpeg', '.webp', '.gif'].some((ext) => value.endsWith(ext))}\n <img\n src=\"/api/files/{collectionId}/{id}/{value}\"\n class=\"w-8 h-8 rounded-sm object-cover\"\n alt={value}\n title={value}\n />\n {:else}\n <div\n class=\"inline-flex items-center justify-center w-8 h-8 bg-muted rounded-sm\"\n title={value}\n >\n <FileIcon class=\"w-4 h-4\" />\n </div>\n {/if}\n {/if}\n</div>\n", v = "<script lang=\"ts\">\n import MapPinIcon from '@lucide/svelte/icons/map-pin';\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: {\n value: { lat: number; lon: number } | undefined;\n } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center space-x-1', className)} {...restProps}>\n {#if value}\n <MapPinIcon class=\"inline-block w-4 h-4 text-muted-foreground\" />\n <span>{value.lat.toFixed(6)}, {value.lon.toFixed(6)}</span>\n {/if}\n</div>\n", y = "export { default as AutodateCell } from \"./autodate.svelte\";\nexport { default as BoolCell } from \"./bool.svelte\";\nexport { default as DateCell } from \"./date.svelte\";\nexport { default as EditorCell } from \"./editor.svelte\";\nexport { default as EmailCell } from \"./email.svelte\";\nexport { default as FileCell } from \"./file.svelte\";\nexport { default as GeoPointCell } from \"./geoPoint.svelte\";\nexport { default as JsonCell } from \"./json.svelte\";\nexport { default as NumberCell } from \"./number.svelte\";\nexport { default as PasswordCell } from \"./password.svelte\";\nexport { default as RelationCell } from \"./relation.svelte\";\nexport { default as SelectCell } from \"./select.svelte\";\nexport { default as TextCell } from \"./text.svelte\";\nexport { default as UrlCell } from \"./url.svelte\";\n", b = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: any } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value !== undefined}\n {JSON.stringify(value)}\n {/if}\n</div>\n", x = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: number | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {value}\n</div>\n", S = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>********</div>\n", C = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { Badge } from '$lib/components/ui/badge';\n import { cn } from '$lib/utils';\n\n let {\n value,\n expanded,\n displayField = 'id',\n class: className,\n ...restProps\n }: {\n value: string[] | string | undefined;\n expanded: any;\n displayField?: string;\n } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if expanded}\n {#if Array.isArray(expanded)}\n {#each expanded.slice(0, 2) as item}\n <Badge variant=\"outline\" class=\"mr-1\">\n {item[displayField]}\n </Badge>\n {/each}\n {#if expanded.length > 2}\n <Badge variant=\"secondary\" class=\"mr-1\">\n +{expanded.length - 2}\n </Badge>\n {/if}\n {:else}\n <Badge variant=\"outline\" class=\"mr-1\">\n {expanded[displayField]}\n </Badge>\n {/if}\n {/if}\n</div>\n", w = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { Badge } from '$lib/components/ui/badge';\n import { cn } from '$lib/utils';\n\n let {\n value,\n options,\n class: className,\n ...restProps\n }: {\n value: string[] | string | undefined;\n options: Record<string, { label: string; value: string }>;\n } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value}\n {#if Array.isArray(value)}\n {#each value.slice(0, 2) as item}\n <Badge variant=\"outline\" class=\"mr-1\">\n {options[item].label}\n </Badge>\n {/each}\n {:else}\n {options[value].label}\n {/if}\n {/if}\n</div>\n", T = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n ...restProps\n }: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {value}\n</div>\n", E = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import { cn } from '$lib/utils';\n\n let {\n value,\n class: className,\n target = '_blank',\n rel = 'noopener noreferrer',\n ...restProps\n }: {\n value: string | undefined;\n target?: string;\n rel?: string;\n } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n<div class={cn('flex items-center', className)} {...restProps}>\n {#if value}\n <a href={value} {target} {rel}>{value}</a>\n {/if}\n</div>\n", D = "<script lang=\"ts\">\n import type { HTMLAttributes } from 'svelte/elements';\n import type { Column } from '@tanstack/table-core';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import { Button } from '$lib/components/ui/button';\n import ArrowUpIcon from '@lucide/svelte/icons/arrow-up';\n import ArrowDownIcon from '@lucide/svelte/icons/arrow-down';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import { cn } from '$lib/utils';\n\n let {\n column,\n title,\n class: className,\n ...restProps\n }: { column: Column<any>; title: string } & HTMLAttributes<HTMLDivElement> = $props();\n<\/script>\n\n{#if !column?.getCanSort()}\n <div class={className} {...restProps}>\n {title}\n </div>\n{:else}\n <div class={cn('flex items-center', className)} {...restProps}>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Button\n {...props}\n variant=\"ghost\"\n size=\"sm\"\n class=\"data-[state=open]:bg-accent -ml-3 h-8\"\n >\n <span>\n {title}\n </span>\n {#if column.getIsSorted() === 'desc'}\n <ArrowDownIcon />\n {:else if column.getIsSorted() === 'asc'}\n <ArrowUpIcon />\n {:else}\n <ChevronsUpDownIcon />\n {/if}\n </Button>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\">\n <DropdownMenu.Item onclick={() => column.toggleSorting(false)}>\n <ArrowUpIcon class=\"text-muted-foreground/70 mr-2 size-3.5\" />\n Asc\n </DropdownMenu.Item>\n <DropdownMenu.Item onclick={() => column.toggleSorting(true)}>\n <ArrowDownIcon class=\"text-muted-foreground/70 mr-2 size-3.5\" />\n Desc\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </div>\n{/if}\n", O = "export { default as ColumnHeader } from \"./column-header.svelte\";\n", k = "<script lang=\"ts\" generics=\"TData, TValue\">\n import type { Component } from 'svelte';\n import { SvelteSet } from 'svelte/reactivity';\n import type { Column } from '@tanstack/table-core';\n import CirclePlusIcon from '@lucide/svelte/icons/circle-plus';\n import CheckIcon from '@lucide/svelte/icons/check';\n import * as Command from '$lib/components/ui/command';\n import * as Popover from '$lib/components/ui/popover';\n import { Button } from '$lib/components/ui/button';\n import { Separator } from '$lib/components/ui/separator';\n import { Badge } from '$lib/components/ui/badge';\n import { cn } from '$lib/utils';\n\n let {\n column,\n title,\n options\n }: {\n column: Column<TData, TValue>;\n title: string;\n options: {\n label: string;\n value: string;\n icon?: Component;\n }[];\n } = $props();\n\n const facets = $derived(column?.getFacetedUniqueValues());\n const selectedValues = $derived(new SvelteSet(column?.getFilterValue() as string[]));\n<\/script>\n\n<Popover.Root>\n <Popover.Trigger>\n {#snippet child({ props })}\n <Button {...props} variant=\"outline\" size=\"sm\" class=\"h-8 border-dashed\">\n <CirclePlusIcon />\n {title}\n {#if selectedValues.size > 0}\n <Separator orientation=\"vertical\" class=\"mx-2 h-4\" />\n <Badge variant=\"secondary\" class=\"rounded-sm px-1 font-normal lg:hidden\">\n {selectedValues.size}\n </Badge>\n <div class=\"hidden space-x-1 lg:flex\">\n {#if selectedValues.size > 2}\n <Badge variant=\"secondary\" class=\"rounded-sm px-1 font-normal\">\n {selectedValues.size} selected\n </Badge>\n {:else}\n {#each options.filter((opt) => selectedValues.has(opt.value)) as option (option)}\n <Badge variant=\"secondary\" class=\"rounded-sm px-1 font-normal\">\n {option.label}\n </Badge>\n {/each}\n {/if}\n </div>\n {/if}\n </Button>\n {/snippet}\n </Popover.Trigger>\n <Popover.Content class=\"w-[200px] p-0\" align=\"start\">\n <Command.Root>\n <Command.Input placeholder={title} />\n <Command.List>\n <Command.Empty>No results found.</Command.Empty>\n <Command.Group>\n {#each options as option (option)}\n {@const isSelected = selectedValues.has(option.value)}\n <Command.Item\n onSelect={() => {\n if (isSelected) {\n selectedValues.delete(option.value);\n } else {\n selectedValues.add(option.value);\n }\n const filterValues = Array.from(selectedValues);\n column?.setFilterValue(filterValues.length ? filterValues : undefined);\n }}\n >\n <div\n class={cn(\n 'border-primary mr-2 flex size-4 items-center justify-center rounded-sm border',\n isSelected ? 'bg-primary text-primary-foreground' : 'opacity-50 [&_svg]:invisible'\n )}\n >\n <CheckIcon class=\"size-4\" />\n </div>\n {#if option.icon}\n {@const Icon = option.icon}\n <Icon class=\"text-muted-foreground\" />\n {/if}\n\n <span>{option.label}</span>\n {#if facets?.get(option.value)}\n <span class=\"ml-auto flex size-4 items-center justify-center font-mono text-xs\">\n {facets.get(option.value)}\n </span>\n {/if}\n </Command.Item>\n {/each}\n </Command.Group>\n {#if selectedValues.size > 0}\n <Command.Separator />\n <Command.Group>\n <Command.Item\n onSelect={() => column?.setFilterValue(undefined)}\n class=\"justify-center text-center\"\n >\n Clear filters\n </Command.Item>\n </Command.Group>\n {/if}\n </Command.List>\n </Command.Root>\n </Popover.Content>\n</Popover.Root>\n", A = "export { default as FacetedFilter } from \"./faceted-filter.svelte\";\n", j = "<script lang=\"ts\" generics=\"T extends Record<string, unknown>, U extends FormPath<T>\">\n import * as FormPrimitive from 'formsnap';\n import type { FormPath } from 'sveltekit-superforms';\n import { cn, type WithElementRef, type WithoutChildren } from '$lib/utils';\n import type { HTMLAttributes } from 'svelte/elements';\n import { setContext } from 'svelte';\n\n let {\n ref = $bindable(null),\n class: className,\n form,\n name,\n children: childrenProp,\n ...restProps\n }: FormPrimitive.FieldProps<T, U> &\n WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();\n\n setContext('file-field', {\n get form() {\n return form;\n },\n get name() {\n return name;\n }\n });\n<\/script>\n\n<FormPrimitive.Field {form} {name}>\n {#snippet children({ constraints, errors, tainted, value })}\n <div bind:this={ref} data-slot=\"form-item\" class={cn('space-y-2', className)} {...restProps}>\n {@render childrenProp?.({ constraints, errors, tainted, value: value as T[U] })}\n </div>\n {/snippet}\n</FormPrimitive.Field>\n", M = "<script lang=\"ts\">\n import { getContext } from 'svelte';\n import { fileProxy, filesProxy, type SuperForm } from 'sveltekit-superforms';\n import { Input } from '$lib/components/ui/input';\n\n const ctx = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');\n const { multiple } = getContext<{ multiple: boolean }>('file-field-multiple');\n\n const files = multiple ? filesProxy(ctx.form, `${ctx.name}+`) : fileProxy(ctx.form, ctx.name);\n const { form: formData, reset } = ctx.form;\n\n const { ...props } = $props();\n\n const onchange = () => {\n reset({\n data: $formData\n });\n };\n<\/script>\n\n{#if !multiple}\n {#if $formData[ctx.name]}\n {#if typeof $formData[ctx.name] === 'string'}\n <input type=\"text\" name={ctx.name} value={$formData[ctx.name]} class=\"hidden\" />\n {:else}\n <input type=\"file\" name={ctx.name} files={$files} class=\"hidden\" />\n {/if}\n {:else}\n <input type=\"text\" name={ctx.name} value=\"\" class=\"hidden\" />\n {/if}\n{/if}\n\n<Input\n type=\"file\"\n bind:files={$files}\n {multiple}\n {onchange}\n {...props}\n name={multiple ? `${ctx.name}+` : ''}\n/>\n", N = "<script lang=\"ts\">\n import { setContext, getContext } from 'svelte';\n import { type SuperForm } from 'sveltekit-superforms';\n import { getName } from './shared';\n\n const ctx = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');\n const {\n display,\n input\n }: {\n display: (props: {\n file: File | string;\n filename: string;\n onremove: (file: File | string) => void;\n }) => any;\n input: () => any;\n } = $props();\n\n setContext('file-field-multiple', { multiple: true });\n\n const { form: formData, reset } = ctx.form;\n\n let removed = $state<string[]>([]);\n\n const onremove = (file: File | string) => {\n if (typeof file === 'string') {\n removed.push(file);\n } else {\n if (Array.isArray($formData[`${ctx.name}+`])) {\n reset({\n data: {\n ...$formData,\n [`${ctx.name}+`]: $formData[`${ctx.name}+`].filter((f: File | string) => f !== file) as\n | File[]\n | undefined\n }\n });\n }\n }\n };\n\n const initialFiles = $formData[ctx.name] || [];\n<\/script>\n\n{#if initialFiles}\n {#each initialFiles as file}\n {#if !removed.includes(file)}\n {@render display({ file, filename: getName(file), onremove })}\n {/if}\n {/each}\n{/if}\n\n{#each $formData[`${ctx.name}+`] as file}\n {#if file && typeof file !== 'string'}\n {@render display({ file, filename: getName(file), onremove })}\n {/if}\n{/each}\n\n{#each removed as removedFile}\n <input type=\"text\" name={`${ctx.name}-`} value={removedFile} class=\"hidden\" />\n{/each}\n\n{@render input()}\n", P = "<script lang=\"ts\">\n import { setContext, getContext } from 'svelte';\n import { type SuperForm } from 'sveltekit-superforms';\n import { getName } from './shared';\n\n const ctx = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');\n const {\n display,\n input\n }: {\n display: (props: {\n file: File | string;\n filename: string;\n onremove: (file: File | string) => void;\n }) => any;\n input: () => any;\n } = $props();\n\n const { form: formData, reset } = ctx.form;\n\n setContext('file-field-multiple', { multiple: false });\n\n const onremove = () => {\n reset({\n data: {\n ...$formData,\n [ctx.name]: ''\n }\n });\n };\n<\/script>\n\n{#if $formData[ctx.name]}\n {@render display({ file: $formData[ctx.name], filename: getName($formData[ctx.name]), onremove })}\n{/if}\n\n{@render input()}\n", F = "<script lang=\"ts\">\n import { getContext } from 'svelte';\n import { type SuperForm } from 'sveltekit-superforms';\n import FileIcon from '@lucide/svelte/icons/file';\n import ImageIcon from '@lucide/svelte/icons/image';\n import { cn } from '$lib/utils';\n import type { HTMLAttributes } from 'svelte/elements';\n\n const ctx = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');\n const { form: formData } = ctx.form;\n\n const {\n file,\n filename,\n collectionId,\n id,\n thumb = '50x50',\n class: className,\n type = 'image',\n ...props\n }: {\n file: File | string;\n filename: string;\n collectionId?: string;\n id?: string;\n thumb?: string;\n class?: string;\n type?: 'image' | 'file';\n } & HTMLAttributes<HTMLImageElement> = $props();\n\n const isImage = $derived(\n type === 'image' ||\n filename.toLowerCase().endsWith('.png') ||\n filename.toLowerCase().endsWith('.jpg') ||\n filename.toLowerCase().endsWith('.jpeg') ||\n filename.toLowerCase().endsWith('.gif') ||\n filename.toLowerCase().endsWith('.webp')\n );\n\n function getUrl(file: string) {\n return `/api/files/${collectionId ?? $formData.collectionId}/${id ?? $formData.id}/${file}?thumb=${thumb}`;\n }\n<\/script>\n\n{#if typeof file === 'string'}\n {#if (id ?? $formData.collectionId) && (id ?? $formData.id) && isImage}\n <img src={getUrl(file)} alt={filename} class={className} {...props} />\n {:else}\n <div\n class={cn('flex items-center justify-center w-full h-full bg-muted rounded-md', className)}\n {...props as HTMLAttributes<HTMLDivElement>}\n >\n {#if isImage}\n <ImageIcon class=\"w-4 h-4\" />\n {:else}\n <FileIcon class=\"w-4 h-4\" />\n {/if}\n </div>\n {/if}\n{:else if isImage}\n <img src={URL.createObjectURL(file)} alt={filename} class={className} {...props} />\n{:else}\n <div\n class={cn('flex items-center justify-center w-full h-full bg-muted rounded-md', className)}\n {...props as HTMLAttributes<HTMLDivElement>}\n >\n <FileIcon class=\"w-4 h-4\" />\n </div>\n{/if}\n", I = "export { default as Field } from \"./file-field.svelte\";\nexport { default as Single } from \"./file-single.svelte\";\nexport { default as Multiple } from \"./file-multiple.svelte\";\nexport { default as Input } from \"./file-input.svelte\";\nexport { default as Thumb } from \"./file-thumb.svelte\";\n", L = "export function getUrl(\n file: File | string,\n collectionId: string,\n recordId: string,\n thumb: string,\n) {\n return typeof file === \"string\"\n ? `/api/files/${collectionId}/${recordId}/${file}?thumb=${thumb}`\n : URL.createObjectURL(file);\n}\n\nexport function getName(file: File | string) {\n return typeof file === \"string\" ? (file.split(\"/\").pop() ?? \"\") : file.name;\n}\n", R = "<script lang=\"ts\">\n import { cn } from '$lib/utils';\n\n let {\n value = $bindable(),\n id,\n label,\n shortLabel,\n mapOpen\n }: {\n value: number;\n id: string;\n label: string;\n shortLabel: string;\n mapOpen: boolean;\n } = $props();\n<\/script>\n\n<div\n class={cn(\n 'border-input bg-background selection:bg-primary dark:bg-input/30 selection:text-primary-foreground ring-offset-background placeholder:text-muted-foreground shadow-xs flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n 'pr-0 flex items-center',\n label === 'Latitude' && 'rounded-r-none',\n label === 'Longitude' && 'rounded-none -ml-px',\n mapOpen && 'rounded-b-none'\n )}\n>\n <label for={id} class=\"text-muted-foreground mr-2\">\n <span class=\"hidden md:block\">{label}</span>\n <span class=\"block md:hidden\">{shortLabel}</span>\n </label>\n\n <input\n bind:value\n type=\"number\"\n class=\"border-none outline-none min-w-0 w-full pr-2\"\n {id}\n step=\"0.000001\"\n />\n</div>\n", z = "export { default as GeopointInput } from \"./input.svelte\";\n", B = "<script lang=\"ts\">\n import { setContext } from 'svelte';\n import ToggleMap from './toggle-map.svelte';\n import Coordinate from './coordinate.svelte';\n\n let {\n name,\n value = $bindable()\n }: {\n name: string;\n value: string | undefined;\n } = $props();\n\n const geopoint = $state(value ? JSON.parse(value) : { lat: 0, lon: 0 });\n const map = $state({ open: false });\n\n setContext('geopoint', {\n geopoint,\n map\n });\n\n $effect(() => {\n if (value) {\n const parsed = JSON.parse(value);\n\n if (typeof parsed === 'object' && parsed !== null && 'lat' in parsed && 'lon' in parsed) {\n geopoint.lat = parsed.lat.toFixed(6);\n geopoint.lon = parsed.lon.toFixed(6);\n }\n }\n });\n\n const stringValue = $derived(\n JSON.stringify({ lat: parseFloat(geopoint.lat), lon: parseFloat(geopoint.lon) })\n );\n<\/script>\n\n<input type=\"hidden\" {name} value={stringValue} />\n\n<div class=\"w-full\">\n <div class=\"w-full flex\">\n <Coordinate\n id=\"latitude\"\n label=\"Latitude\"\n shortLabel=\"Lat\"\n bind:value={geopoint.lat}\n mapOpen={map.open}\n />\n <Coordinate\n id=\"longitude\"\n label=\"Longitude\"\n shortLabel=\"Lon\"\n bind:value={geopoint.lon}\n mapOpen={map.open}\n />\n <ToggleMap />\n </div>\n\n {#if map.open}\n {#await import('$lib/components/ui/leaflet/leaflet.svelte')}\n <div class=\"h-[225px] w-full bg-input rounded-b-md\"></div>\n {:then { default: Leaflet }}\n <Leaflet height={225} point={geopoint} class=\"rounded-b-md overflow-hidden\" />\n {/await}\n {/if}\n</div>\n", V = "<script>\n import { Button } from '$lib/components/ui/button';\n import MapIcon from '@lucide/svelte/icons/map';\n import { getContext } from 'svelte';\n import { cn } from '$lib/utils';\n\n let { map } = getContext('geopoint');\n<\/script>\n\n<Button\n variant=\"outline\"\n size=\"icon\"\n class={cn('w-10 rounded-none rounded-r-md border-l-0', map.open && 'rounded-b-none')}\n onclick={() => (map.open = !map.open)}\n>\n <MapIcon class=\"w-4 h-4\" />\n</Button>\n", H = "export { default as Leaflet } from \"./leaflet.svelte\";\n", U = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import L from 'leaflet';\n import 'leaflet/dist/leaflet.css';\n\n // manually load the markers so that they can be embedded in the prod bundle\n import markerIconUrl from 'leaflet/dist/images/marker-icon.png';\n import markerIconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';\n import markerShadowUrl from 'leaflet/dist/images/marker-shadow.png';\n\n let { height = 225, point = $bindable(), readonly = false, ...props } = $props();\n\n let map: L.Map;\n let mapEl: HTMLElement;\n let marker: L.Marker;\n let panTimeoutId: ReturnType<typeof setTimeout>;\n\n const defaultZoomLevel = 8;\n\n $effect(() => {\n if (point.lat && point.lon) {\n panInside();\n }\n });\n\n function normalizeCoordinate(coord: any) {\n return +(+coord).toFixed(6);\n }\n\n function panInside(debounce = 200) {\n clearTimeout(panTimeoutId);\n panTimeoutId = setTimeout(() => {\n marker?.setLatLng([point.lat, point.lon]);\n map?.panInside([point.lat, point.lon], { padding: [20, 40] });\n }, debounce);\n }\n\n function initMap() {\n const latlon = [\n normalizeCoordinate(point.lat),\n normalizeCoordinate(point.lon)\n ] as L.LatLngTuple;\n\n map = L.map(mapEl, {\n zoomControl: false,\n maxBounds: [\n [-90, -180],\n [90, 180]\n ],\n minZoom: 2\n }).setView(latlon, defaultZoomLevel);\n\n if (readonly) {\n map.dragging.disable();\n map.touchZoom.disable();\n map.doubleClickZoom.disable();\n map.scrollWheelZoom.disable();\n map.boxZoom.disable();\n map.keyboard.disable();\n }\n\n L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OSM</a>',\n noWrap: true\n }).addTo(map);\n\n map.attributionControl.setPrefix('');\n\n // reassign the default marker images with the loaded ones\n // (https://leafletjs.com/reference.html#icon-default-option)\n L.Icon.Default.prototype.options.iconUrl = markerIconUrl;\n L.Icon.Default.prototype.options.iconRetinaUrl = markerIconRetinaUrl;\n L.Icon.Default.prototype.options.shadowUrl = markerShadowUrl;\n L.Icon.Default.imagePath = '';\n\n marker = L.marker(latlon, {\n draggable: true,\n autoPan: true\n }).addTo(map);\n\n marker.bindTooltip('drag or right click anywhere on the map to move');\n\n marker.on('moveend', (e) => {\n if (e.sourceTarget?._latlng) {\n select(e.sourceTarget._latlng.lat, e.sourceTarget._latlng.lng, false);\n }\n });\n\n map.on('contextmenu', (e) => {\n select(e.latlng.lat, e.latlng.lng, false);\n });\n }\n\n function destroyMap() {\n marker?.remove();\n map?.remove();\n }\n\n function select(lat: number, lon: number, centerMap = true) {\n point.lat = normalizeCoordinate(lat);\n point.lon = normalizeCoordinate(lon);\n\n // center the map\n if (centerMap) {\n marker?.setLatLng([point.lat, point.lon]); // optimistic marker update\n map?.panTo([point.lat, point.lon], { animate: false });\n }\n }\n\n onMount(() => {\n initMap();\n\n return () => {\n destroyMap();\n };\n });\n<\/script>\n\n<div class=\"map-wrapper\" style=\"{height ? `height:${height}px` : null};\" {...props}>\n <div bind:this={mapEl} class=\"map-box\"></div>\n</div>\n\n<style>\n .map-wrapper {\n position: relative;\n display: block;\n height: 100%;\n width: 100%;\n }\n .map-box {\n z-index: 1;\n height: 100%;\n width: 100%;\n }\n</style>\n", ce = "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { cn } from '$lib/utils';\n\n let { children, class: className }: { children: Snippet; class?: string } = $props();\n<\/script>\n\n<span class={cn('bg-secondary text-secondary-foreground px-2 py-1 rounded-sm text-sm', className)}>\n {@render children?.()}\n</span>\n", W = "<script lang=\"ts\">\n import { Popover as PopoverPrimitive } from 'bits-ui';\n import * as Popover from '$lib/components/ui/popover';\n\n let {\n children,\n ...props\n }: PopoverPrimitive.ContentProps & {\n portalProps?: PopoverPrimitive.PortalProps;\n } = $props();\n<\/script>\n\n<Popover.Content {...props}>\n {@render children?.()}\n</Popover.Content>\n", G = "<script lang=\"ts\" generics=\"T extends Record<string, unknown>, U extends FormPath<T>\">\n import * as FormPrimitive from 'formsnap';\n import type { FormPath } from 'sveltekit-superforms';\n import { cn, type WithElementRef, type WithoutChildren } from '$lib/utils';\n import type { HTMLAttributes } from 'svelte/elements';\n import { setContext } from 'svelte';\n import * as Popover from '$lib/components/ui/popover';\n\n let {\n ref = $bindable(null),\n class: className,\n type,\n form,\n name,\n required,\n children: childrenProp,\n ...restProps\n }: FormPrimitive.FieldProps<T, U> & {\n type: 'multiple' | 'single';\n required?: boolean;\n } & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();\n\n const { form: formData } = form;\n\n const toggleSelected = (value: string) => {\n if (type === 'single') {\n if (!required && $formData[name] === value) {\n $formData[name] = undefined as T[U];\n } else {\n $formData[name] = value as T[U];\n }\n } else if (type === 'multiple') {\n if (!$formData[name]) {\n $formData[name] = [] as T[U];\n }\n\n const currentValue = $formData[name] as string[];\n const index = currentValue.indexOf(value);\n\n if (index > -1) {\n $formData[name] = currentValue.filter((id) => id !== value) as T[U];\n } else {\n $formData[name] = [...currentValue, value] as T[U];\n }\n }\n };\n\n const isSelected = (value: string) => {\n if (type === 'single') {\n return $formData[name] === value;\n } else if (type === 'multiple') {\n return ($formData[name] as string[])?.includes(value) ?? false;\n }\n };\n\n setContext('multiselect-field', {\n form,\n name,\n type,\n toggleSelected,\n isSelected\n });\n<\/script>\n\n<Popover.Root>\n <FormPrimitive.Field {form} {name}>\n {#snippet children({ constraints, errors, tainted, value })}\n <div bind:this={ref} data-slot=\"form-item\" class={cn('space-y-2', className)} {...restProps}>\n {@render childrenProp?.({ constraints, errors, tainted, value: value as T[U] })}\n </div>\n {/snippet}\n </FormPrimitive.Field>\n</Popover.Root>\n", le = "export { default as Field } from \"./field.svelte\";\nexport { default as Trigger } from \"./trigger.svelte\";\nexport { default as Input } from \"./input.svelte\";\nexport { default as Content } from \"./content.svelte\";\nexport { default as Item } from \"./item.svelte\";\nexport { default as Chip } from \"./chip.svelte\";\n", ue = "<script lang=\"ts\" generics=\"T extends string\">\n import type { SuperForm } from 'sveltekit-superforms';\n import { getContext, type Snippet } from 'svelte';\n\n const { form, type } = getContext<{ form: SuperForm<any, any>; type: 'single' | 'multiple' }>(\n 'multiselect-field'\n );\n const { form: formData } = form;\n\n let {\n children,\n placeholder,\n name,\n value = $bindable()\n }: {\n children: Snippet<[{ selected: T[] }]>;\n placeholder?: string;\n name: string;\n value: T[] | T | undefined;\n } = $props();\n<\/script>\n\n{#if value && value.length > 0}\n {@render children?.({ selected: type === 'single' ? [$formData[name]] : $formData[name] })}\n {#if type === 'multiple'}\n {#each value as v}\n <input type=\"hidden\" {name} value={v} />\n {/each}\n {:else}\n <input type=\"hidden\" {name} {value} />\n {/if}\n{:else}\n {placeholder}\n{/if}\n", de = "<script lang=\"ts\">\n import { getContext, type Snippet } from 'svelte';\n import { cn } from '$lib/utils';\n import { Command as CommandPrimitive } from 'bits-ui';\n import * as Command from '$lib/components/ui/command';\n import CheckIcon from '@lucide/svelte/icons/check';\n\n let {\n children,\n value,\n label,\n class: className,\n ...props\n }: CommandPrimitive.ItemProps & {\n value: string;\n label: string | undefined;\n children?: Snippet;\n class?: string;\n } = $props();\n\n const { toggleSelected, isSelected } = getContext<{\n toggleSelected: (value: string) => void;\n isSelected: (value: string) => boolean;\n }>('multiselect-field');\n\n const handleSelect = () => {\n toggleSelected(value);\n };\n<\/script>\n\n<Command.Item\n class={cn('cursor-pointer', className)}\n {...props}\n value={label}\n onSelect={handleSelect}\n>\n {label}\n <CheckIcon class={cn('ml-auto', !isSelected(value) && 'text-transparent')} />\n</Command.Item>\n", fe = "<script lang=\"ts\">\n import * as Popover from '$lib/components/ui/popover';\n import { Popover as PopoverPrimitive } from 'bits-ui';\n import { cn } from '$lib/utils';\n import { buttonVariants } from '$lib/components/ui/button';\n import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';\n\n let { children, class: className, ...props }: PopoverPrimitive.TriggerProps = $props();\n<\/script>\n\n<Popover.Trigger\n class={cn(buttonVariants({ variant: 'outline' }), className)}\n role=\"combobox\"\n {...props}\n>\n {@render children?.()}\n <ChevronDownIcon class=\"size-4 opacity-50\" />\n</Popover.Trigger>\n", pe = "export { default as Pagination } from \"./pagination.svelte\";\n", me = "<script lang=\"ts\">\n import * as Select from '$lib/components/ui/select';\n import { Button } from '$lib/components/ui/button';\n import ChevronsLeftIcon from '@lucide/svelte/icons/chevrons-left';\n import ChevronLeftIcon from '@lucide/svelte/icons/chevron-left';\n import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';\n import ChevronsRightIcon from '@lucide/svelte/icons/chevrons-right';\n import type { Table as TableType } from '@tanstack/table-core';\n\n let { table }: { table: TableType<any> } = $props();\n<\/script>\n\n<div class=\"flex items-center justify-between px-2\">\n <div class=\"text-muted-foreground flex-1 text-sm\">\n {table.getFilteredSelectedRowModel().rows.length} of\n {table.getFilteredRowModel().rows.length} row(s) selected.\n </div>\n <div class=\"flex items-center space-x-6 lg:space-x-8\">\n <div class=\"flex items-center space-x-2\">\n <p class=\"text-sm font-medium\">Rows per page</p>\n <Select.Root\n allowDeselect={false}\n type=\"single\"\n value={`${table.getState().pagination.pageSize}`}\n onValueChange={(value) => {\n table.setPageSize(Number(value));\n }}\n >\n <Select.Trigger class=\"h-8 w-[70px]\">\n {String(table.getState().pagination.pageSize)}\n </Select.Trigger>\n <Select.Content side=\"top\">\n {#each [10, 20, 30, 40, 50] as pageSize (pageSize)}\n <Select.Item value={`${pageSize}`}>\n {pageSize}\n </Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n </div>\n <div class=\"flex w-[100px] items-center justify-center text-sm font-medium\">\n Page {table.getState().pagination.pageIndex + 1} of\n {table.getPageCount()}\n </div>\n <div class=\"flex items-center space-x-2\">\n <Button\n variant=\"outline\"\n class=\"hidden size-8 p-0 lg:flex\"\n onclick={() => table.setPageIndex(0)}\n disabled={!table.getCanPreviousPage()}\n >\n <span class=\"sr-only\">Go to first page</span>\n <ChevronsLeftIcon />\n </Button>\n <Button\n variant=\"outline\"\n class=\"size-8 p-0\"\n onclick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n <span class=\"sr-only\">Go to previous page</span>\n <ChevronLeftIcon />\n </Button>\n <Button\n variant=\"outline\"\n class=\"size-8 p-0\"\n onclick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n <span class=\"sr-only\">Go to next page</span>\n <ChevronRightIcon />\n </Button>\n <Button\n variant=\"outline\"\n class=\"hidden size-8 p-0 lg:flex\"\n onclick={() => table.setPageIndex(table.getPageCount() - 1)}\n disabled={!table.getCanNextPage()}\n >\n <span class=\"sr-only\">Go to last page</span>\n <ChevronsRightIcon />\n </Button>\n </div>\n </div>\n</div>\n", he = "export { default as RowActions } from \"./row-actions.svelte\";\n", ge = "<script lang=\"ts\">\n import { goto } from '$app/navigation';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import { Button } from '$lib/components/ui/button';\n import EllipsisIcon from '@lucide/svelte/icons/ellipsis';\n\n let {\n viewPath,\n editPath,\n deletePath\n }: {\n viewPath: string;\n editPath: string;\n deletePath: string;\n } = $props();\n<\/script>\n\n<DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Button {...props} variant=\"ghost\" class=\"data-[state=open]:bg-muted flex h-8 w-8 p-0\">\n <EllipsisIcon />\n <span class=\"sr-only\">Open Menu</span>\n </Button>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content class=\"w-[160px]\" align=\"end\">\n <DropdownMenu.Item onclick={() => goto(viewPath)}>View</DropdownMenu.Item>\n <DropdownMenu.Item onclick={() => goto(editPath)}>Edit</DropdownMenu.Item>\n <DropdownMenu.Item>\n <form method=\"POST\" action={deletePath}>\n <button type=\"submit\" class=\"contents\">Delete</button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n</DropdownMenu.Root>\n", _e = {
|
|
9
|
-
"file-form": ["input", "form"],
|
|
10
|
-
multiselect: [
|
|
11
|
-
"command",
|
|
12
|
-
"popover",
|
|
13
|
-
"button",
|
|
14
|
-
"badge"
|
|
15
|
-
],
|
|
16
|
-
geopoint: ["button", "leaflet"],
|
|
17
|
-
cells: [],
|
|
18
|
-
"column-header": ["dropdown-menu", "button"],
|
|
19
|
-
"faceted-filter": [
|
|
20
|
-
"command",
|
|
21
|
-
"popover",
|
|
22
|
-
"button",
|
|
23
|
-
"separator",
|
|
24
|
-
"badge"
|
|
25
|
-
],
|
|
26
|
-
pagination: ["button", "select"],
|
|
27
|
-
"row-actions": ["dropdown-menu", "button"],
|
|
28
|
-
leaflet: [],
|
|
29
|
-
"auth-menu": ["dropdown-menu", "button"]
|
|
30
|
-
}, ve = {
|
|
31
|
-
"file-form": [],
|
|
32
|
-
multiselect: [],
|
|
33
|
-
geopoint: [],
|
|
34
|
-
cells: [],
|
|
35
|
-
"column-header": ["@tanstack/table-core"],
|
|
36
|
-
"faceted-filter": ["@tanstack/table-core"],
|
|
37
|
-
pagination: ["@tanstack/table-core"],
|
|
38
|
-
"row-actions": [],
|
|
39
|
-
leaflet: ["leaflet", "@types/leaflet"]
|
|
40
|
-
}, K = /* @__PURE__ */ Object.assign({
|
|
41
|
-
"../ui/components/auth-menu/auth-menu-content.svelte": d,
|
|
42
|
-
"../ui/components/auth-menu/auth-menu-group.svelte": f,
|
|
43
|
-
"../ui/components/auth-menu/auth-menu-item.svelte": p,
|
|
44
|
-
"../ui/components/auth-menu/auth-menu-label.svelte": m,
|
|
45
|
-
"../ui/components/auth-menu/auth-menu-separator.svelte": h,
|
|
46
|
-
"../ui/components/auth-menu/auth-menu-trigger.svelte": ee,
|
|
47
|
-
"../ui/components/auth-menu/auth-menu.svelte": te,
|
|
48
|
-
"../ui/components/auth-menu/context.ts": ne,
|
|
49
|
-
"../ui/components/auth-menu/index.ts": re,
|
|
50
|
-
"../ui/components/cells/autodate.svelte": ie,
|
|
51
|
-
"../ui/components/cells/bool.svelte": ae,
|
|
52
|
-
"../ui/components/cells/date.svelte": oe,
|
|
53
|
-
"../ui/components/cells/editor.svelte": se,
|
|
54
|
-
"../ui/components/cells/email.svelte": g,
|
|
55
|
-
"../ui/components/cells/file.svelte": _,
|
|
56
|
-
"../ui/components/cells/geoPoint.svelte": v,
|
|
57
|
-
"../ui/components/cells/index.ts": y,
|
|
58
|
-
"../ui/components/cells/json.svelte": b,
|
|
59
|
-
"../ui/components/cells/number.svelte": x,
|
|
60
|
-
"../ui/components/cells/password.svelte": S,
|
|
61
|
-
"../ui/components/cells/relation.svelte": C,
|
|
62
|
-
"../ui/components/cells/select.svelte": w,
|
|
63
|
-
"../ui/components/cells/text.svelte": T,
|
|
64
|
-
"../ui/components/cells/url.svelte": E,
|
|
65
|
-
"../ui/components/column-header/column-header.svelte": D,
|
|
66
|
-
"../ui/components/column-header/index.ts": O,
|
|
67
|
-
"../ui/components/faceted-filter/faceted-filter.svelte": k,
|
|
68
|
-
"../ui/components/faceted-filter/index.ts": A,
|
|
69
|
-
"../ui/components/file-form/file-field.svelte": j,
|
|
70
|
-
"../ui/components/file-form/file-input.svelte": M,
|
|
71
|
-
"../ui/components/file-form/file-multiple.svelte": N,
|
|
72
|
-
"../ui/components/file-form/file-single.svelte": P,
|
|
73
|
-
"../ui/components/file-form/file-thumb.svelte": F,
|
|
74
|
-
"../ui/components/file-form/index.ts": I,
|
|
75
|
-
"../ui/components/file-form/shared.ts": L,
|
|
76
|
-
"../ui/components/geopoint/coordinate.svelte": R,
|
|
77
|
-
"../ui/components/geopoint/index.ts": z,
|
|
78
|
-
"../ui/components/geopoint/input.svelte": B,
|
|
79
|
-
"../ui/components/geopoint/toggle-map.svelte": V,
|
|
80
|
-
"../ui/components/leaflet/index.ts": H,
|
|
81
|
-
"../ui/components/leaflet/leaflet.svelte": U,
|
|
82
|
-
"../ui/components/multiselect/chip.svelte": ce,
|
|
83
|
-
"../ui/components/multiselect/content.svelte": W,
|
|
84
|
-
"../ui/components/multiselect/field.svelte": G,
|
|
85
|
-
"../ui/components/multiselect/index.ts": le,
|
|
86
|
-
"../ui/components/multiselect/input.svelte": ue,
|
|
87
|
-
"../ui/components/multiselect/item.svelte": de,
|
|
88
|
-
"../ui/components/multiselect/trigger.svelte": fe,
|
|
89
|
-
"../ui/components/pagination/index.ts": pe,
|
|
90
|
-
"../ui/components/pagination/pagination.svelte": me,
|
|
91
|
-
"../ui/components/row-actions/index.ts": he,
|
|
92
|
-
"../ui/components/row-actions/row-actions.svelte": ge
|
|
93
|
-
});
|
|
94
|
-
function ye() {
|
|
95
|
-
return [...new Set(Object.keys(K).map(q))].filter(Boolean).sort();
|
|
96
|
-
}
|
|
97
|
-
function q(e) {
|
|
98
|
-
let t = e.split("/");
|
|
99
|
-
return t[t.indexOf("components") + 1] ?? "";
|
|
100
|
-
}
|
|
101
|
-
function be(e) {
|
|
102
|
-
let t = e.split("/"), n = t.indexOf("components");
|
|
103
|
-
return t.slice(n + 2).join("/");
|
|
104
|
-
}
|
|
105
|
-
function J(e, t) {
|
|
106
|
-
return s.isAbsolute(t) ? t : s.join(e, t);
|
|
107
|
-
}
|
|
108
|
-
function Y(e, t) {
|
|
109
|
-
r(s.dirname(e), { recursive: !0 }), o(e, t, "utf8");
|
|
110
|
-
}
|
|
111
|
-
function xe(e) {
|
|
112
|
-
n(e) && a(e, {
|
|
113
|
-
force: !0,
|
|
114
|
-
recursive: !0
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
async function Se(e, t, n) {
|
|
118
|
-
let r = (await c({ cwd: e }))?.name ?? "npm", i = l(r, t, n);
|
|
119
|
-
if (!i) throw Error(`Unable to resolve ${t} command for ${r}`);
|
|
120
|
-
let a = [...i.args];
|
|
121
|
-
r === "npm" && a.unshift("--yes"), await new Promise((t, n) => {
|
|
122
|
-
let r = u(i.command, a, {
|
|
123
|
-
cwd: e,
|
|
124
|
-
stdio: "inherit"
|
|
125
|
-
});
|
|
126
|
-
r.on("error", n), r.on("exit", (e) => {
|
|
127
|
-
if (e === 0) {
|
|
128
|
-
t();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
n(/* @__PURE__ */ Error(`${i.command} exited with code ${e ?? "unknown"}`));
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
async function X(e, t, n, r) {
|
|
136
|
-
if (r?.executeCommand) {
|
|
137
|
-
await r.executeCommand(e, t, n);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
await Se(e, t, n);
|
|
141
|
-
}
|
|
142
|
-
function Ce(e) {
|
|
143
|
-
let t = s.join(e, "package.json");
|
|
144
|
-
if (!n(t)) return /* @__PURE__ */ new Set();
|
|
145
|
-
let r = JSON.parse(i(t, "utf8"));
|
|
146
|
-
return new Set([
|
|
147
|
-
...Object.keys(r.dependencies ?? {}),
|
|
148
|
-
...Object.keys(r.devDependencies ?? {}),
|
|
149
|
-
...Object.keys(r.optionalDependencies ?? {}),
|
|
150
|
-
...Object.keys(r.peerDependencies ?? {})
|
|
151
|
-
]);
|
|
152
|
-
}
|
|
153
|
-
async function Z(e, n, r, i = t) {
|
|
154
|
-
if (n.length === 0) return [];
|
|
155
|
-
let a = Ce(e), o = [...new Set(n)].filter((e) => !a.has(e));
|
|
156
|
-
return o.length === 0 ? [] : (i.info(`Installing packages: ${o.join(", ")}`), await X(e, "install", o, r), o);
|
|
157
|
-
}
|
|
158
|
-
function Q(e) {
|
|
159
|
-
return ye().includes(e);
|
|
160
|
-
}
|
|
161
|
-
function $(e) {
|
|
162
|
-
return [...new Set(e.flatMap((e) => ve[e] ?? []))];
|
|
163
|
-
}
|
|
164
|
-
function we(e, t) {
|
|
165
|
-
let n = s.join(t, e);
|
|
166
|
-
r(n, { recursive: !0 });
|
|
167
|
-
for (let [t, i] of Object.entries(K)) {
|
|
168
|
-
if (q(t) !== e) continue;
|
|
169
|
-
let a = be(t);
|
|
170
|
-
if (!a) continue;
|
|
171
|
-
let c = s.join(n, a);
|
|
172
|
-
r(s.dirname(c), { recursive: !0 }), o(c, i, "utf8");
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async function Te(e, i, a, o = t) {
|
|
176
|
-
if (i.length === 0) return {
|
|
177
|
-
components: [],
|
|
178
|
-
packages: []
|
|
179
|
-
};
|
|
180
|
-
let c = s.join(e, "src", "lib", "components", "ui");
|
|
181
|
-
r(c, { recursive: !0 });
|
|
182
|
-
let l = [...new Set(i)].filter((e) => !n(s.join(c, e)));
|
|
183
|
-
if (l.length === 0) return {
|
|
184
|
-
components: [],
|
|
185
|
-
packages: []
|
|
186
|
-
};
|
|
187
|
-
let u = new Set(l.filter(Q)), d = new Set(l.filter((e) => !Q(e)));
|
|
188
|
-
for (let e of [...u]) for (let t of _e[e] ?? []) n(s.join(c, t)) || (Q(t) ? u.add(t) : d.add(t));
|
|
189
|
-
let f = [], p = [...u].sort();
|
|
190
|
-
p.length > 0 && o.info(`Installing custom components: ${p.join(", ")}`);
|
|
191
|
-
for (let e of p) we(e, c), f.push(e), d.delete(e);
|
|
192
|
-
let m = await Z(e, $([...u]), a, o), h = [...d].sort();
|
|
193
|
-
return h.length > 0 && (o.info(`Installing shadcn-svelte components: ${h.join(", ")}`), await X(e, "execute", [
|
|
194
|
-
"shadcn-svelte",
|
|
195
|
-
"add",
|
|
196
|
-
"--yes",
|
|
197
|
-
"--overwrite",
|
|
198
|
-
...h
|
|
199
|
-
], a), f.push(...h)), {
|
|
200
|
-
components: [...new Set(f)],
|
|
201
|
-
packages: m
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
async function Ee(t, r, i) {
|
|
205
|
-
let a = e(r), o = {
|
|
206
|
-
creates: [],
|
|
207
|
-
modifies: [],
|
|
208
|
-
deletes: [],
|
|
209
|
-
components: [],
|
|
210
|
-
packages: [],
|
|
211
|
-
collections: [],
|
|
212
|
-
collectionPatches: [],
|
|
213
|
-
collectionDrops: []
|
|
214
|
-
}, s = [];
|
|
215
|
-
if (t.collectionDrops.length > 0) {
|
|
216
|
-
let { dropCollections: e } = await import("./collections-VC2LOzBB.js");
|
|
217
|
-
s = await e(t.collectionDrops, r);
|
|
218
|
-
}
|
|
219
|
-
let c = await Z(r.root, t.packages, i, a), l = await Te(r.root, t.components, i, a);
|
|
220
|
-
for (let e of [...t.creates, ...s]) e.status === "success" && (n(J(r.root, e.path)) || (Y(J(r.root, e.path), e.content), o.creates.push(e)));
|
|
221
|
-
for (let e of t.modifies) e.status === "success" && Y(J(r.root, e.path), e.content);
|
|
222
|
-
for (let e of t.deletes) e.status === "success" && n(J(r.root, e.path)) && (xe(J(r.root, e.path)), o.deletes.push(e));
|
|
223
|
-
return {
|
|
224
|
-
...t,
|
|
225
|
-
creates: o.creates,
|
|
226
|
-
deletes: o.deletes,
|
|
227
|
-
components: l.components,
|
|
228
|
-
packages: [...new Set([...c, ...l.packages])]
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
//#endregion
|
|
232
|
-
export { Ee as writeResult };
|
|
233
|
-
|
|
234
|
-
//# sourceMappingURL=write-result-ByDzyVll.js.map
|