@upstart.gg/vite-plugins 0.0.38 → 0.0.40

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 (64) hide show
  1. package/dist/upstart-editor-api.d.ts +79 -0
  2. package/dist/upstart-editor-api.d.ts.map +1 -0
  3. package/dist/upstart-editor-api.js +208 -0
  4. package/dist/upstart-editor-api.js.map +1 -0
  5. package/dist/vite-plugin-upstart-attrs.d.ts +3 -3
  6. package/dist/vite-plugin-upstart-attrs.d.ts.map +1 -1
  7. package/dist/vite-plugin-upstart-attrs.js +227 -25
  8. package/dist/vite-plugin-upstart-attrs.js.map +1 -1
  9. package/dist/vite-plugin-upstart-branding/plugin.d.ts +17 -0
  10. package/dist/vite-plugin-upstart-branding/plugin.d.ts.map +1 -0
  11. package/dist/vite-plugin-upstart-branding/plugin.js +41 -0
  12. package/dist/vite-plugin-upstart-branding/plugin.js.map +1 -0
  13. package/dist/vite-plugin-upstart-branding/runtime.d.ts +10 -0
  14. package/dist/vite-plugin-upstart-branding/runtime.d.ts.map +1 -0
  15. package/dist/vite-plugin-upstart-branding/runtime.js +118 -0
  16. package/dist/vite-plugin-upstart-branding/runtime.js.map +1 -0
  17. package/dist/vite-plugin-upstart-branding/types.d.ts +14 -0
  18. package/dist/vite-plugin-upstart-branding/types.d.ts.map +1 -0
  19. package/dist/vite-plugin-upstart-branding/types.js +1 -0
  20. package/dist/vite-plugin-upstart-editor/plugin.d.ts +3 -3
  21. package/dist/vite-plugin-upstart-editor/plugin.d.ts.map +1 -1
  22. package/dist/vite-plugin-upstart-editor/plugin.js +3 -16
  23. package/dist/vite-plugin-upstart-editor/plugin.js.map +1 -1
  24. package/dist/vite-plugin-upstart-editor/runtime/click-handler.js +25 -11
  25. package/dist/vite-plugin-upstart-editor/runtime/click-handler.js.map +1 -1
  26. package/dist/vite-plugin-upstart-editor/runtime/error-handler.d.ts +5 -0
  27. package/dist/vite-plugin-upstart-editor/runtime/error-handler.d.ts.map +1 -0
  28. package/dist/vite-plugin-upstart-editor/runtime/error-handler.js +16 -0
  29. package/dist/vite-plugin-upstart-editor/runtime/error-handler.js.map +1 -0
  30. package/dist/vite-plugin-upstart-editor/runtime/hover-overlay.js +1 -1
  31. package/dist/vite-plugin-upstart-editor/runtime/hover-overlay.js.map +1 -1
  32. package/dist/vite-plugin-upstart-editor/runtime/index.d.ts +2 -1
  33. package/dist/vite-plugin-upstart-editor/runtime/index.d.ts.map +1 -1
  34. package/dist/vite-plugin-upstart-editor/runtime/index.js +42 -7
  35. package/dist/vite-plugin-upstart-editor/runtime/index.js.map +1 -1
  36. package/dist/vite-plugin-upstart-editor/runtime/text-editor.d.ts +6 -1
  37. package/dist/vite-plugin-upstart-editor/runtime/text-editor.d.ts.map +1 -1
  38. package/dist/vite-plugin-upstart-editor/runtime/text-editor.js +423 -129
  39. package/dist/vite-plugin-upstart-editor/runtime/text-editor.js.map +1 -1
  40. package/dist/vite-plugin-upstart-editor/runtime/types.d.ts +18 -10
  41. package/dist/vite-plugin-upstart-editor/runtime/types.d.ts.map +1 -1
  42. package/dist/vite-plugin-upstart-theme.d.ts +3 -3
  43. package/dist/vite-plugin-upstart-theme.d.ts.map +1 -1
  44. package/dist/vite-plugin-upstart-theme.js +1 -3
  45. package/dist/vite-plugin-upstart-theme.js.map +1 -1
  46. package/package.json +12 -4
  47. package/src/tests/upstart-editor-api.test.ts +98 -174
  48. package/src/tests/vite-plugin-upstart-attrs.test.ts +408 -105
  49. package/src/tests/vite-plugin-upstart-branding.test.ts +90 -0
  50. package/src/tests/vite-plugin-upstart-editor.test.ts +1 -2
  51. package/src/upstart-editor-api.ts +90 -29
  52. package/src/vite-plugin-upstart-attrs.ts +376 -38
  53. package/src/vite-plugin-upstart-branding/plugin.ts +59 -0
  54. package/src/vite-plugin-upstart-branding/runtime.ts +128 -0
  55. package/src/vite-plugin-upstart-branding/types.ts +10 -0
  56. package/src/vite-plugin-upstart-editor/plugin.ts +4 -19
  57. package/src/vite-plugin-upstart-editor/runtime/click-handler.ts +25 -12
  58. package/src/vite-plugin-upstart-editor/runtime/error-handler.ts +12 -0
  59. package/src/vite-plugin-upstart-editor/runtime/hover-overlay.ts +1 -1
  60. package/src/vite-plugin-upstart-editor/runtime/index.ts +39 -5
  61. package/src/vite-plugin-upstart-editor/runtime/text-editor.ts +518 -141
  62. package/src/vite-plugin-upstart-editor/runtime/types.ts +18 -4
  63. package/src/vite-plugin-upstart-theme.ts +0 -3
  64. package/src/vite-plugin-upstart-editor/PLAN.md +0 -1391
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-upstart-attrs.js","names":["state: TransformState","state","attributes: string[]","current: Expression","i18nKey: string | null"],"sources":["../src/vite-plugin-upstart-attrs.ts"],"sourcesContent":["import { createUnplugin } from \"unplugin\";\nimport { parseSync } from \"oxc-parser\";\nimport { walk } from \"zimmerframe\";\nimport MagicString from \"magic-string\";\nimport path from \"path\";\nimport type {\n Program,\n Node,\n JSXElement,\n JSXOpeningElement,\n JSXAttribute,\n Expression,\n MemberExpression,\n CallExpression,\n} from \"estree-jsx\";\n\ninterface Options {\n enabled: boolean;\n emitRegistry?: boolean;\n}\n\ntype NodeWithRange = Node & { start: number; end: number };\n\nfunction hasRange(node: any): node is NodeWithRange {\n return node && typeof node.start === \"number\" && typeof node.end === \"number\";\n}\n\n// Fast, stable hash function (djb2 variant)\n// Produces a short hex string that's stable across rebuilds\nfunction hashContent(content: string): string {\n let hash = 5381;\n for (let i = 0; i < content.length; i++) {\n hash = ((hash << 5) + hash) ^ content.charCodeAt(i);\n }\n // Convert to unsigned 32-bit and then to hex\n return (hash >>> 0).toString(16);\n}\n\ninterface LoopContext {\n itemName: string;\n indexName: string | null;\n arrayExpr: string;\n}\n\n\ninterface I18nKeyInfo {\n /** The resolved key with namespace, e.g. \"dashboard:features.title\" */\n fullKey: string;\n /** Just the translation key, e.g. \"features.title\" */\n key: string;\n /** The namespace, e.g. \"dashboard\" */\n namespace: string;\n}\n\n// Registry entry for editable elements (text and className)\nexport interface EditableEntry {\n file: string;\n type: \"text\" | \"className\";\n startOffset: number;\n endOffset: number;\n originalContent: string;\n context: { parentTag: string };\n}\n\n// Module-level registry (collected across all files during build)\nconst editableRegistry = new Map<string, EditableEntry>();\n\n// Generate stable ID for editable elements\n// Replace the counter-based ID generation with position-based\nfunction generateId(filePath: string, node: NodeWithRange): string {\n // Use file path + start position for a stable, deterministic ID\n return `${filePath}:${node.start}`;\n}\n\n// Export for testing - get a copy of the current registry\nexport function getRegistry(): Record<string, EditableEntry> {\n return Object.fromEntries(editableRegistry);\n}\n\n// Export for testing - clear registry and counters\nexport function clearRegistry(): void {\n editableRegistry.clear();\n}\n\ninterface TransformState {\n filePath: string;\n code: string;\n s: MagicString;\n loopStack: LoopContext[];\n}\n\nexport const upstartEditor = createUnplugin<Options>((options) => {\n if (!options.enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const emitRegistry = options.emitRegistry ?? true;\n let root = process.cwd();\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n vite: {\n configResolved(config) {\n root = config.root;\n },\n generateBundle() {\n if (!emitRegistry || editableRegistry.size === 0) {\n return;\n }\n\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: \"upstart-registry.json\",\n source: JSON.stringify(registry, null, 2),\n });\n\n // Clear for next build\n editableRegistry.clear();\n },\n },\n\n transformInclude(id) {\n return /\\.(tsx|jsx)$/.test(id) && !id.includes(\"node_modules\");\n },\n\n transform(code, id) {\n // Fast path: skip files without JSX\n if (!code.includes(\"<\")) {\n return null;\n }\n\n try {\n const relativePath = path.relative(root, id);\n const result = transformWithOxc(code, relativePath);\n\n if (!result) {\n return null;\n }\n\n return {\n code: result.code,\n map: result.map,\n };\n } catch (error) {\n console.error(`Error transforming ${id}:`, error);\n return null;\n }\n },\n };\n});\n\nexport function transformWithOxc(code: string, filePath: string) {\n // Parse with oxc (super fast!)\n const ast = parseSync(filePath, code, {\n sourceType: \"module\",\n });\n\n if (!ast.program) {\n return null;\n }\n\n const s = new MagicString(code);\n const state: TransformState = {\n filePath,\n code,\n s,\n loopStack: [],\n };\n\n let modified = false;\n\n // Use zimmerframe to walk and transform the AST\n walk(ast.program as Program, state, {\n _(node: Node, { state, next }: { state: TransformState; next: () => void }) {\n // ENFORCE: Throw error if useTranslation is used for translations (destructuring `t`)\n if (node.type === \"VariableDeclaration\") {\n checkForbiddenUseTranslation(node, state.filePath);\n }\n\n // Handle .map() calls to track loops (must be before JSXElement)\n if (node.type === \"CallExpression\") {\n const loopInfo = detectMapCall(node as CallExpression, state.code);\n\n if (loopInfo) {\n // Push loop context\n state.loopStack.push(loopInfo);\n\n // Continue walking into the callback\n next();\n\n // Pop loop context after traversing\n state.loopStack.pop();\n return;\n }\n }\n\n // Handle JSX elements\n if (node.type === \"JSXElement\") {\n const jsxNode = node as JSXElement;\n const opening = jsxNode.openingElement;\n const tagName = getJSXElementName(opening);\n const insertPos = getAttributeInsertPosition(opening, state.code);\n\n // Track attributes to inject\n const attributes: string[] = [];\n\n // Compute stable hash from the element's source code (includes all children)\n // This hash changes if ANY part of the element or its children change\n if (hasRange(jsxNode)) {\n const elementSource = state.code.slice(jsxNode.start, jsxNode.end);\n const hash = hashContent(elementSource);\n attributes.push(`data-upstart-hash=\"${hash}\"`);\n }\n\n // Check for text leaf elements (any element with only static text)\n if (isTextLeafElement(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n\n // Find the actual JSXText node to track its location\n const textChild = jsxNode.children.find((c) => c.type === \"JSXText\" && (c as any).value?.trim());\n\n if (textChild && hasRange(textChild)) {\n const id = generateId(state.filePath, textChild);\n const textValue = (textChild as any).value as string;\n\n // Calculate trimmed offsets (exclude leading/trailing whitespace)\n const trimmedStart = textChild.start + (textValue.length - textValue.trimStart().length);\n const trimmedEnd = textChild.end - (textValue.length - textValue.trimEnd().length);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"text\",\n startOffset: trimmedStart,\n endOffset: trimmedEnd,\n originalContent: textValue.trim(),\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n\n // Check if this element IS a <Trans> component - add i18n tracking attributes\n const transInfo = detectTransComponent(jsxNode, state.code);\n if (transInfo) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push(`data-i18n-key=\"${escapeProp(transInfo.fullKey)}\"`);\n }\n\n // Track className attribute if it's a string literal\n const classNameAttr = opening.attributes.find(\n (attr): attr is JSXAttribute =>\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n attr.name.name === \"className\" &&\n attr.value?.type === \"Literal\" &&\n typeof (attr.value as any).value === \"string\",\n );\n\n if (classNameAttr && classNameAttr.value && hasRange(classNameAttr.value)) {\n const id = generateId(state.filePath, classNameAttr.value);\n const classValue = (classNameAttr.value as any).value as string;\n\n // +1 and -1 to exclude the quotes\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"className\",\n startOffset: classNameAttr.value.start + 1,\n endOffset: classNameAttr.value.end - 1,\n originalContent: classValue,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-classname-id=\"${id}\"`);\n }\n\n // Process PascalCase components for additional tracking\n if (tagName && /^[A-Z]/.test(tagName)) {\n // File and component tracking\n attributes.push(`data-upstart-file=\"${escapeProp(state.filePath)}\"`);\n attributes.push(`data-upstart-component=\"${escapeProp(tagName)}\"`);\n\n // Loop context tracking\n if (state.loopStack.length > 0) {\n const loop = state.loopStack[state.loopStack.length - 1];\n attributes.push(`data-upstart-loop-item=\"${escapeProp(loop.itemName)}\"`);\n if (loop.indexName) {\n attributes.push(`data-upstart-loop-index={${loop.indexName.toLowerCase()}}`);\n }\n attributes.push(`data-upstart-loop-array=\"${escapeProp(loop.arrayExpr)}\"`);\n }\n\n // Analyze each prop for data bindings\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") {\n continue;\n }\n\n const propName = attr.name.name;\n const binding = analyzeBinding(attr.value, state.code);\n\n if (binding) {\n attributes.push(`data-upstart-prop-${propName.toLowerCase()}=\"${escapeProp(binding.path)}\"`);\n\n if (binding.datasource) {\n attributes.push(\n `data-upstart-datasource-${propName.toLowerCase()}=\"${escapeProp(binding.datasource)}\"`,\n );\n }\n\n if (binding.recordId) {\n attributes.push(`data-upstart-record-id-${propName.toLowerCase()}={${binding.recordId}}`);\n }\n\n // Track conditional expressions\n if (binding.isConditional) {\n attributes.push(`data-upstart-conditional-${propName.toLowerCase()}=\"true\"`);\n }\n }\n }\n }\n\n // Inject attributes if any\n if (insertPos !== -1 && attributes.length > 0) {\n const attrString = \" \" + attributes.join(\" \");\n state.s.appendLeft(insertPos, attrString);\n modified = true;\n }\n }\n\n next();\n },\n });\n\n if (!modified) {\n return null;\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true }),\n };\n}\n\n// Helper: Get JSX element name\nfunction getJSXElementName(opening: JSXOpeningElement): string | null {\n if (opening.name.type === \"JSXIdentifier\") {\n return opening.name.name;\n }\n\n // Handle JSXMemberExpression like <Foo.Bar>\n if (opening.name.type === \"JSXMemberExpression\") {\n let current = opening.name;\n while (current.property) {\n if (current.property.type === \"JSXIdentifier\") {\n return current.property.name;\n }\n if (current.type === \"JSXMemberExpression\") {\n current = current.property as any;\n } else {\n break;\n }\n }\n }\n\n return null;\n}\n\n// Helper: Find where to insert attributes in JSX opening tag\nfunction getAttributeInsertPosition(opening: JSXOpeningElement, code: string): number {\n // If there are existing attributes, insert before the first one\n if (opening.attributes.length > 0) {\n const firstAttr = opening.attributes[0];\n if (hasRange(firstAttr)) {\n return firstAttr.start;\n }\n }\n\n // Otherwise, insert after the tag name\n if (opening.name.type === \"JSXIdentifier\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n if (opening.name.type === \"JSXMemberExpression\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n return -1;\n}\n\n// Helper: Analyze a prop value to extract data binding\nfunction analyzeBinding(\n value: JSXAttribute[\"value\"],\n code: string,\n): {\n path: string;\n datasource?: string;\n recordId?: string;\n isConditional?: boolean;\n} | null {\n if (!value) {\n return null;\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expr = value.expression;\n\n if (expr.type === \"JSXEmptyExpression\") {\n return null;\n }\n\n return analyzeExpression(expr, code);\n }\n\n return null;\n}\n\n// Helper: Analyze any expression to extract binding info\nfunction analyzeExpression(\n expr: Expression,\n code: string,\n): {\n path: string;\n datasource?: string;\n recordId?: string;\n isConditional?: boolean;\n} | null {\n // Handle member expressions: user.name, product.price, etc.\n if (expr.type === \"MemberExpression\") {\n const path = exprToString(expr, code);\n const datasource = extractDatasource(expr);\n const recordId = extractRecordId(expr);\n\n return { path, datasource, recordId };\n }\n\n // Handle identifiers: userName, price, etc.\n if (expr.type === \"Identifier\") {\n return { path: expr.name };\n }\n\n // Handle conditional expressions: condition ? value1 : value2\n if (expr.type === \"ConditionalExpression\") {\n // Try to extract from the consequent\n const consequent = analyzeExpression(expr.consequent, code);\n if (consequent) {\n return {\n ...consequent,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // Handle logical expressions: value1 && value2, value1 || value2\n if (expr.type === \"LogicalExpression\") {\n const right = analyzeExpression(expr.right, code);\n if (right) {\n return {\n ...right,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // For other complex expressions, just return the path\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return {\n path: code.slice(exprWithRange.start, exprWithRange.end),\n };\n }\n\n return null;\n}\n\n// Helper: Convert expression AST to string\nfunction exprToString(expr: Expression, code: string): string {\n // Use the source range to get the actual code\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return code.slice(exprWithRange.start, exprWithRange.end);\n }\n\n // Fallback: reconstruct from AST\n if (expr.type === \"Identifier\") {\n return expr.name;\n }\n\n if (expr.type === \"MemberExpression\") {\n const obj = exprToString(expr.object as Expression, code);\n const prop =\n expr.property.type === \"Identifier\" && !expr.computed\n ? expr.property.name\n : exprToString(expr.property as Expression, code);\n return expr.computed ? `${obj}[${prop}]` : `${obj}.${prop}`;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n const test = exprToString(expr.test, code);\n const consequent = exprToString(expr.consequent, code);\n const alternate = exprToString(expr.alternate, code);\n return `${test} ? ${consequent} : ${alternate}`;\n }\n\n if (expr.type === \"LogicalExpression\") {\n const left = exprToString(expr.left, code);\n const right = exprToString(expr.right, code);\n return `${left} ${expr.operator} ${right}`;\n }\n\n return \"\";\n}\n\n// Helper: Extract datasource name from member expression\nfunction extractDatasource(expr: MemberExpression): string | undefined {\n let current: Expression = expr.object as Expression;\n\n // Traverse to the root object\n while (current.type === \"MemberExpression\") {\n current = current.object as Expression;\n }\n\n if (current.type === \"Identifier\") {\n return current.name;\n }\n\n return undefined;\n}\n\n// Helper: Extract record ID reference\nfunction extractRecordId(expr: MemberExpression): string | undefined {\n const obj = expr.object;\n\n if (obj.type === \"Identifier\") {\n // Assume the ID field is `${object}.id`\n return `${obj.name}.id`;\n }\n\n if (obj.type === \"MemberExpression\") {\n // For nested objects like user.profile.id\n const datasource = extractDatasource(obj);\n if (datasource) {\n return `${datasource}.id`;\n }\n }\n\n return undefined;\n}\n\n// Helper: Detect .map() calls and extract loop context\nfunction detectMapCall(node: CallExpression, code: string): LoopContext | null {\n // Check if this is a .map() call\n if (\n node.callee.type !== \"MemberExpression\" ||\n node.callee.property.type !== \"Identifier\" ||\n node.callee.property.name !== \"map\"\n ) {\n return null;\n }\n\n const callback = node.arguments[0];\n\n if (!callback) {\n return null;\n }\n\n // Check if callback is an arrow function or function expression\n if (callback.type !== \"ArrowFunctionExpression\" && callback.type !== \"FunctionExpression\") {\n return null;\n }\n\n const params = callback.params;\n const itemParam = params[0];\n const indexParam = params[1];\n\n if (!itemParam) {\n return null;\n }\n\n // Extract parameter names\n const itemName = itemParam.type === \"Identifier\" ? itemParam.name : \"item\";\n const indexName = indexParam?.type === \"Identifier\" ? indexParam.name : null;\n\n // Get the array expression\n const arrayExpr = exprToString(node.callee.object as Expression, code);\n\n return {\n itemName,\n indexName,\n arrayExpr,\n };\n}\n\n// Helper: Escape prop values for JSX attributes\nfunction escapeProp(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n// Helper: ENFORCE forbidden useTranslation usage - throw error if `t` is destructured\n// Only `{ i18n }` is allowed (for language switching), not `{ t }` (use <Trans> instead)\nfunction checkForbiddenUseTranslation(node: Node, filePath: string): void {\n if (node.type !== \"VariableDeclaration\") return;\n\n const decl = node as any;\n for (const declarator of decl.declarations) {\n if (\n declarator.id?.type !== \"ObjectPattern\" ||\n !declarator.init ||\n declarator.init.type !== \"CallExpression\"\n ) {\n continue;\n }\n\n const callExpr = declarator.init;\n if (callExpr.callee?.type !== \"Identifier\" || callExpr.callee.name !== \"useTranslation\") {\n continue;\n }\n\n // Check if `t` is being destructured (forbidden)\n for (const prop of declarator.id.properties) {\n if (prop.type !== \"Property\") continue;\n\n if (prop.key?.type === \"Identifier\" && prop.key.name === \"t\") {\n throw new Error(\n `[${filePath}] useTranslation hook is forbidden for translations. ` +\n `Use <Trans i18nKey=\"...\" /> component instead. ` +\n `Only { i18n } destructuring is allowed (for language switching).`,\n );\n }\n }\n }\n}\n\n// Helper: Detect <Trans i18nKey=\"...\" /> component and extract i18n key info\nfunction detectTransComponent(jsxElement: JSXElement, code: string): I18nKeyInfo | null {\n const opening = jsxElement.openingElement;\n const tagName = getJSXElementName(opening);\n\n if (tagName !== \"Trans\") return null;\n\n let i18nKey: string | null = null;\n let namespace = \"translation\";\n\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") continue;\n\n const attrName = attr.name.name;\n\n // Extract i18nKey prop value\n if (attrName === \"i18nKey\" && attr.value?.type === \"Literal\") {\n i18nKey = (attr.value as any).value as string;\n }\n\n // Extract ns prop value (optional namespace override)\n if (attrName === \"ns\" && attr.value?.type === \"Literal\") {\n namespace = (attr.value as any).value as string;\n }\n }\n\n if (!i18nKey) return null;\n\n return {\n fullKey: `${namespace}:${i18nKey}`,\n key: i18nKey,\n namespace,\n };\n}\n\n// Helper: Check if element is a \"leaf\" with only static text (no nested elements or expressions)\nfunction isTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n hasText = true;\n }\n } else if (\n child.type === \"JSXElement\" ||\n child.type === \"JSXFragment\" ||\n child.type === \"JSXExpressionContainer\" ||\n child.type === \"JSXSpreadChild\"\n ) {\n // Has non-text children, not a leaf element\n return false;\n }\n }\n\n return hasText;\n}\n\nexport default upstartEditor.vite;\n"],"mappings":";;;;;;;AAuBA,SAAS,SAAS,MAAkC;AAClD,QAAO,QAAQ,OAAO,KAAK,UAAU,YAAY,OAAO,KAAK,QAAQ;;AAKvE,SAAS,YAAY,SAAyB;CAC5C,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAClC,SAAS,QAAQ,KAAK,OAAQ,QAAQ,WAAW,EAAE;AAGrD,SAAQ,SAAS,GAAG,SAAS,GAAG;;AA8BlC,MAAM,mCAAmB,IAAI,KAA4B;AAIzD,SAAS,WAAW,UAAkB,MAA6B;AAEjE,QAAO,GAAG,SAAS,GAAG,KAAK;;AAI7B,SAAgB,cAA6C;AAC3D,QAAO,OAAO,YAAY,iBAAiB;;AAI7C,SAAgB,gBAAsB;AACpC,kBAAiB,OAAO;;AAU1B,MAAa,gBAAgB,gBAAyB,YAAY;AAChE,KAAI,CAAC,QAAQ,QACX,QA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W,SAC7B,KAAI,MAAM,SAAS,WAEjB;MADmB,MAAc,OAClB,MAAM,CACnB,WAAU;YAGZ,MAAM,SAAS,gBACf,MAAM,SAAS,iBACf,MAAM,SAAS,4BACf,MAAM,SAAS,iBAGf,QAAO;AAIX,QAAO;;AAGT,wCAAe,cAAc"}
1
+ {"version":3,"file":"vite-plugin-upstart-attrs.js","names":["state: TransformState","state","attributes: string[]","current: Expression","keyResult: { value: string; expr: string | null } | null","nsResult: { value: string; expr: string | null } | null","results: I18nKeyInfo[]"],"sources":["../src/vite-plugin-upstart-attrs.ts"],"sourcesContent":["import { createUnplugin } from \"unplugin\";\nimport { parseSync } from \"oxc-parser\";\nimport { walk } from \"zimmerframe\";\nimport MagicString from \"magic-string\";\nimport path from \"path\";\nimport type {\n Program,\n Node,\n JSXElement,\n JSXOpeningElement,\n JSXAttribute,\n Expression,\n MemberExpression,\n CallExpression,\n} from \"estree-jsx\";\n\ninterface Options {\n enabled: boolean;\n emitRegistry?: boolean;\n}\n\ntype NodeWithRange = Node & { start: number; end: number };\n\nfunction hasRange(node: any): node is NodeWithRange {\n return node && typeof node.start === \"number\" && typeof node.end === \"number\";\n}\n\n// Fast, stable hash function (djb2 variant)\n// Produces a short hex string that's stable across rebuilds\nfunction hashContent(content: string): string {\n let hash = 5381;\n for (let i = 0; i < content.length; i++) {\n hash = ((hash << 5) + hash) ^ content.charCodeAt(i);\n }\n // Convert to unsigned 32-bit and then to hex\n return (hash >>> 0).toString(16);\n}\n\ninterface LoopContext {\n itemName: string;\n indexName: string | null;\n arrayExpr: string;\n}\n\ninterface I18nKeyInfo {\n /** The resolved key with namespace, e.g. \"dashboard:features.title\" */\n fullKey: string;\n /** Just the translation key, e.g. \"features.title\" */\n key: string;\n /** The namespace, e.g. \"dashboard\" */\n namespace: string;\n /** Source expression for i18nKey when dynamic (e.g. \"stat.labelKey\"), null when static */\n keyExpr: string | null;\n /** Source expression for namespace when dynamic, null when static */\n nsExpr: string | null;\n}\n\n// Registry entry for editable elements (text and className)\nexport interface EditableEntry {\n file: string;\n type: \"text\" | \"className\";\n startOffset: number;\n endOffset: number;\n originalContent: string;\n context: { parentTag: string };\n}\n\n// Module-level registry (collected across all files during build)\nconst editableRegistry = new Map<string, EditableEntry>();\n\n// Generate stable ID for editable elements\n// Replace the counter-based ID generation with position-based\nfunction generateId(filePath: string, node: NodeWithRange): string {\n // Use file path + start position for a stable, deterministic ID\n return `${filePath}:${node.start}`;\n}\n\n// Export for testing - get a copy of the current registry\nexport function getRegistry(): Record<string, EditableEntry> {\n return Object.fromEntries(editableRegistry);\n}\n\n// Export for testing - clear registry and counters\nexport function clearRegistry(): void {\n editableRegistry.clear();\n}\n\ninterface TransformState {\n filePath: string;\n code: string;\n s: MagicString;\n loopStack: LoopContext[];\n /** Tracks const varName = \"literal\" declarations for resolving dynamic i18nKey expressions */\n constants: Map<string, string>;\n /** Maps t-function variable names to their default namespace, e.g. { \"t\": \"dashboard\" } */\n tFunctions: Map<string, string>;\n}\n\nexport const upstartEditor = createUnplugin<Options>((options) => {\n if (!options.enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const emitRegistry = options.emitRegistry ?? true;\n let root = process.cwd();\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n vite: {\n configResolved(config) {\n root = config.root;\n },\n generateBundle() {\n if (!emitRegistry || editableRegistry.size === 0) {\n return;\n }\n\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: \"upstart-registry.json\",\n source: JSON.stringify(registry, null, 2),\n });\n\n // Clear for next build\n editableRegistry.clear();\n },\n },\n\n transformInclude(id) {\n return /\\.(tsx|jsx)$/.test(id) && !id.includes(\"node_modules\");\n },\n\n transform(code, id) {\n // Fast path: skip files without JSX\n if (!code.includes(\"<\")) {\n return null;\n }\n\n try {\n const relativePath = path.relative(root, id);\n const result = transformWithOxc(code, relativePath);\n\n if (!result) {\n return null;\n }\n\n return {\n code: result.code,\n map: result.map,\n };\n } catch (error) {\n console.error(`Error transforming ${id}:`, error);\n return null;\n }\n },\n };\n});\n\nexport function transformWithOxc(code: string, filePath: string) {\n // Parse with oxc (super fast!)\n const ast = parseSync(filePath, code, {\n sourceType: \"module\",\n });\n\n if (!ast.program) {\n return null;\n }\n\n const s = new MagicString(code);\n const state: TransformState = {\n filePath,\n code,\n s,\n loopStack: [],\n constants: new Map(),\n tFunctions: new Map(),\n };\n\n let modified = false;\n\n // Use zimmerframe to walk and transform the AST\n walk(ast.program as Program, state, {\n _(node: Node, { state, next }: { state: TransformState; next: () => void }) {\n // Track useTranslation() calls to resolve t() function namespaces\n if (node.type === \"VariableDeclaration\") {\n trackUseTranslation(node, state);\n\n // Track const varName = \"literal\" for resolving dynamic i18nKey expressions\n for (const decl of (node as any).declarations) {\n if (\n decl.type === \"VariableDeclarator\" &&\n decl.id?.type === \"Identifier\" &&\n decl.init?.type === \"Literal\" &&\n typeof decl.init.value === \"string\"\n ) {\n state.constants.set(decl.id.name, decl.init.value);\n }\n }\n }\n\n // Handle .map() calls to track loops (must be before JSXElement)\n if (node.type === \"CallExpression\") {\n const loopInfo = detectMapCall(node as CallExpression, state.code);\n\n if (loopInfo) {\n // Push loop context\n state.loopStack.push(loopInfo);\n\n // Continue walking into the callback\n next();\n\n // Pop loop context after traversing\n state.loopStack.pop();\n return;\n }\n }\n\n // Handle JSX elements\n if (node.type === \"JSXElement\") {\n const jsxNode = node as JSXElement;\n const opening = jsxNode.openingElement;\n const tagName = getJSXElementName(opening);\n\n // Skip ALL attribute injection for <Trans> elements.\n // <Trans> renders to a text node at runtime, so DOM attributes are lost.\n // The i18n attributes are promoted to the parent element instead.\n if (tagName === \"Trans\") {\n next();\n return;\n }\n\n const insertPos = getAttributeInsertPosition(opening, state.code);\n\n // Track attributes to inject\n const attributes: string[] = [];\n\n // Compute stable hash from the element's source code (includes all children)\n // This hash changes if ANY part of the element or its children change\n if (hasRange(jsxNode)) {\n const elementSource = state.code.slice(jsxNode.start, jsxNode.end);\n const hash = hashContent(elementSource);\n\n // Collect index variables from all enclosing loops so elements\n // inside .map() get a unique hash per iteration at runtime.\n const loopIndices = state.loopStack.map((l) => l.indexName).filter((n): n is string => n !== null);\n\n if (loopIndices.length > 0) {\n const suffix = loopIndices.map((n) => `\\${${n}}`).join(\"-\");\n attributes.push(`data-upstart-hash={\\`${hash}-${suffix}\\`}`);\n } else {\n attributes.push(`data-upstart-hash=\"${hash}\"`);\n }\n }\n\n // --- Editable text detection ---\n // Priority: i18n (true) > non-i18n text (false) > no text (no attribute)\n\n // Step 1: Check for Trans children AND t() calls (editable via i18n, gets \"true\")\n const transChildren = findTransInChildren(jsxNode, state.code, state.constants);\n const tCallChildren = findTCallsInChildren(jsxNode, state.code, state);\n const allI18nKeys = [...transChildren, ...tCallChildren];\n const hasI18n = allI18nKeys.length > 0;\n\n if (hasI18n) {\n attributes.push('data-upstart-editable-text=\"true\"');\n\n const hasDynamic = allI18nKeys.some((t) => t.keyExpr || t.nsExpr);\n if (hasDynamic) {\n // Build a runtime JSX template expression for dynamic i18n keys\n const parts = allI18nKeys.map((t) => {\n const nsPart = t.nsExpr ? `\\${${t.nsExpr}}` : t.namespace;\n const keyPart = t.keyExpr ? `\\${${t.keyExpr}}` : t.key;\n return `${nsPart}:${keyPart}`;\n });\n attributes.push(`data-upstart-i18n={\\`${parts.join(\",\")}\\`}`);\n } else {\n const keys = allI18nKeys.map((t: I18nKeyInfo) => escapeProp(t.fullKey)).join(\",\");\n attributes.push(`data-upstart-i18n=\"${keys}\"`);\n }\n }\n\n // Step 2: Text leaf elements — registry tracking + non-editable flag\n if (isTextLeafElement(jsxNode)) {\n if (!hasI18n) {\n attributes.push('data-upstart-editable-text=\"false\"');\n }\n\n // Find the actual JSXText node to track its location\n const textChild = jsxNode.children.find((c) => c.type === \"JSXText\" && (c as any).value?.trim());\n\n if (textChild && hasRange(textChild)) {\n const id = generateId(state.filePath, textChild);\n const textValue = (textChild as any).value as string;\n\n // Calculate trimmed offsets (exclude leading/trailing whitespace)\n const trimmedStart = textChild.start + (textValue.length - textValue.trimStart().length);\n const trimmedEnd = textChild.end - (textValue.length - textValue.trimEnd().length);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"text\",\n startOffset: trimmedStart,\n endOffset: trimmedEnd,\n originalContent: textValue.trim(),\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n // Step 3: Non-leaf elements with visible text content (expressions, mixed content)\n else if (!hasI18n && hasVisibleTextContent(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"false\"');\n }\n\n // Track className attribute if it's a string literal\n const classNameAttr = opening.attributes.find(\n (attr): attr is JSXAttribute =>\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n attr.name.name === \"className\" &&\n attr.value?.type === \"Literal\" &&\n typeof (attr.value as any).value === \"string\",\n );\n\n if (classNameAttr && classNameAttr.value && hasRange(classNameAttr.value)) {\n const id = generateId(state.filePath, classNameAttr.value);\n const classValue = (classNameAttr.value as any).value as string;\n\n // +1 and -1 to exclude the quotes\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"className\",\n startOffset: classNameAttr.value.start + 1,\n endOffset: classNameAttr.value.end - 1,\n originalContent: classValue,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-classname-id=\"${id}\"`);\n }\n\n // Process PascalCase components for additional tracking\n if (tagName && /^[A-Z]/.test(tagName)) {\n // File and component tracking\n attributes.push(`data-upstart-file=\"${escapeProp(state.filePath)}\"`);\n attributes.push(`data-upstart-component=\"${escapeProp(tagName)}\"`);\n\n // Loop context tracking\n if (state.loopStack.length > 0) {\n const loop = state.loopStack[state.loopStack.length - 1];\n attributes.push(`data-upstart-loop-item=\"${escapeProp(loop.itemName)}\"`);\n if (loop.indexName) {\n attributes.push(`data-upstart-loop-index={${loop.indexName.toLowerCase()}}`);\n }\n attributes.push(`data-upstart-loop-array=\"${escapeProp(loop.arrayExpr)}\"`);\n }\n\n // Analyze each prop for data bindings\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") {\n continue;\n }\n\n const propName = attr.name.name;\n const binding = analyzeBinding(attr.value, state.code);\n\n if (binding) {\n attributes.push(`data-upstart-prop-${propName.toLowerCase()}=\"${escapeProp(binding.path)}\"`);\n\n if (binding.datasource) {\n attributes.push(\n `data-upstart-datasource-${propName.toLowerCase()}=\"${escapeProp(binding.datasource)}\"`,\n );\n }\n\n if (binding.recordId) {\n attributes.push(`data-upstart-record-id-${propName.toLowerCase()}={${binding.recordId}}`);\n }\n\n // Track conditional expressions\n if (binding.isConditional) {\n attributes.push(`data-upstart-conditional-${propName.toLowerCase()}=\"true\"`);\n }\n }\n }\n }\n\n // Inject attributes if any\n if (insertPos !== -1 && attributes.length > 0) {\n const attrString = \" \" + attributes.join(\" \");\n state.s.appendLeft(insertPos, attrString);\n modified = true;\n }\n }\n\n next();\n },\n });\n\n if (!modified) {\n return null;\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true }),\n };\n}\n\n// Helper: Get JSX element name\nfunction getJSXElementName(opening: JSXOpeningElement): string | null {\n if (opening.name.type === \"JSXIdentifier\") {\n return opening.name.name;\n }\n\n // Handle JSXMemberExpression like <Foo.Bar>\n if (opening.name.type === \"JSXMemberExpression\") {\n let current = opening.name;\n while (current.property) {\n if (current.property.type === \"JSXIdentifier\") {\n return current.property.name;\n }\n if (current.type === \"JSXMemberExpression\") {\n current = current.property as any;\n } else {\n break;\n }\n }\n }\n\n return null;\n}\n\n// Helper: Find where to insert attributes in JSX opening tag\nfunction getAttributeInsertPosition(opening: JSXOpeningElement, code: string): number {\n // If there are existing attributes, insert before the first one\n if (opening.attributes.length > 0) {\n const firstAttr = opening.attributes[0];\n if (hasRange(firstAttr)) {\n return firstAttr.start;\n }\n }\n\n // Otherwise, insert after the tag name\n if (opening.name.type === \"JSXIdentifier\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n if (opening.name.type === \"JSXMemberExpression\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n return -1;\n}\n\n// Helper: Analyze a prop value to extract data binding\nfunction analyzeBinding(\n value: JSXAttribute[\"value\"],\n code: string,\n): {\n path: string;\n datasource?: string;\n recordId?: string;\n isConditional?: boolean;\n} | null {\n if (!value) {\n return null;\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expr = value.expression;\n\n if (expr.type === \"JSXEmptyExpression\") {\n return null;\n }\n\n return analyzeExpression(expr, code);\n }\n\n return null;\n}\n\n// Helper: Analyze any expression to extract binding info\nfunction analyzeExpression(\n expr: Expression,\n code: string,\n): {\n path: string;\n datasource?: string;\n recordId?: string;\n isConditional?: boolean;\n} | null {\n // Handle member expressions: user.name, product.price, etc.\n if (expr.type === \"MemberExpression\") {\n const path = exprToString(expr, code);\n const datasource = extractDatasource(expr);\n const recordId = extractRecordId(expr);\n\n return { path, datasource, recordId };\n }\n\n // Handle identifiers: userName, price, etc.\n if (expr.type === \"Identifier\") {\n return { path: expr.name };\n }\n\n // Handle conditional expressions: condition ? value1 : value2\n if (expr.type === \"ConditionalExpression\") {\n // Try to extract from the consequent\n const consequent = analyzeExpression(expr.consequent, code);\n if (consequent) {\n return {\n ...consequent,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // Handle logical expressions: value1 && value2, value1 || value2\n if (expr.type === \"LogicalExpression\") {\n const right = analyzeExpression(expr.right, code);\n if (right) {\n return {\n ...right,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // For other complex expressions, just return the path\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return {\n path: code.slice(exprWithRange.start, exprWithRange.end),\n };\n }\n\n return null;\n}\n\n// Helper: Convert expression AST to string\nfunction exprToString(expr: Expression, code: string): string {\n // Use the source range to get the actual code\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return code.slice(exprWithRange.start, exprWithRange.end);\n }\n\n // Fallback: reconstruct from AST\n if (expr.type === \"Identifier\") {\n return expr.name;\n }\n\n if (expr.type === \"MemberExpression\") {\n const obj = exprToString(expr.object as Expression, code);\n const prop =\n expr.property.type === \"Identifier\" && !expr.computed\n ? expr.property.name\n : exprToString(expr.property as Expression, code);\n return expr.computed ? `${obj}[${prop}]` : `${obj}.${prop}`;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n const test = exprToString(expr.test, code);\n const consequent = exprToString(expr.consequent, code);\n const alternate = exprToString(expr.alternate, code);\n return `${test} ? ${consequent} : ${alternate}`;\n }\n\n if (expr.type === \"LogicalExpression\") {\n const left = exprToString(expr.left, code);\n const right = exprToString(expr.right, code);\n return `${left} ${expr.operator} ${right}`;\n }\n\n return \"\";\n}\n\n// Helper: Extract datasource name from member expression\nfunction extractDatasource(expr: MemberExpression): string | undefined {\n let current: Expression = expr.object as Expression;\n\n // Traverse to the root object\n while (current.type === \"MemberExpression\") {\n current = current.object as Expression;\n }\n\n if (current.type === \"Identifier\") {\n return current.name;\n }\n\n return undefined;\n}\n\n// Helper: Extract record ID reference\nfunction extractRecordId(expr: MemberExpression): string | undefined {\n const obj = expr.object;\n\n if (obj.type === \"Identifier\") {\n // Assume the ID field is `${object}.$id`\n return `${obj.name}.$id`;\n }\n\n if (obj.type === \"MemberExpression\") {\n // For nested objects like user.profile.id\n const datasource = extractDatasource(obj);\n if (datasource) {\n return `${datasource}.$id`;\n }\n }\n\n return undefined;\n}\n\n// Helper: Detect .map() calls and extract loop context\nfunction detectMapCall(node: CallExpression, code: string): LoopContext | null {\n // Check if this is a .map() call\n if (\n node.callee.type !== \"MemberExpression\" ||\n node.callee.property.type !== \"Identifier\" ||\n node.callee.property.name !== \"map\"\n ) {\n return null;\n }\n\n const callback = node.arguments[0];\n\n if (!callback) {\n return null;\n }\n\n // Check if callback is an arrow function or function expression\n if (callback.type !== \"ArrowFunctionExpression\" && callback.type !== \"FunctionExpression\") {\n return null;\n }\n\n const params = callback.params;\n const itemParam = params[0];\n const indexParam = params[1];\n\n if (!itemParam) {\n return null;\n }\n\n // Extract parameter names\n const itemName = itemParam.type === \"Identifier\" ? itemParam.name : \"item\";\n const indexName = indexParam?.type === \"Identifier\" ? indexParam.name : null;\n\n // Get the array expression\n const arrayExpr = exprToString(node.callee.object as Expression, code);\n\n return {\n itemName,\n indexName,\n arrayExpr,\n };\n}\n\n// Helper: Escape prop values for JSX attributes\nfunction escapeProp(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n// Helper: Track useTranslation() calls to map t-function variable names to their namespace\nfunction trackUseTranslation(node: Node, state: TransformState): void {\n if (node.type !== \"VariableDeclaration\") return;\n\n const decl = node as any;\n for (const declarator of decl.declarations) {\n if (\n declarator.id?.type !== \"ObjectPattern\" ||\n !declarator.init ||\n declarator.init.type !== \"CallExpression\"\n ) {\n continue;\n }\n\n const callExpr = declarator.init;\n if (callExpr.callee?.type !== \"Identifier\" || callExpr.callee.name !== \"useTranslation\") {\n continue;\n }\n\n const namespace = extractUseTranslationNamespace(callExpr);\n\n for (const prop of declarator.id.properties) {\n if (prop.type !== \"Property\") continue;\n if (prop.key?.type !== \"Identifier\" || prop.key.name !== \"t\") continue;\n\n // Handle aliased destructuring: { t: translate } → maps \"translate\" to namespace\n const localName = prop.value?.type === \"Identifier\" ? prop.value.name : \"t\";\n state.tFunctions.set(localName, namespace);\n }\n }\n}\n\n// Helper: Extract namespace from useTranslation() call arguments\nfunction extractUseTranslationNamespace(callExpr: any): string {\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return \"translation\";\n\n // String literal: useTranslation(\"dashboard\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n return firstArg.value;\n }\n\n // Array expression: useTranslation([\"dashboard\", \"common\"])\n if (firstArg.type === \"ArrayExpression\" && firstArg.elements?.length > 0) {\n const first = firstArg.elements[0];\n if (first?.type === \"Literal\" && typeof first.value === \"string\") {\n return first.value;\n }\n }\n\n return \"translation\";\n}\n\n// Helper: Resolve a JSX attribute value to a string.\n// Handles string literals directly, and JSXExpressionContainer by resolving\n// Identifier references via the constants map, or returning the expression source for dynamic values.\nfunction resolveJSXAttrValue(\n value: any,\n code: string,\n constants: Map<string, string>,\n): { value: string; expr: string | null } | null {\n if (!value) return null;\n\n if (value.type === \"Literal\" && typeof value.value === \"string\") {\n return { value: value.value, expr: null };\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expression = value.expression;\n if (!expression) return null;\n\n // Resolve simple identifiers via constants map (e.g. i18nKey={labelKey} where const labelKey = \"...\")\n if (expression.type === \"Identifier\" && constants.has(expression.name)) {\n return { value: constants.get(expression.name)!, expr: null };\n }\n\n // Dynamic expression — return source text so caller can emit a runtime JSX expression\n if (hasRange(expression)) {\n const src = code.slice(expression.start, expression.end);\n return { value: src, expr: src };\n }\n }\n\n return null;\n}\n\n// Helper: Detect <Trans i18nKey=\"...\" /> component and extract i18n key info\nfunction detectTransComponent(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo | null {\n const opening = jsxElement.openingElement;\n const tagName = getJSXElementName(opening);\n\n if (tagName !== \"Trans\") return null;\n\n let keyResult: { value: string; expr: string | null } | null = null;\n let nsResult: { value: string; expr: string | null } | null = null;\n\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") continue;\n\n const attrName = attr.name.name;\n\n if (attrName === \"i18nKey\") {\n keyResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n\n if (attrName === \"ns\") {\n nsResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n }\n\n if (!keyResult) {\n return null;\n }\n\n const key = keyResult.value;\n const namespace = nsResult?.value ?? \"translation\";\n const keyExpr = keyResult.expr;\n const nsExpr = nsResult?.expr ?? null;\n\n return {\n fullKey: `${namespace}:${key}`,\n key,\n namespace,\n keyExpr,\n nsExpr,\n };\n}\n\n// Helper: Scan an element's direct children for <Trans> components and extract i18n key info.\n// Handles direct <Trans> children and <Trans> inside JSXExpressionContainer (e.g. {show && <Trans>}).\nfunction findTransInChildren(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo[] {\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXElement\") {\n const info = detectTransComponent(child as JSXElement, code, constants);\n if (info) results.push(info);\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTransInExpression(expr, code, results, constants);\n }\n }\n }\n\n return results;\n}\n\n// Helper: Recursively search an expression tree for <Trans> JSXElements.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct JSXElement.\nfunction findTransInExpression(\n expr: any,\n code: string,\n results: I18nKeyInfo[],\n constants: Map<string, string>,\n): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"JSXElement\") {\n const info = detectTransComponent(expr as JSXElement, code, constants);\n if (info) results.push(info);\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTransInExpression(expr.left, code, results, constants);\n findTransInExpression(expr.right, code, results, constants);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTransInExpression(expr.consequent, code, results, constants);\n findTransInExpression(expr.alternate, code, results, constants);\n return;\n }\n\n // Handle .map() and other call expressions — recurse into arguments\n if (expr.type === \"CallExpression\") {\n for (const arg of expr.arguments) {\n findTransInExpression(arg, code, results, constants);\n }\n return;\n }\n\n // Handle arrow/function expressions — recurse into body\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTransInExpression(expr.body, code, results, constants);\n return;\n }\n\n // Handle block bodies (arrow functions with braces)\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTransInExpression(stmt.argument, code, results, constants);\n }\n }\n return;\n }\n}\n\n// Helper: Scan an element's direct children for t() function calls and extract i18n key info.\nfunction findTCallsInChildren(jsxElement: JSXElement, code: string, state: TransformState): I18nKeyInfo[] {\n if (state.tFunctions.size === 0) return [];\n\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTCallInExpression(expr, code, results, state);\n }\n }\n }\n\n return results;\n}\n\n// Helper: Recursively search an expression tree for t() calls.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct CallExpression.\nfunction findTCallInExpression(expr: any, code: string, results: I18nKeyInfo[], state: TransformState): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"CallExpression\") {\n const info = detectTCall(expr, code, state);\n if (info) {\n results.push(info);\n return;\n }\n // Not a t() call — recurse into arguments (for .map() callbacks etc.)\n for (const arg of expr.arguments) {\n findTCallInExpression(arg, code, results, state);\n }\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTCallInExpression(expr.left, code, results, state);\n findTCallInExpression(expr.right, code, results, state);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTCallInExpression(expr.consequent, code, results, state);\n findTCallInExpression(expr.alternate, code, results, state);\n return;\n }\n\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTCallInExpression(expr.body, code, results, state);\n return;\n }\n\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTCallInExpression(stmt.argument, code, results, state);\n }\n }\n return;\n }\n}\n\n// Helper: Detect a t(\"key\") call and extract i18n key info.\nfunction detectTCall(callExpr: any, code: string, state: TransformState): I18nKeyInfo | null {\n if (callExpr.callee?.type !== \"Identifier\") return null;\n\n const calleeName = callExpr.callee.name;\n const namespace = state.tFunctions.get(calleeName);\n if (namespace === undefined) return null;\n\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return null;\n\n // Static string key: t(\"features.title\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n const key = firstArg.value;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n // Dynamic key — try constant resolution first, then fall back to expression\n if (hasRange(firstArg)) {\n const exprSrc = code.slice(firstArg.start, firstArg.end);\n\n if (firstArg.type === \"Identifier\" && state.constants.has(firstArg.name)) {\n const key = state.constants.get(firstArg.name)!;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n return { fullKey: `${namespace}:${exprSrc}`, key: exprSrc, namespace, keyExpr: exprSrc, nsExpr: null };\n }\n\n return null;\n}\n\n// Helper: Check if element is a \"leaf\" with only static text (no nested elements or expressions)\nfunction isTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n hasText = true;\n }\n } else if (\n child.type === \"JSXElement\" ||\n child.type === \"JSXFragment\" ||\n child.type === \"JSXExpressionContainer\" ||\n child.type === \"JSXSpreadChild\"\n ) {\n // Has non-text children, not a leaf element\n return false;\n }\n }\n\n return hasText;\n}\n\n// Helper: Check if element has any visible text content (static or dynamic).\n// Broader than isTextLeafElement — returns true even if the element has other child types.\n// Detects JSXText with non-whitespace content and expression containers with\n// text-producing expressions (Identifier, MemberExpression, Literal, TemplateLiteral).\n// Skips CallExpression, ConditionalExpression, LogicalExpression (these typically produce elements).\nfunction hasVisibleTextContent(jsxElement: JSXElement): boolean {\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n return true;\n }\n continue;\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") {\n continue;\n }\n if (\n expr.type === \"Identifier\" ||\n expr.type === \"MemberExpression\" ||\n expr.type === \"Literal\" ||\n expr.type === \"TemplateLiteral\"\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport default upstartEditor.vite;\n"],"mappings":";;;;;;;AAuBA,SAAS,SAAS,MAAkC;AAClD,QAAO,QAAQ,OAAO,KAAK,UAAU,YAAY,OAAO,KAAK,QAAQ;;AAKvE,SAAS,YAAY,SAAyB;CAC5C,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAClC,SAAS,QAAQ,KAAK,OAAQ,QAAQ,WAAW,EAAE;AAGrD,SAAQ,SAAS,GAAG,SAAS,GAAG;;AAiClC,MAAM,mCAAmB,IAAI,KAA4B;AAIzD,SAAS,WAAW,UAAkB,MAA6B;AAEjE,QAAO,GAAG,SAAS,GAAG,KAAK;;AAI7B,SAAgB,cAA6C;AAC3D,QAAO,OAAO,YAAY,iBAAiB;;AAI7C,SAAgB,gBAAsB;AACpC,kBAAiB,OAAO;;AAc1B,MAAa,gBAAgB,gBAAyB,YAAY;AAChE,KAAI,CAAC,QAAQ,QACX,QAAO,EAAE,MAAM,2BAA2B;CAG5C,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,IAAI,OAAO,QAAQ,KAAK;AAExB,QAAO;EACL,MAAM;EACN,SAAS;EAET,MAAM;GACJ,eAAe,QAAQ;AACrB,WAAO,OAAO;;GAEhB,iBAAiB;AACf,QAAI,CAAC,gBAAgB,iBAAiB,SAAS,EAC7C;IAGF,MAAM,WAAW;KACf,SAAS;KACT,8BAAa,IAAI,MAAM,EAAC,aAAa;KACrC,UAAU,OAAO,YAAY,iBAAiB;KAC/C;AAED,SAA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,WAAW,SAC7B,KAAI,MAAM,SAAS,WAEjB;MADmB,MAAc,OAClB,MAAM,CACnB,WAAU;YAGZ,MAAM,SAAS,gBACf,MAAM,SAAS,iBACf,MAAM,SAAS,4BACf,MAAM,SAAS,iBAGf,QAAO;AAIX,QAAO;;AAQT,SAAS,sBAAsB,YAAiC;AAC9D,MAAK,MAAM,SAAS,WAAW,UAAU;AACvC,MAAI,MAAM,SAAS,WAAW;AAE5B,OADmB,MAAc,OAClB,MAAM,CACnB,QAAO;AAET;;AAGF,MAAI,MAAM,SAAS,0BAA0B;GAC3C,MAAM,OAAQ,MAAc;AAC5B,OAAI,CAAC,QAAQ,KAAK,SAAS,qBACzB;AAEF,OACE,KAAK,SAAS,gBACd,KAAK,SAAS,sBACd,KAAK,SAAS,aACd,KAAK,SAAS,kBAEd,QAAO;;;AAKb,QAAO;;AAGT,wCAAe,cAAc"}
@@ -0,0 +1,17 @@
1
+ import { UpstartBrandingPluginOptions } from "./types.js";
2
+ import * as unplugin8 from "unplugin";
3
+
4
+ //#region src/vite-plugin-upstart-branding/plugin.d.ts
5
+
6
+ /**
7
+ * Upstart Branding Vite plugin (build-time)
8
+ *
9
+ * Injects a "Made with Upstart" badge into the app entry during build.
10
+ * The badge appears at the bottom of the page, then fades out after a
11
+ * few seconds or when the user scrolls.
12
+ */
13
+ declare const upstartBranding: unplugin8.UnpluginInstance<UpstartBrandingPluginOptions, boolean>;
14
+ declare const _default: (options: UpstartBrandingPluginOptions) => unplugin8.VitePlugin<any> | unplugin8.VitePlugin<any>[];
15
+ //#endregion
16
+ export { _default as default, upstartBranding };
17
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../src/vite-plugin-upstart-branding/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAgBA;AAwCG;;;cAxCU,iBAAe,SAAA,CAAA,iBAAA;cAwCzB"}
@@ -0,0 +1,41 @@
1
+ import path from "node:path";
2
+ import { createUnplugin } from "unplugin";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ //#region src/vite-plugin-upstart-branding/plugin.ts
6
+ const DEFAULT_OPTIONS = { enabled: false };
7
+ /**
8
+ * Upstart Branding Vite plugin (build-time)
9
+ *
10
+ * Injects a "Made with Upstart" badge into the app entry during build.
11
+ * The badge appears at the bottom of the page, then fades out after a
12
+ * few seconds or when the user scrolls.
13
+ */
14
+ const upstartBranding = createUnplugin((options = {}) => {
15
+ const { enabled } = {
16
+ ...DEFAULT_OPTIONS,
17
+ ...options
18
+ };
19
+ if (!enabled) return { name: "upstart-branding-disabled" };
20
+ const runtimePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "./runtime");
21
+ return {
22
+ name: "upstart-branding",
23
+ enforce: "pre",
24
+ transform(code, id) {
25
+ const [cleanId] = id.split("?");
26
+ if (!cleanId || cleanId.includes("node_modules")) return null;
27
+ if (!/\.(t|j)sx?$/.test(cleanId)) return null;
28
+ if (!cleanId.includes("entry.client.tsx")) return null;
29
+ if (code.includes("initUpstartBranding")) return null;
30
+ return {
31
+ code: `${`import { initUpstartBranding } from ${JSON.stringify(runtimePath)};`}${code}requestIdleCallback(initUpstartBranding);`,
32
+ map: null
33
+ };
34
+ }
35
+ };
36
+ });
37
+ var plugin_default = upstartBranding.vite;
38
+
39
+ //#endregion
40
+ export { plugin_default as default, upstartBranding };
41
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","names":["DEFAULT_OPTIONS: Required<UpstartBrandingPluginOptions>"],"sources":["../../src/vite-plugin-upstart-branding/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createUnplugin } from \"unplugin\";\nimport type { UpstartBrandingPluginOptions } from \"./types.js\";\n\nconst DEFAULT_OPTIONS: Required<UpstartBrandingPluginOptions> = {\n enabled: false,\n};\n\n/**\n * Upstart Branding Vite plugin (build-time)\n *\n * Injects a \"Made with Upstart\" badge into the app entry during build.\n * The badge appears at the bottom of the page, then fades out after a\n * few seconds or when the user scrolls.\n */\nexport const upstartBranding = createUnplugin<UpstartBrandingPluginOptions>((options = {}) => {\n const { enabled } = { ...DEFAULT_OPTIONS, ...options };\n\n if (!enabled) {\n return { name: \"upstart-branding-disabled\" };\n }\n\n const runtimePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"./runtime\");\n\n return {\n name: \"upstart-branding\",\n enforce: \"pre\",\n\n transform(code, id) {\n const [cleanId] = id.split(\"?\");\n if (!cleanId || cleanId.includes(\"node_modules\")) {\n return null;\n }\n\n if (!/\\.(t|j)sx?$/.test(cleanId)) {\n return null;\n }\n\n if (!cleanId.includes(\"entry.client.tsx\")) {\n return null;\n }\n\n if (code.includes(\"initUpstartBranding\")) {\n return null;\n }\n\n const imports = `import { initUpstartBranding } from ${JSON.stringify(runtimePath)};`;\n const injection = \"requestIdleCallback(initUpstartBranding);\";\n\n return {\n code: `${imports}${code}${injection}`,\n map: null,\n };\n },\n };\n});\n\nexport default upstartBranding.vite;\n"],"mappings":";;;;;AAKA,MAAMA,kBAA0D,EAC9D,SAAS,OACV;;;;;;;;AASD,MAAa,kBAAkB,gBAA8C,UAAU,EAAE,KAAK;CAC5F,MAAM,EAAE,YAAY;EAAE,GAAG;EAAiB,GAAG;EAAS;AAEtD,KAAI,CAAC,QACH,QAAO,EAAE,MAAM,6BAA6B;CAG9C,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,YAAY;AAE3F,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAU,MAAM,IAAI;GAClB,MAAM,CAAC,WAAW,GAAG,MAAM,IAAI;AAC/B,OAAI,CAAC,WAAW,QAAQ,SAAS,eAAe,CAC9C,QAAO;AAGT,OAAI,CAAC,cAAc,KAAK,QAAQ,CAC9B,QAAO;AAGT,OAAI,CAAC,QAAQ,SAAS,mBAAmB,CACvC,QAAO;AAGT,OAAI,KAAK,SAAS,sBAAsB,CACtC,QAAO;AAMT,UAAO;IACL,MAAM,GAJQ,uCAAuC,KAAK,UAAU,YAAY,CAAC,KAI9D;IACnB,KAAK;IACN;;EAEJ;EACD;AAEF,qBAAe,gBAAgB"}
@@ -0,0 +1,10 @@
1
+ //#region src/vite-plugin-upstart-branding/runtime.d.ts
2
+ /**
3
+ * Initialize the Upstart branding badge.
4
+ * Injects a fixed-position badge at the bottom center of the viewport.
5
+ * The badge slides up and fades in, then dismisses after ~4 seconds or on scroll.
6
+ */
7
+ declare function initUpstartBranding(): void;
8
+ //#endregion
9
+ export { initUpstartBranding };
10
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","names":[],"sources":["../../src/vite-plugin-upstart-branding/runtime.ts"],"sourcesContent":[],"mappings":";;AAmBA;;;;iBAAgB,mBAAA,CAAA"}
@@ -0,0 +1,118 @@
1
+ //#region src/vite-plugin-upstart-branding/runtime.ts
2
+ const UPSTART_ICON_SVG = `<svg width="18" height="18" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <g clip-path="url(#clip0_upstart_branding)">
4
+ <path d="M452 0H60C26.8629 0 0 26.8629 0 60V452C0 485.137 26.8629 512 60 512H452C485.137 512 512 485.137 512 452V60C512 26.8629 485.137 0 452 0Z" fill="#817FCC"/>
5
+ <path d="M346.505 112H410L377.739 307.306C374.122 329.235 365.764 348.423 352.664 364.87C339.564 381.316 322.896 394.141 302.66 403.343C282.424 412.448 259.841 417 234.913 417C209.984 417 188.966 412.448 171.858 403.343C154.75 394.141 142.383 381.316 134.758 364.87C127.133 348.423 125.129 329.235 128.746 307.306L161.006 112H224.501L192.974 301.872C191.214 313.326 192.094 323.508 195.613 332.416C199.23 341.325 205.194 348.325 213.503 353.416C221.813 358.506 232.078 361.052 244.297 361.052C256.615 361.052 267.76 358.506 277.731 353.416C287.801 348.325 296.061 341.325 302.513 332.416C309.063 323.508 313.218 313.326 314.978 301.872L346.505 112Z" fill="white"/>
6
+ <path d="M101 119C101 115.134 104.134 112 108 112H164C167.866 112 171 115.134 171 119V160C171 163.866 167.866 167 164 167H108C104.134 167 101 163.866 101 160V119Z" fill="white"/>
7
+ </g>
8
+ <defs><clipPath id="clip0_upstart_branding"><rect width="512" height="512" fill="white"/></clipPath></defs>
9
+ </svg>`;
10
+ const BADGE_ID = "upstart-branding-badge";
11
+ const DISMISS_DELAY_MS = 4e3;
12
+ let isInitialized = false;
13
+ /**
14
+ * Initialize the Upstart branding badge.
15
+ * Injects a fixed-position badge at the bottom center of the viewport.
16
+ * The badge slides up and fades in, then dismisses after ~4 seconds or on scroll.
17
+ */
18
+ function initUpstartBranding() {
19
+ if (typeof window === "undefined" || typeof document === "undefined") return;
20
+ if (isInitialized) return;
21
+ isInitialized = true;
22
+ if ("scheduler" in globalThis) globalThis.scheduler.postTask(() => injectBranding(), {
23
+ delay: 250,
24
+ priority: "background"
25
+ });
26
+ else setTimeout(() => injectBranding(), 250);
27
+ }
28
+ function injectBranding() {
29
+ const style = document.createElement("style");
30
+ style.textContent = `
31
+ @keyframes upstart-branding-slide-in {
32
+ from {
33
+ opacity: 0;
34
+ transform: translateX(-50%) translateY(20px);
35
+ }
36
+ to {
37
+ opacity: 1;
38
+ transform: translateX(-50%) translateY(0);
39
+ }
40
+ }
41
+
42
+ #${BADGE_ID} {
43
+ position: fixed;
44
+ bottom: 16px;
45
+ left: 50%;
46
+ transform: translateX(-50%);
47
+ z-index: 2147483647;
48
+ display: flex;
49
+ align-items: center;
50
+ gap: 6px;
51
+ padding: 8px 14px;
52
+ background: rgba(30, 30, 30, 0.75);
53
+ backdrop-filter: blur(12px);
54
+ -webkit-backdrop-filter: blur(12px);
55
+ border-radius: 9999px;
56
+ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.1);
57
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
58
+ font-size: 13px;
59
+ font-weight: 500;
60
+ color: rgba(255, 255, 255, 0.9);
61
+ text-decoration: none;
62
+ cursor: pointer;
63
+ pointer-events: auto;
64
+ animation: upstart-branding-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
65
+ transition: opacity 0.4s ease, transform 0.4s ease;
66
+ white-space: nowrap;
67
+ line-height: 1;
68
+ }
69
+
70
+ #${BADGE_ID}:hover {
71
+ background: rgba(30, 30, 30, 0.9);
72
+ color: #fff;
73
+ }
74
+
75
+ #${BADGE_ID}.upstart-branding-hiding {
76
+ opacity: 0;
77
+ transform: translateX(-50%) translateY(12px);
78
+ pointer-events: none;
79
+ }
80
+
81
+ #${BADGE_ID} svg {
82
+ flex-shrink: 0;
83
+ border-radius: 3px;
84
+ }
85
+ `;
86
+ document.head.appendChild(style);
87
+ const badge = document.createElement("a");
88
+ badge.id = BADGE_ID;
89
+ badge.href = "https://upstart.gg";
90
+ badge.target = "_blank";
91
+ badge.rel = "noopener noreferrer";
92
+ badge.innerHTML = `${UPSTART_ICON_SVG}<span>Made with Upstart</span>`;
93
+ document.body.appendChild(badge);
94
+ let dismissed = false;
95
+ function dismiss() {
96
+ if (dismissed) return;
97
+ dismissed = true;
98
+ badge.classList.add("upstart-branding-hiding");
99
+ setTimeout(() => {
100
+ badge.remove();
101
+ style.remove();
102
+ }, 500);
103
+ window.removeEventListener("scroll", onScroll);
104
+ clearTimeout(timer);
105
+ }
106
+ const timer = setTimeout(dismiss, DISMISS_DELAY_MS);
107
+ function onScroll() {
108
+ dismiss();
109
+ }
110
+ window.addEventListener("scroll", onScroll, {
111
+ passive: true,
112
+ once: true
113
+ });
114
+ }
115
+
116
+ //#endregion
117
+ export { initUpstartBranding };
118
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../src/vite-plugin-upstart-branding/runtime.ts"],"sourcesContent":["const UPSTART_ICON_SVG = `<svg width=\"18\" height=\"18\" viewBox=\"0 0 512 512\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<g clip-path=\"url(#clip0_upstart_branding)\">\n<path d=\"M452 0H60C26.8629 0 0 26.8629 0 60V452C0 485.137 26.8629 512 60 512H452C485.137 512 512 485.137 512 452V60C512 26.8629 485.137 0 452 0Z\" fill=\"#817FCC\"/>\n<path d=\"M346.505 112H410L377.739 307.306C374.122 329.235 365.764 348.423 352.664 364.87C339.564 381.316 322.896 394.141 302.66 403.343C282.424 412.448 259.841 417 234.913 417C209.984 417 188.966 412.448 171.858 403.343C154.75 394.141 142.383 381.316 134.758 364.87C127.133 348.423 125.129 329.235 128.746 307.306L161.006 112H224.501L192.974 301.872C191.214 313.326 192.094 323.508 195.613 332.416C199.23 341.325 205.194 348.325 213.503 353.416C221.813 358.506 232.078 361.052 244.297 361.052C256.615 361.052 267.76 358.506 277.731 353.416C287.801 348.325 296.061 341.325 302.513 332.416C309.063 323.508 313.218 313.326 314.978 301.872L346.505 112Z\" fill=\"white\"/>\n<path d=\"M101 119C101 115.134 104.134 112 108 112H164C167.866 112 171 115.134 171 119V160C171 163.866 167.866 167 164 167H108C104.134 167 101 163.866 101 160V119Z\" fill=\"white\"/>\n</g>\n<defs><clipPath id=\"clip0_upstart_branding\"><rect width=\"512\" height=\"512\" fill=\"white\"/></clipPath></defs>\n</svg>`;\n\nconst BADGE_ID = \"upstart-branding-badge\";\nconst DISMISS_DELAY_MS = 4000;\n\nlet isInitialized = false;\n\n/**\n * Initialize the Upstart branding badge.\n * Injects a fixed-position badge at the bottom center of the viewport.\n * The badge slides up and fades in, then dismisses after ~4 seconds or on scroll.\n */\nexport function initUpstartBranding(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return;\n }\n\n if (isInitialized) {\n return;\n }\n\n isInitialized = true;\n\n // Delay initialization to wait for React hydration\n if (\"scheduler\" in globalThis) {\n // @ts-expect-error not yet in TS types\n globalThis.scheduler.postTask(() => injectBranding(), { delay: 250, priority: \"background\" });\n } else {\n setTimeout(() => injectBranding(), 250);\n }\n}\n\nfunction injectBranding(): void {\n const style = document.createElement(\"style\");\n style.textContent = `\n @keyframes upstart-branding-slide-in {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n }\n\n #${BADGE_ID} {\n position: fixed;\n bottom: 16px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 2147483647;\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n background: rgba(30, 30, 30, 0.75);\n backdrop-filter: blur(12px);\n -webkit-backdrop-filter: blur(12px);\n border-radius: 9999px;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.1);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n font-size: 13px;\n font-weight: 500;\n color: rgba(255, 255, 255, 0.9);\n text-decoration: none;\n cursor: pointer;\n pointer-events: auto;\n animation: upstart-branding-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;\n transition: opacity 0.4s ease, transform 0.4s ease;\n white-space: nowrap;\n line-height: 1;\n }\n\n #${BADGE_ID}:hover {\n background: rgba(30, 30, 30, 0.9);\n color: #fff;\n }\n\n #${BADGE_ID}.upstart-branding-hiding {\n opacity: 0;\n transform: translateX(-50%) translateY(12px);\n pointer-events: none;\n }\n\n #${BADGE_ID} svg {\n flex-shrink: 0;\n border-radius: 3px;\n }\n `;\n document.head.appendChild(style);\n\n const badge = document.createElement(\"a\");\n badge.id = BADGE_ID;\n badge.href = \"https://upstart.gg\";\n badge.target = \"_blank\";\n badge.rel = \"noopener noreferrer\";\n badge.innerHTML = `${UPSTART_ICON_SVG}<span>Made with Upstart</span>`;\n\n document.body.appendChild(badge);\n\n let dismissed = false;\n function dismiss() {\n if (dismissed) return;\n dismissed = true;\n badge.classList.add(\"upstart-branding-hiding\");\n setTimeout(() => {\n badge.remove();\n style.remove();\n }, 500);\n window.removeEventListener(\"scroll\", onScroll);\n clearTimeout(timer);\n }\n\n const timer = setTimeout(dismiss, DISMISS_DELAY_MS);\n\n function onScroll() {\n dismiss();\n }\n window.addEventListener(\"scroll\", onScroll, { passive: true, once: true });\n}\n"],"mappings":";AAAA,MAAM,mBAAmB;;;;;;;;AASzB,MAAM,WAAW;AACjB,MAAM,mBAAmB;AAEzB,IAAI,gBAAgB;;;;;;AAOpB,SAAgB,sBAA4B;AAC1C,KAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YACvD;AAGF,KAAI,cACF;AAGF,iBAAgB;AAGhB,KAAI,eAAe,WAEjB,YAAW,UAAU,eAAe,gBAAgB,EAAE;EAAE,OAAO;EAAK,UAAU;EAAc,CAAC;KAE7F,kBAAiB,gBAAgB,EAAE,IAAI;;AAI3C,SAAS,iBAAuB;CAC9B,MAAM,QAAQ,SAAS,cAAc,QAAQ;AAC7C,OAAM,cAAc;;;;;;;;;;;;OAYf,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BT,SAAS;;;;;OAKT,SAAS;;;;;;OAMT,SAAS;;;;;AAKd,UAAS,KAAK,YAAY,MAAM;CAEhC,MAAM,QAAQ,SAAS,cAAc,IAAI;AACzC,OAAM,KAAK;AACX,OAAM,OAAO;AACb,OAAM,SAAS;AACf,OAAM,MAAM;AACZ,OAAM,YAAY,GAAG,iBAAiB;AAEtC,UAAS,KAAK,YAAY,MAAM;CAEhC,IAAI,YAAY;CAChB,SAAS,UAAU;AACjB,MAAI,UAAW;AACf,cAAY;AACZ,QAAM,UAAU,IAAI,0BAA0B;AAC9C,mBAAiB;AACf,SAAM,QAAQ;AACd,SAAM,QAAQ;KACb,IAAI;AACP,SAAO,oBAAoB,UAAU,SAAS;AAC9C,eAAa,MAAM;;CAGrB,MAAM,QAAQ,WAAW,SAAS,iBAAiB;CAEnD,SAAS,WAAW;AAClB,WAAS;;AAEX,QAAO,iBAAiB,UAAU,UAAU;EAAE,SAAS;EAAM,MAAM;EAAM,CAAC"}
@@ -0,0 +1,14 @@
1
+ //#region src/vite-plugin-upstart-branding/types.d.ts
2
+ /**
3
+ * Build-time plugin options for the Upstart branding badge.
4
+ */
5
+ interface UpstartBrandingPluginOptions {
6
+ /**
7
+ * Enable or disable the branding badge.
8
+ * @default false
9
+ */
10
+ enabled?: boolean;
11
+ }
12
+ //#endregion
13
+ export { UpstartBrandingPluginOptions };
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/vite-plugin-upstart-branding/types.ts"],"sourcesContent":[],"mappings":";;AAGA;;UAAiB,4BAAA"}
@@ -0,0 +1 @@
1
+ export { };
@@ -1,5 +1,5 @@
1
1
  import { UpstartEditorPluginOptions } from "./runtime/types.js";
2
- import * as unplugin2 from "unplugin";
2
+ import * as unplugin5 from "unplugin";
3
3
 
4
4
  //#region src/vite-plugin-upstart-editor/plugin.d.ts
5
5
 
@@ -8,8 +8,8 @@ import * as unplugin2 from "unplugin";
8
8
  *
9
9
  * Injects the editor runtime into the app entry during build.
10
10
  */
11
- declare const upstartEditor: unplugin2.UnpluginInstance<UpstartEditorPluginOptions, boolean>;
12
- declare const _default: (options: UpstartEditorPluginOptions) => unplugin2.VitePlugin<any> | unplugin2.VitePlugin<any>[];
11
+ declare const upstartEditor: unplugin5.UnpluginInstance<UpstartEditorPluginOptions, boolean>;
12
+ declare const _default: (options: UpstartEditorPluginOptions) => unplugin5.VitePlugin<any> | unplugin5.VitePlugin<any>[];
13
13
  //#endregion
14
14
  export { _default as default, upstartEditor };
15
15
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../src/vite-plugin-upstart-editor/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAeA;AAuDG;cAvDU,eAAa,SAAA,CAAA,iBAAA;cAuDvB"}
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../src/vite-plugin-upstart-editor/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAeA;AAwCG;cAxCU,eAAa,SAAA,CAAA,iBAAA;cAwCvB"}
@@ -1,5 +1,5 @@
1
- import { createUnplugin } from "unplugin";
2
1
  import path from "node:path";
2
+ import { createUnplugin } from "unplugin";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
5
  //#region src/vite-plugin-upstart-editor/plugin.ts
@@ -26,23 +26,10 @@ const upstartEditor = createUnplugin((options = {}) => {
26
26
  if (!autoInject) return null;
27
27
  const [cleanId] = id.split("?");
28
28
  if (!cleanId || cleanId.includes("node_modules")) return null;
29
- if (!/\.(t|j)sx?$/.test(cleanId)) return null;
30
- const filename = path.basename(cleanId);
31
- if (!filename.startsWith("main.") && !filename.startsWith("index.")) return null;
29
+ if (!cleanId.includes("entry.client.tsx")) return null;
32
30
  if (code.includes("initUpstartEditor")) return null;
33
31
  return {
34
- code: `${[
35
- `import { initUpstartEditor } from ${JSON.stringify(runtimePath)};`,
36
- "",
37
- "if (typeof window !== 'undefined') {",
38
- " if (document.readyState === 'loading') {",
39
- " document.addEventListener('DOMContentLoaded', () => initUpstartEditor());",
40
- " } else {",
41
- " initUpstartEditor();",
42
- " }",
43
- "}",
44
- ""
45
- ].join("\n")}${code}`,
32
+ code: `${`import { initUpstartEditor } from ${JSON.stringify(runtimePath)};`}${code}requestIdleCallback(initUpstartEditor);`,
46
33
  map: null
47
34
  };
48
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":["DEFAULT_OPTIONS: Required<UpstartEditorPluginOptions>"],"sources":["../../src/vite-plugin-upstart-editor/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createUnplugin } from \"unplugin\";\nimport type { UpstartEditorPluginOptions } from \"./runtime/types.js\";\n\nconst DEFAULT_OPTIONS: Required<UpstartEditorPluginOptions> = {\n enabled: false,\n autoInject: true,\n};\n\n/**\n * Upstart Visual Editor Vite plugin (build-time)\n *\n * Injects the editor runtime into the app entry during build.\n */\nexport const upstartEditor = createUnplugin<UpstartEditorPluginOptions>((options = {}) => {\n const { enabled, autoInject } = { ...DEFAULT_OPTIONS, ...options };\n\n if (!enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const runtimePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"./runtime/index\");\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n transform(code, id) {\n if (!autoInject) {\n return null;\n }\n\n const [cleanId] = id.split(\"?\");\n if (!cleanId || cleanId.includes(\"node_modules\")) {\n return null;\n }\n\n if (!/\\.(t|j)sx?$/.test(cleanId)) {\n return null;\n }\n\n const filename = path.basename(cleanId);\n if (!filename.startsWith(\"main.\") && !filename.startsWith(\"index.\")) {\n return null;\n }\n\n if (code.includes(\"initUpstartEditor\")) {\n return null;\n }\n\n const injection = [\n `import { initUpstartEditor } from ${JSON.stringify(runtimePath)};`,\n \"\",\n \"if (typeof window !== 'undefined') {\",\n \" if (document.readyState === 'loading') {\",\n \" document.addEventListener('DOMContentLoaded', () => initUpstartEditor());\",\n \" } else {\",\n \" initUpstartEditor();\",\n \" }\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code: `${injection}${code}`,\n map: null,\n };\n },\n };\n});\n\nexport default upstartEditor.vite;\n"],"mappings":";;;;;AAKA,MAAMA,kBAAwD;CAC5D,SAAS;CACT,YAAY;CACb;;;;;;AAOD,MAAa,gBAAgB,gBAA4C,UAAU,EAAE,KAAK;CACxF,MAAM,EAAE,SAAS,eAAe;EAAE,GAAG;EAAiB,GAAG;EAAS;AAElE,KAAI,CAAC,QACH,QAAO,EAAE,MAAM,2BAA2B;CAG5C,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,kBAAkB;AAEjG,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAU,MAAM,IAAI;AAClB,OAAI,CAAC,WACH,QAAO;GAGT,MAAM,CAAC,WAAW,GAAG,MAAM,IAAI;AAC/B,OAAI,CAAC,WAAW,QAAQ,SAAS,eAAe,CAC9C,QAAO;AAGT,OAAI,CAAC,cAAc,KAAK,QAAQ,CAC9B,QAAO;GAGT,MAAM,WAAW,KAAK,SAAS,QAAQ;AACvC,OAAI,CAAC,SAAS,WAAW,QAAQ,IAAI,CAAC,SAAS,WAAW,SAAS,CACjE,QAAO;AAGT,OAAI,KAAK,SAAS,oBAAoB,CACpC,QAAO;AAgBT,UAAO;IACL,MAAM,GAdU;KAChB,qCAAqC,KAAK,UAAU,YAAY,CAAC;KACjE;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,CAAC,KAAK,KAAK,GAGW;IACrB,KAAK;IACN;;EAEJ;EACD;AAEF,qBAAe,cAAc"}
1
+ {"version":3,"file":"plugin.js","names":["DEFAULT_OPTIONS: Required<UpstartEditorPluginOptions>"],"sources":["../../src/vite-plugin-upstart-editor/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createUnplugin } from \"unplugin\";\nimport type { UpstartEditorPluginOptions } from \"./runtime/types.js\";\n\nconst DEFAULT_OPTIONS: Required<UpstartEditorPluginOptions> = {\n enabled: false,\n autoInject: true,\n};\n\n/**\n * Upstart Visual Editor Vite plugin (build-time)\n *\n * Injects the editor runtime into the app entry during build.\n */\nexport const upstartEditor = createUnplugin<UpstartEditorPluginOptions>((options = {}) => {\n const { enabled, autoInject } = { ...DEFAULT_OPTIONS, ...options };\n\n if (!enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const runtimePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"./runtime/index\");\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n transform(code, id) {\n if (!autoInject) {\n return null;\n }\n\n const [cleanId] = id.split(\"?\");\n if (!cleanId || cleanId.includes(\"node_modules\")) {\n return null;\n }\n\n if (!cleanId.includes(\"entry.client.tsx\")) {\n return null;\n }\n\n if (code.includes(\"initUpstartEditor\")) {\n return null;\n }\n\n const imports = `import { initUpstartEditor } from ${JSON.stringify(runtimePath)};`;\n const injection = \"requestIdleCallback(initUpstartEditor);\";\n\n return {\n code: `${imports}${code}${injection}`,\n map: null,\n };\n },\n };\n});\n\nexport default upstartEditor.vite;\n"],"mappings":";;;;;AAKA,MAAMA,kBAAwD;CAC5D,SAAS;CACT,YAAY;CACb;;;;;;AAOD,MAAa,gBAAgB,gBAA4C,UAAU,EAAE,KAAK;CACxF,MAAM,EAAE,SAAS,eAAe;EAAE,GAAG;EAAiB,GAAG;EAAS;AAElE,KAAI,CAAC,QACH,QAAO,EAAE,MAAM,2BAA2B;CAG5C,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,kBAAkB;AAEjG,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAU,MAAM,IAAI;AAClB,OAAI,CAAC,WACH,QAAO;GAGT,MAAM,CAAC,WAAW,GAAG,MAAM,IAAI;AAC/B,OAAI,CAAC,WAAW,QAAQ,SAAS,eAAe,CAC9C,QAAO;AAGT,OAAI,CAAC,QAAQ,SAAS,mBAAmB,CACvC,QAAO;AAGT,OAAI,KAAK,SAAS,oBAAoB,CACpC,QAAO;AAMT,UAAO;IACL,MAAM,GAJQ,qCAAqC,KAAK,UAAU,YAAY,CAAC,KAI5D;IACnB,KAAK;IACN;;EAEJ;EACD;AAEF,qBAAe,cAAc"}
@@ -22,24 +22,38 @@ function cleanupClickHandler() {
22
22
  }
23
23
  function handleClick(event) {
24
24
  if (getCurrentMode() !== "edit") return;
25
+ console.debug("[Upstart Editor] Click event:", event);
25
26
  const target = event.target;
26
- if (!target) return;
27
- if (target.closest("[contenteditable='true']")) return;
28
- const component = target.closest("[data-upstart-component]");
29
- if (!component) return;
30
- event.preventDefault();
27
+ if (!target) {
28
+ console.warn("[Upstart Editor] Click target is not an HTMLElement");
29
+ return;
30
+ }
31
+ const activeLink = target.closest("a[data-upstart-editor-active]");
32
+ const isFormControlClick = Boolean(target?.closest("input, textarea, select, button"));
33
+ if (activeLink || !isFormControlClick) event.preventDefault();
34
+ if (target.closest("[contenteditable='true']")) {
35
+ console.info("[Upstart Editor] Click ignored: target is inside a contenteditable element");
36
+ return;
37
+ }
38
+ const element = target.closest("[data-upstart-hash]");
39
+ if (!element) {
40
+ console.info("[Upstart Editor] Click ignored: no ancestral element with data-upstart-hash found");
41
+ return;
42
+ }
31
43
  event.stopPropagation();
32
- const hash = component.dataset.upstartHash;
33
- const componentName = component.dataset.upstartComponent;
34
- const filePath = component.dataset.upstartFile ?? "";
35
- if (!hash || !componentName) return;
36
- const rect = component.getBoundingClientRect();
44
+ console.log("Element clicked dataset:", element.dataset);
45
+ const hash = element.dataset.upstartHash;
46
+ const componentName = element.dataset.upstartComponent;
47
+ const filePath = element.dataset.upstartFile ?? "";
48
+ const classNameId = element.dataset.upstartClassnameId ?? "";
49
+ const rect = element.getBoundingClientRect();
37
50
  sendToParent({
38
51
  type: "element-clicked",
39
52
  hash,
40
53
  componentName,
41
54
  filePath,
42
- currentClassName: component.className,
55
+ classNameId,
56
+ currentClassName: element.className,
43
57
  bounds: {
44
58
  top: rect.top,
45
59
  left: rect.left,
@@ -1 +1 @@
1
- {"version":3,"file":"click-handler.js","names":[],"sources":["../../../src/vite-plugin-upstart-editor/runtime/click-handler.ts"],"sourcesContent":["import { getCurrentMode } from \"./index.js\";\nimport { sendToParent } from \"./utils.js\";\n\nlet isInitialized = false;\n\n/**\n * Initialize click handler for className editing.\n */\nexport function initClickHandler(): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n if (isInitialized) {\n return;\n }\n\n console.log(\"[Upstart Editor] Initializing click handler...\");\n document.addEventListener(\"click\", handleClick, true);\n isInitialized = true;\n}\n\n/**\n * Cleanup click handler.\n */\nexport function cleanupClickHandler(): void {\n document.removeEventListener(\"click\", handleClick, true);\n isInitialized = false;\n}\n\nfunction handleClick(event: MouseEvent): void {\n if (getCurrentMode() !== \"edit\") {\n return;\n }\n\n const target = event.target as HTMLElement | null;\n if (!target) {\n return;\n }\n\n if (target.closest(\"[contenteditable='true']\")) {\n return;\n }\n\n const component = target.closest<HTMLElement>(\"[data-upstart-component]\");\n if (!component) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n const hash = component.dataset.upstartHash;\n const componentName = component.dataset.upstartComponent;\n const filePath = component.dataset.upstartFile ?? \"\";\n\n if (!hash || !componentName) {\n return;\n }\n\n const rect = component.getBoundingClientRect();\n\n sendToParent({\n type: \"element-clicked\",\n hash,\n componentName,\n filePath,\n currentClassName: component.className,\n bounds: {\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height,\n right: rect.right,\n bottom: rect.bottom,\n },\n });\n\n console.log(\"[Upstart Editor] Element clicked:\", componentName, hash);\n}\n"],"mappings":";;;;AAGA,IAAI,gBAAgB;;;;AAKpB,SAAgB,mBAAyB;AACvC,KAAI,OAAO,aAAa,YACtB;AAGF,KAAI,cACF;AAGF,SAAQ,IAAI,iDAAiD;AAC7D,UAAS,iBAAiB,SAAS,aAAa,KAAK;AACrD,iBAAgB;;;;;AAMlB,SAAgB,sBAA4B;AAC1C,UAAS,oBAAoB,SAAS,aAAa,KAAK;AACxD,iBAAgB;;AAGlB,SAAS,YAAY,OAAyB;AAC5C,KAAI,gBAAgB,KAAK,OACvB;CAGF,MAAM,SAAS,MAAM;AACrB,KAAI,CAAC,OACH;AAGF,KAAI,OAAO,QAAQ,2BAA2B,CAC5C;CAGF,MAAM,YAAY,OAAO,QAAqB,2BAA2B;AACzE,KAAI,CAAC,UACH;AAGF,OAAM,gBAAgB;AACtB,OAAM,iBAAiB;CAEvB,MAAM,OAAO,UAAU,QAAQ;CAC/B,MAAM,gBAAgB,UAAU,QAAQ;CACxC,MAAM,WAAW,UAAU,QAAQ,eAAe;AAElD,KAAI,CAAC,QAAQ,CAAC,cACZ;CAGF,MAAM,OAAO,UAAU,uBAAuB;AAE9C,cAAa;EACX,MAAM;EACN;EACA;EACA;EACA,kBAAkB,UAAU;EAC5B,QAAQ;GACN,KAAK,KAAK;GACV,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,OAAO,KAAK;GACZ,QAAQ,KAAK;GACd;EACF,CAAC;AAEF,SAAQ,IAAI,qCAAqC,eAAe,KAAK"}
1
+ {"version":3,"file":"click-handler.js","names":[],"sources":["../../../src/vite-plugin-upstart-editor/runtime/click-handler.ts"],"sourcesContent":["import { getCurrentMode } from \"./index.js\";\nimport { sendToParent } from \"./utils.js\";\n\nlet isInitialized = false;\n\n/**\n * Initialize click handler for className editing.\n */\nexport function initClickHandler(): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n if (isInitialized) {\n return;\n }\n\n console.log(\"[Upstart Editor] Initializing click handler...\");\n document.addEventListener(\"click\", handleClick, true);\n isInitialized = true;\n}\n\n/**\n * Cleanup click handler.\n */\nexport function cleanupClickHandler(): void {\n document.removeEventListener(\"click\", handleClick, true);\n isInitialized = false;\n}\n\nfunction handleClick(event: MouseEvent): void {\n if (getCurrentMode() !== \"edit\") {\n return;\n }\n\n console.debug(\"[Upstart Editor] Click event:\", event);\n\n const target = event.target as HTMLElement | null;\n if (!target) {\n console.warn(\"[Upstart Editor] Click target is not an HTMLElement\");\n return;\n }\n\n const activeLink = target.closest(\"a[data-upstart-editor-active]\");\n const isFormControlClick = Boolean(\n (target as HTMLElement | null)?.closest(\"input, textarea, select, button\"),\n );\n if (activeLink || !isFormControlClick) {\n event.preventDefault();\n }\n\n if (target.closest(\"[contenteditable='true']\")) {\n console.info(\"[Upstart Editor] Click ignored: target is inside a contenteditable element\");\n return;\n }\n\n const element = target.closest<HTMLElement>(\"[data-upstart-hash]\");\n // const i18nKey = target.closest<HTMLElement>(\"[data-upstart-i18n]\");\n\n if (!element) {\n console.info(\"[Upstart Editor] Click ignored: no ancestral element with data-upstart-hash found\");\n return;\n }\n\n event.stopPropagation();\n\n console.log(\"Element clicked dataset:\", element.dataset);\n\n const hash = element.dataset.upstartHash as string;\n const componentName = element.dataset.upstartComponent;\n const filePath = element.dataset.upstartFile ?? \"\";\n const classNameId = element.dataset.upstartClassnameId ?? \"\";\n const rect = element.getBoundingClientRect();\n\n sendToParent({\n type: \"element-clicked\",\n hash,\n componentName,\n filePath,\n classNameId,\n currentClassName: element.className,\n bounds: {\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height,\n right: rect.right,\n bottom: rect.bottom,\n },\n });\n\n console.log(\"[Upstart Editor] Element clicked:\", componentName, hash);\n}\n"],"mappings":";;;;AAGA,IAAI,gBAAgB;;;;AAKpB,SAAgB,mBAAyB;AACvC,KAAI,OAAO,aAAa,YACtB;AAGF,KAAI,cACF;AAGF,SAAQ,IAAI,iDAAiD;AAC7D,UAAS,iBAAiB,SAAS,aAAa,KAAK;AACrD,iBAAgB;;;;;AAMlB,SAAgB,sBAA4B;AAC1C,UAAS,oBAAoB,SAAS,aAAa,KAAK;AACxD,iBAAgB;;AAGlB,SAAS,YAAY,OAAyB;AAC5C,KAAI,gBAAgB,KAAK,OACvB;AAGF,SAAQ,MAAM,iCAAiC,MAAM;CAErD,MAAM,SAAS,MAAM;AACrB,KAAI,CAAC,QAAQ;AACX,UAAQ,KAAK,sDAAsD;AACnE;;CAGF,MAAM,aAAa,OAAO,QAAQ,gCAAgC;CAClE,MAAM,qBAAqB,QACxB,QAA+B,QAAQ,kCAAkC,CAC3E;AACD,KAAI,cAAc,CAAC,mBACjB,OAAM,gBAAgB;AAGxB,KAAI,OAAO,QAAQ,2BAA2B,EAAE;AAC9C,UAAQ,KAAK,6EAA6E;AAC1F;;CAGF,MAAM,UAAU,OAAO,QAAqB,sBAAsB;AAGlE,KAAI,CAAC,SAAS;AACZ,UAAQ,KAAK,oFAAoF;AACjG;;AAGF,OAAM,iBAAiB;AAEvB,SAAQ,IAAI,4BAA4B,QAAQ,QAAQ;CAExD,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,gBAAgB,QAAQ,QAAQ;CACtC,MAAM,WAAW,QAAQ,QAAQ,eAAe;CAChD,MAAM,cAAc,QAAQ,QAAQ,sBAAsB;CAC1D,MAAM,OAAO,QAAQ,uBAAuB;AAE5C,cAAa;EACX,MAAM;EACN;EACA;EACA;EACA;EACA,kBAAkB,QAAQ;EAC1B,QAAQ;GACN,KAAK,KAAK;GACV,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,OAAO,KAAK;GACZ,QAAQ,KAAK;GACd;EACF,CAAC;AAEF,SAAQ,IAAI,qCAAqC,eAAe,KAAK"}
@@ -0,0 +1,5 @@
1
+ //#region src/vite-plugin-upstart-editor/runtime/error-handler.d.ts
2
+ declare function initErrorHandler(): void;
3
+ //#endregion
4
+ export { initErrorHandler };
5
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","names":[],"sources":["../../../src/vite-plugin-upstart-editor/runtime/error-handler.ts"],"sourcesContent":[],"mappings":";iBAEgB,gBAAA,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { sendToParent } from "./utils.js";
2
+
3
+ //#region src/vite-plugin-upstart-editor/runtime/error-handler.ts
4
+ function initErrorHandler() {
5
+ window.addEventListener("error", (event) => {
6
+ console.error("[Upstart Editor] Uncaught error in editor:", event.error);
7
+ sendToParent({
8
+ type: "editor-error",
9
+ error: event.error
10
+ });
11
+ });
12
+ }
13
+
14
+ //#endregion
15
+ export { initErrorHandler };
16
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","names":[],"sources":["../../../src/vite-plugin-upstart-editor/runtime/error-handler.ts"],"sourcesContent":["import { sendToParent } from \"./utils.js\";\n\nexport function initErrorHandler() {\n // Global error handler for uncaught errors in the editor\n window.addEventListener(\"error\", (event) => {\n console.error(\"[Upstart Editor] Uncaught error in editor:\", event.error);\n sendToParent({\n type: \"editor-error\",\n error: event.error,\n });\n });\n}\n"],"mappings":";;;AAEA,SAAgB,mBAAmB;AAEjC,QAAO,iBAAiB,UAAU,UAAU;AAC1C,UAAQ,MAAM,8CAA8C,MAAM,MAAM;AACxE,eAAa;GACX,MAAM;GACN,OAAO,MAAM;GACd,CAAC;GACF"}