@velastack/patterns 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/chunks/{generate-vRi-W3rL.js → generate-mchSz-tm.js} +3 -3
  2. package/dist/chunks/{generate-vRi-W3rL.js.map → generate-mchSz-tm.js.map} +1 -1
  3. package/dist/chunks/{generate.runtime-C3kgmLls.js → generate.runtime-BB-U8d52.js} +2 -2
  4. package/dist/chunks/{generate.runtime-C3kgmLls.js.map → generate.runtime-BB-U8d52.js.map} +1 -1
  5. package/dist/chunks/{generate.runtime--0bYEUP_.js → generate.runtime-C5TE2jyc.js} +2 -2
  6. package/dist/chunks/{generate.runtime--0bYEUP_.js.map → generate.runtime-C5TE2jyc.js.map} +1 -1
  7. package/dist/chunks/{generate.runtime-BHoIbpFW.js → generate.runtime-C7Shwovm.js} +2 -2
  8. package/dist/chunks/{generate.runtime-BHoIbpFW.js.map → generate.runtime-C7Shwovm.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-BhgkUhnZ.js → generate.runtime-C8Y2mS0B.js} +2 -2
  10. package/dist/chunks/{generate.runtime-BhgkUhnZ.js.map → generate.runtime-C8Y2mS0B.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-CflCO_6s.js → generate.runtime-CL-fRmd9.js} +2 -2
  12. package/dist/chunks/{generate.runtime-CflCO_6s.js.map → generate.runtime-CL-fRmd9.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-DpgPAnEd.js → generate.runtime-CRcQrxEJ.js} +6 -6
  14. package/dist/chunks/{generate.runtime-DpgPAnEd.js.map → generate.runtime-CRcQrxEJ.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-CFwzS666.js → generate.runtime-Cdep21LK.js} +2 -2
  16. package/dist/chunks/{generate.runtime-CFwzS666.js.map → generate.runtime-Cdep21LK.js.map} +1 -1
  17. package/dist/chunks/{generate.runtime-BiQzi7ie.js → generate.runtime-CmBcOojv.js} +2 -2
  18. package/dist/chunks/{generate.runtime-BiQzi7ie.js.map → generate.runtime-CmBcOojv.js.map} +1 -1
  19. package/dist/chunks/{generate.runtime-BOLZHcGN.js → generate.runtime-CpKaHLG6.js} +2 -2
  20. package/dist/chunks/{generate.runtime-BOLZHcGN.js.map → generate.runtime-CpKaHLG6.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-CqOjFGKT.js → generate.runtime-DEPMu4l8.js} +2 -2
  22. package/dist/chunks/{generate.runtime-CqOjFGKT.js.map → generate.runtime-DEPMu4l8.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-DUFPsIYY.js → generate.runtime-DJJTAUe-.js} +2 -2
  24. package/dist/chunks/{generate.runtime-DUFPsIYY.js.map → generate.runtime-DJJTAUe-.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-CFKrhkAA.js → generate.runtime-DZR09ORc.js} +2 -2
  26. package/dist/chunks/{generate.runtime-CFKrhkAA.js.map → generate.runtime-DZR09ORc.js.map} +1 -1
  27. package/dist/chunks/{generate.runtime-Dbhctzy1.js → generate.runtime-De1TeiUr.js} +2 -2
  28. package/dist/chunks/{generate.runtime-Dbhctzy1.js.map → generate.runtime-De1TeiUr.js.map} +1 -1
  29. package/dist/chunks/{generate.runtime-CNwy0UB2.js → generate.runtime-O_XZsZZ0.js} +2 -2
  30. package/dist/chunks/{generate.runtime-CNwy0UB2.js.map → generate.runtime-O_XZsZZ0.js.map} +1 -1
  31. package/dist/chunks/{generate.runtime-DYySjH4f.js → generate.runtime-QL0UvDUK.js} +2 -2
  32. package/dist/chunks/{generate.runtime-DYySjH4f.js.map → generate.runtime-QL0UvDUK.js.map} +1 -1
  33. package/dist/chunks/{generate.runtime-CbSifpZG.js → generate.runtime-mFZIMpFZ.js} +2 -2
  34. package/dist/chunks/{generate.runtime-CbSifpZG.js.map → generate.runtime-mFZIMpFZ.js.map} +1 -1
  35. package/dist/chunks/{generate.runtime-JtRQn3Yl.js → generate.runtime-pwEIGBEe.js} +2 -2
  36. package/dist/chunks/{generate.runtime-JtRQn3Yl.js.map → generate.runtime-pwEIGBEe.js.map} +1 -1
  37. package/dist/chunks/{ts-morph-helpers-Bk82Z2n7.js → ts-morph-helpers-7qF9S2k7.js} +11 -1
  38. package/dist/chunks/ts-morph-helpers-7qF9S2k7.js.map +1 -0
  39. package/dist/index.js +20 -20
  40. package/dist/index.js.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunks/ts-morph-helpers-Bk82Z2n7.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velastack/patterns",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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,
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-morph-helpers-Bk82Z2n7.js","names":[],"sources":["../../src/runtime/svelte-file.ts","../../src/runtime/ts-morph-helpers.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n /**\n * Remove a named attribute from a component's start tag, including the\n * leading whitespace. No-op if the element or attribute isn't present.\n */\n removeAttribute(name: string, attrName: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const attr = (node.attributes ?? []).find(\n (a: SvelteNode) => a.type === \"Attribute\" && a.name === attrName,\n );\n if (!attr) return false;\n // Extend the removal backwards over the whitespace between the previous\n // token and this attribute so the tag doesn't collapse `<Foo />`.\n let start = attr.start as number;\n while (start > 0 && /\\s/.test(this.source[start - 1]!)) start--;\n this.s.remove(start, attr.end as number);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n","import {\n Project,\n QuoteKind,\n SyntaxKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n type StringLiteral,\n} from \"ts-morph\";\n\nexport interface ImportSpec {\n defaultImport?: string;\n namespaceImport?: string;\n namedImports?: string[];\n moduleSpecifier: string;\n}\n\n/**\n * Run a function with an in-memory ts-morph SourceFile and return the resulting\n * source plus whatever the callback returned.\n */\nexport function withInMemoryScript<T>(\n source: string,\n fn: (sf: SourceFile) => T,\n): { source: string; result: T } {\n const project = new Project({\n useInMemoryFileSystem: true,\n skipFileDependencyResolution: true,\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.createSourceFile(\"script.ts\", source, { overwrite: true });\n const result = fn(sf);\n return { source: sf.getFullText(), result };\n}\n\n/** Add the given imports to the source file, skipping any whose module specifier already exists. */\nexport function ensureImports(sf: SourceFile, imports: ImportSpec[]): void {\n for (const spec of imports) {\n const existing = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) continue;\n\n const structure: OptionalKind<ImportDeclarationStructure> = {\n moduleSpecifier: spec.moduleSpecifier,\n };\n if (spec.defaultImport) structure.defaultImport = spec.defaultImport;\n if (spec.namespaceImport) structure.namespaceImport = spec.namespaceImport;\n if (spec.namedImports) structure.namedImports = spec.namedImports;\n sf.addImportDeclaration(structure);\n }\n}\n\n/** Remove the import declaration for the given module specifier, if present. */\nexport function removeImportByModuleSpecifier(\n sf: SourceFile,\n moduleSpecifier: string,\n): { wasRemoved: boolean } {\n const decl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!decl) return { wasRemoved: false };\n decl.remove();\n return { wasRemoved: true };\n}\n\n/** Remove a top-level function or variable declaration by name, if present. */\nexport function removeTopLevelStatementByIdentifier(\n sf: SourceFile,\n name: string,\n): { wasRemoved: boolean } {\n const fn = sf.getFunction(name);\n if (fn) {\n fn.remove();\n return { wasRemoved: true };\n }\n const vs = sf\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === name));\n if (vs) {\n vs.remove();\n return { wasRemoved: true };\n }\n return { wasRemoved: false };\n}\n\n/**\n * Add an item to the `data.navUser` array in a Svelte component's script body.\n * Idempotent: if an entry with the same `title` already exists, no-op.\n */\nexport function addNavItemToScript(\n scriptSource: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { source: string; wasAdded: boolean } {\n const newNavItemSnippet = `\n {\n title: '${title}',\n url: '${url}',\n icon: ${icon}\n }\n `.trim();\n\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasAdded: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasAdded: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasAdded: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const exists = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (exists) return { wasAdded: false };\n\n ensureImports(sf, [\n { defaultImport: icon, moduleSpecifier: iconImportPath },\n ]);\n arr.addElement(newNavItemSnippet);\n sf.formatText();\n return { wasAdded: true };\n });\n\n return { source, wasAdded: result.wasAdded };\n}\n\n/**\n * Remove the entry with the given `title` from the `data.navUser` array in a\n * Svelte component's script body. Also removes the icon import if supplied and\n * no other navUser entry references it. Idempotent: no-op if the entry or\n * navUser structure is missing.\n */\nexport function removeNavItemFromScript(\n scriptSource: string,\n title: string,\n iconImportPath?: string,\n): { source: string; wasRemoved: boolean } {\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasRemoved: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasRemoved: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasRemoved: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const elements = arr.getElements();\n const index = elements.findIndex((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (index === -1) return { wasRemoved: false };\n\n arr.removeElement(index);\n\n if (iconImportPath) {\n const remainingRefs = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const iconProp = o.getProperty(\"icon\");\n if (!iconProp || iconProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n return (\n iconProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer()\n ?.getText() !== undefined\n );\n });\n const importDecl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === iconImportPath);\n if (importDecl && !remainingRefs) {\n const importName = importDecl.getDefaultImport()?.getText();\n const stillUsed =\n importName &&\n sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id) =>\n id.getText() === importName &&\n id.getParent()?.getKind() !== SyntaxKind.ImportClause &&\n id.getParent()?.getKind() !== SyntaxKind.ImportSpecifier,\n );\n if (!stillUsed) {\n importDecl.remove();\n }\n }\n }\n\n sf.formatText();\n return { wasRemoved: true };\n });\n\n return { source, wasRemoved: result.wasRemoved };\n}\n"],"mappings":";;;;;AAqBA,IAAa,IAAb,MAAa,EAAW;CAKtB,YAAY,GAAgB;EAG1B,AAFA,KAAK,SAAS,GACd,KAAK,MAAM,EAAM,GAAQ,EAAE,QAAQ,GAAK,CAAC,GACzC,KAAK,IAAI,IAAI,EAAY,CAAM;CACjC;CAEA,OAAO,SAAS,GAA8B;EAC5C,OAAO,IAAI,EAAW,EAAG,aAAa,GAAU,MAAM,CAAC;CACzD;CAEA,YAAgC;EAC9B,OAAO,KAAK,YAAa,KAAK,IAAY,QAAQ;CACpD;CAEA,kBAAsC;EACpC,OAAO,KAAK,YAAa,KAAK,IAAY,MAAM;CAClD;CAEA,YAAoB,GAA+C;EACjE,IAAI,CAAC,GAAQ,OAAO;EACpB,IAAM,IAAQ,EAAO,QAAQ,OACvB,IAAM,EAAO,QAAQ;EAC3B,OAAO;GAAE,SAAS,KAAK,OAAO,MAAM,GAAO,CAAG;GAAG;GAAO;EAAI;CAC9D;CAMA,aAAa,GAA0C;EACrD,OAAO,KAAK,kBAAkB,KAAK,UAAU,GAAG,CAAE;CACpD;CAEA,mBAAmB,GAA0C;EAC3D,OAAO,KAAK,kBAAkB,KAAK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