Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
No EOL
8.7 KiB
Text
1 line
No EOL
8.7 KiB
Text
{"version":3,"sources":["../../../src/server/typescript/utils.ts"],"sourcesContent":["import path from 'path'\n\nimport type tsModule from 'typescript/lib/tsserverlibrary'\ntype TypeScript = typeof import('typescript/lib/tsserverlibrary')\n\nlet ts: TypeScript\nlet info: tsModule.server.PluginCreateInfo\nlet appDirRegExp: RegExp\n\nexport function log(message: string) {\n info.project.projectService.logger.info('[next] ' + message)\n}\n\n// This function has to be called initially.\nexport function init(opts: {\n ts: TypeScript\n info: tsModule.server.PluginCreateInfo\n}) {\n const projectDir = opts.info.project.getCurrentDirectory()\n ts = opts.ts\n info = opts.info\n appDirRegExp = new RegExp(\n '^' + (projectDir + '(/src)?/app').replace(/[\\\\/]/g, '[\\\\/]')\n )\n\n log('Initialized Next.js TypeScript plugin: ' + projectDir)\n}\n\nexport function getTs() {\n return ts\n}\n\nexport function getInfo() {\n return info\n}\n\nexport function getTypeChecker() {\n const program = info.languageService.getProgram()\n if (!program) {\n log('Failed to get program while while running getTypeChecker.')\n return\n }\n const typeChecker = program.getTypeChecker()\n if (!typeChecker) {\n log('Failed to get type checker while running getTypeChecker.')\n return\n }\n return typeChecker\n}\n\nexport function getSource(fileName: string) {\n const program = info.languageService.getProgram()\n if (!program) {\n log('Failed to get program while running getSource for: ' + fileName)\n return\n }\n\n const sourceFile = program.getSourceFile(fileName)\n if (!sourceFile) {\n log('Failed to get source file while running getSource for: ' + fileName)\n return\n }\n\n return sourceFile\n}\n\nexport function removeStringQuotes(str: string): string {\n return str.replace(/^['\"`]|['\"`]$/g, '')\n}\n\nexport const isPositionInsideNode = (position: number, node: tsModule.Node) => {\n const start = node.getFullStart()\n return start <= position && position <= node.getFullWidth() + start\n}\n\nexport const isDefaultFunctionExport = (\n node: tsModule.Node\n): node is tsModule.FunctionDeclaration => {\n if (ts.isFunctionDeclaration(node)) {\n let hasExportKeyword = false\n let hasDefaultKeyword = false\n\n if (node.modifiers) {\n for (const modifier of node.modifiers) {\n if (modifier.kind === ts.SyntaxKind.ExportKeyword) {\n hasExportKeyword = true\n } else if (modifier.kind === ts.SyntaxKind.DefaultKeyword) {\n hasDefaultKeyword = true\n }\n }\n }\n\n // `export default function`\n if (hasExportKeyword && hasDefaultKeyword) {\n return true\n }\n }\n return false\n}\n\nexport const isInsideApp = (filePath: string) => {\n return appDirRegExp.test(filePath)\n}\nexport const isAppEntryFile = (filePath: string) => {\n return (\n appDirRegExp.test(filePath) &&\n /^(page|layout)\\.(mjs|js|jsx|ts|tsx)$/.test(path.basename(filePath))\n )\n}\nexport const isPageFile = (filePath: string) => {\n return (\n appDirRegExp.test(filePath) &&\n /^page\\.(mjs|js|jsx|ts|tsx)$/.test(path.basename(filePath))\n )\n}\n\n// Check if a module is a client entry.\nexport function getEntryInfo(\n fileName: string,\n throwOnInvalidDirective?: boolean\n) {\n const source = getSource(fileName)\n if (source) {\n let isDirective = true\n let isClientEntry = false\n let isServerEntry = false\n\n ts.forEachChild(source!, (node) => {\n if (\n ts.isExpressionStatement(node) &&\n ts.isStringLiteral(node.expression)\n ) {\n if (node.expression.text === 'use client') {\n if (isDirective) {\n isClientEntry = true\n } else {\n if (throwOnInvalidDirective) {\n const e = {\n messageText:\n 'The `\"use client\"` directive must be put at the top of the file.',\n start: node.expression.getStart(),\n length: node.expression.getWidth(),\n }\n throw e\n }\n }\n } else if (node.expression.text === 'use server') {\n if (isDirective) {\n isServerEntry = true\n } else {\n if (throwOnInvalidDirective) {\n const e = {\n messageText:\n 'The `\"use server\"` directive must be put at the top of the file.',\n start: node.expression.getStart(),\n length: node.expression.getWidth(),\n }\n throw e\n }\n }\n }\n\n if (isClientEntry && isServerEntry) {\n const e = {\n messageText:\n 'Cannot use both \"use client\" and \"use server\" directives in the same file.',\n start: node.expression.getStart(),\n length: node.expression.getWidth(),\n }\n throw e\n }\n } else {\n isDirective = false\n }\n })\n\n return { client: isClientEntry, server: isServerEntry }\n }\n\n return { client: false, server: false }\n}\n"],"names":["path","ts","info","appDirRegExp","log","message","project","projectService","logger","init","opts","projectDir","getCurrentDirectory","RegExp","replace","getTs","getInfo","getTypeChecker","program","languageService","getProgram","typeChecker","getSource","fileName","sourceFile","getSourceFile","removeStringQuotes","str","isPositionInsideNode","position","node","start","getFullStart","getFullWidth","isDefaultFunctionExport","isFunctionDeclaration","hasExportKeyword","hasDefaultKeyword","modifiers","modifier","kind","SyntaxKind","ExportKeyword","DefaultKeyword","isInsideApp","filePath","test","isAppEntryFile","basename","isPageFile","getEntryInfo","throwOnInvalidDirective","source","isDirective","isClientEntry","isServerEntry","forEachChild","isExpressionStatement","isStringLiteral","expression","text","e","messageText","getStart","length","getWidth","client","server"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAKvB,IAAIC;AACJ,IAAIC;AACJ,IAAIC;AAEJ,OAAO,SAASC,IAAIC,OAAe;IACjCH,KAAKI,OAAO,CAACC,cAAc,CAACC,MAAM,CAACN,IAAI,CAAC,YAAYG;AACtD;AAEA,4CAA4C;AAC5C,OAAO,SAASI,KAAKC,IAGpB;IACC,MAAMC,aAAaD,KAAKR,IAAI,CAACI,OAAO,CAACM,mBAAmB;IACxDX,KAAKS,KAAKT,EAAE;IACZC,OAAOQ,KAAKR,IAAI;IAChBC,eAAe,IAAIU,OACjB,MAAM,AAACF,CAAAA,aAAa,aAAY,EAAGG,OAAO,CAAC,UAAU;IAGvDV,IAAI,4CAA4CO;AAClD;AAEA,OAAO,SAASI;IACd,OAAOd;AACT;AAEA,OAAO,SAASe;IACd,OAAOd;AACT;AAEA,OAAO,SAASe;IACd,MAAMC,UAAUhB,KAAKiB,eAAe,CAACC,UAAU;IAC/C,IAAI,CAACF,SAAS;QACZd,IAAI;QACJ;IACF;IACA,MAAMiB,cAAcH,QAAQD,cAAc;IAC1C,IAAI,C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