@trojanbox-vcp-test/site-edit-engine 0.1.0

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 (174) hide show
  1. package/README.md +85 -0
  2. package/dist/execute-integration/execute-fixture-harness.d.ts +25 -0
  3. package/dist/execute-integration/execute-fixture-harness.js +37 -0
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.js +2 -0
  6. package/dist/internal/ast/diagnostics/index.d.ts +5 -0
  7. package/dist/internal/ast/diagnostics/index.js +25 -0
  8. package/dist/internal/ast/history/index.d.ts +15 -0
  9. package/dist/internal/ast/history/index.js +62 -0
  10. package/dist/internal/ast/index.d.ts +8 -0
  11. package/dist/internal/ast/index.js +5 -0
  12. package/dist/internal/ast/locators/index.d.ts +1 -0
  13. package/dist/internal/ast/locators/index.js +1 -0
  14. package/dist/internal/ast/locators/resolve-locator.d.ts +16 -0
  15. package/dist/internal/ast/locators/resolve-locator.js +920 -0
  16. package/dist/internal/ast/parser/SourceParser.d.ts +30 -0
  17. package/dist/internal/ast/parser/SourceParser.js +49 -0
  18. package/dist/internal/ast/parser/index.d.ts +21 -0
  19. package/dist/internal/ast/parser/index.js +64 -0
  20. package/dist/internal/ast/primitives/conditional/conditional-primitives.d.ts +18 -0
  21. package/dist/internal/ast/primitives/conditional/conditional-primitives.js +237 -0
  22. package/dist/internal/ast/primitives/conditional/index.d.ts +1 -0
  23. package/dist/internal/ast/primitives/conditional/index.js +1 -0
  24. package/dist/internal/ast/primitives/imports/add-import.d.ts +18 -0
  25. package/dist/internal/ast/primitives/imports/add-import.js +111 -0
  26. package/dist/internal/ast/primitives/imports/index.d.ts +2 -0
  27. package/dist/internal/ast/primitives/imports/index.js +2 -0
  28. package/dist/internal/ast/primitives/imports/remove-import.d.ts +15 -0
  29. package/dist/internal/ast/primitives/imports/remove-import.js +72 -0
  30. package/dist/internal/ast/primitives/index.d.ts +10 -0
  31. package/dist/internal/ast/primitives/index.js +10 -0
  32. package/dist/internal/ast/primitives/jsx/index.d.ts +4 -0
  33. package/dist/internal/ast/primitives/jsx/index.js +4 -0
  34. package/dist/internal/ast/primitives/jsx/insert-child.d.ts +11 -0
  35. package/dist/internal/ast/primitives/jsx/insert-child.js +69 -0
  36. package/dist/internal/ast/primitives/jsx/move-node.d.ts +9 -0
  37. package/dist/internal/ast/primitives/jsx/move-node.js +76 -0
  38. package/dist/internal/ast/primitives/jsx/remove-node.d.ts +7 -0
  39. package/dist/internal/ast/primitives/jsx/remove-node.js +36 -0
  40. package/dist/internal/ast/primitives/jsx/update-text.d.ts +8 -0
  41. package/dist/internal/ast/primitives/jsx/update-text.js +81 -0
  42. package/dist/internal/ast/primitives/next/index.d.ts +1 -0
  43. package/dist/internal/ast/primitives/next/index.js +1 -0
  44. package/dist/internal/ast/primitives/next/next-primitives.d.ts +43 -0
  45. package/dist/internal/ast/primitives/next/next-primitives.js +211 -0
  46. package/dist/internal/ast/primitives/shared.d.ts +60 -0
  47. package/dist/internal/ast/primitives/shared.js +176 -0
  48. package/dist/internal/ast/primitives/style/class-expression.d.ts +23 -0
  49. package/dist/internal/ast/primitives/style/class-expression.js +174 -0
  50. package/dist/internal/ast/primitives/style/index.d.ts +1 -0
  51. package/dist/internal/ast/primitives/style/index.js +1 -0
  52. package/dist/internal/ast/primitives/style/style-primitives.d.ts +49 -0
  53. package/dist/internal/ast/primitives/style/style-primitives.js +555 -0
  54. package/dist/internal/ast/primitives/values/index.d.ts +1 -0
  55. package/dist/internal/ast/primitives/values/index.js +1 -0
  56. package/dist/internal/ast/primitives/values/value-primitives.d.ts +42 -0
  57. package/dist/internal/ast/primitives/values/value-primitives.js +158 -0
  58. package/dist/internal/ast/printer/SourcePrinter.d.ts +21 -0
  59. package/dist/internal/ast/printer/SourcePrinter.js +76 -0
  60. package/dist/internal/ast/printer/index.d.ts +6 -0
  61. package/dist/internal/ast/printer/index.js +126 -0
  62. package/dist/internal/ast/types.d.ts +190 -0
  63. package/dist/internal/ast/types.js +1 -0
  64. package/dist/internal/capability/capability-resolver.d.ts +16 -0
  65. package/dist/internal/capability/capability-resolver.js +127 -0
  66. package/dist/internal/classname-source.d.ts +24 -0
  67. package/dist/internal/classname-source.js +220 -0
  68. package/dist/internal/contracts/IEditEngineRuntime.d.ts +18 -0
  69. package/dist/internal/contracts/IEditEngineRuntime.js +1 -0
  70. package/dist/internal/domain/EditDiagnostic.d.ts +38 -0
  71. package/dist/internal/domain/EditDiagnostic.js +43 -0
  72. package/dist/internal/events/event-bus.d.ts +14 -0
  73. package/dist/internal/events/event-bus.js +21 -0
  74. package/dist/internal/graph/graph-builder.d.ts +12 -0
  75. package/dist/internal/graph/graph-builder.js +1371 -0
  76. package/dist/internal/graph/import-resolver.d.ts +31 -0
  77. package/dist/internal/graph/import-resolver.js +109 -0
  78. package/dist/internal/graph/project-graph-builder.d.ts +32 -0
  79. package/dist/internal/graph/project-graph-builder.js +133 -0
  80. package/dist/internal/graph/types.d.ts +114 -0
  81. package/dist/internal/graph/types.js +6 -0
  82. package/dist/internal/history/undo-redo.d.ts +28 -0
  83. package/dist/internal/history/undo-redo.js +42 -0
  84. package/dist/internal/index.d.ts +2 -0
  85. package/dist/internal/index.js +1 -0
  86. package/dist/internal/planner/planner.d.ts +104 -0
  87. package/dist/internal/planner/planner.js +2533 -0
  88. package/dist/internal/planner/types.d.ts +275 -0
  89. package/dist/internal/planner/types.js +6 -0
  90. package/dist/internal/protocol/boundary.d.ts +10 -0
  91. package/dist/internal/protocol/boundary.js +3 -0
  92. package/dist/internal/protocol/capability.d.ts +47 -0
  93. package/dist/internal/protocol/capability.js +8 -0
  94. package/dist/internal/protocol/error.d.ts +43 -0
  95. package/dist/internal/protocol/error.js +38 -0
  96. package/dist/internal/protocol/event.d.ts +39 -0
  97. package/dist/internal/protocol/event.js +3 -0
  98. package/dist/internal/protocol/identity.d.ts +26 -0
  99. package/dist/internal/protocol/identity.js +30 -0
  100. package/dist/internal/protocol/operation.d.ts +224 -0
  101. package/dist/internal/protocol/operation.js +8 -0
  102. package/dist/internal/protocol/render.d.ts +212 -0
  103. package/dist/internal/protocol/render.js +3 -0
  104. package/dist/internal/protocol.d.ts +9 -0
  105. package/dist/internal/protocol.js +2 -0
  106. package/dist/internal/provenance/binding-graph.d.ts +39 -0
  107. package/dist/internal/provenance/binding-graph.js +184 -0
  108. package/dist/internal/provenance/capability-policy.d.ts +15 -0
  109. package/dist/internal/provenance/capability-policy.js +96 -0
  110. package/dist/internal/provenance/data-source-classifier.d.ts +14 -0
  111. package/dist/internal/provenance/data-source-classifier.js +281 -0
  112. package/dist/internal/provenance/resolve-text-provenance.d.ts +45 -0
  113. package/dist/internal/provenance/resolve-text-provenance.js +3090 -0
  114. package/dist/internal/provenance/types.d.ts +89 -0
  115. package/dist/internal/provenance/types.js +1 -0
  116. package/dist/internal/render/component-semantic.d.ts +11 -0
  117. package/dist/internal/render/component-semantic.js +141 -0
  118. package/dist/internal/render/content-model.d.ts +3 -0
  119. package/dist/internal/render/content-model.js +89 -0
  120. package/dist/internal/render/media-model.d.ts +3 -0
  121. package/dist/internal/render/media-model.js +45 -0
  122. package/dist/internal/render/provenance-types.d.ts +33 -0
  123. package/dist/internal/render/provenance-types.js +1 -0
  124. package/dist/internal/render/render-projection.d.ts +24 -0
  125. package/dist/internal/render/render-projection.js +281 -0
  126. package/dist/internal/render/tailwind-style-model.d.ts +19 -0
  127. package/dist/internal/render/tailwind-style-model.js +1187 -0
  128. package/dist/internal/runtime/EditEngineRuntime.d.ts +25 -0
  129. package/dist/internal/runtime/EditEngineRuntime.js +89 -0
  130. package/dist/internal/runtime/EditEngineRuntimeSnapshot.d.ts +31 -0
  131. package/dist/internal/runtime/EditEngineRuntimeSnapshot.js +15 -0
  132. package/dist/internal/runtime/InternalEditEngine.d.ts +44 -0
  133. package/dist/internal/runtime/InternalEditEngine.js +1391 -0
  134. package/dist/internal/runtime.d.ts +3 -0
  135. package/dist/internal/runtime.js +1 -0
  136. package/dist/internal/topology/topology.d.ts +6 -0
  137. package/dist/internal/topology/topology.js +98 -0
  138. package/dist/internal/topology/types.d.ts +35 -0
  139. package/dist/internal/topology/types.js +5 -0
  140. package/dist/internal/types.d.ts +1 -0
  141. package/dist/internal/types.js +1 -0
  142. package/dist/internal/writeback/in-memory-fs.d.ts +7 -0
  143. package/dist/internal/writeback/in-memory-fs.js +44 -0
  144. package/dist/internal/writeback/types.d.ts +45 -0
  145. package/dist/internal/writeback/types.js +7 -0
  146. package/dist/internal/writeback/writeback-service.d.ts +7 -0
  147. package/dist/internal/writeback/writeback-service.js +568 -0
  148. package/dist/internal-adapter.d.ts +18 -0
  149. package/dist/internal-adapter.js +350 -0
  150. package/dist/next-app-router-fs.d.ts +2 -0
  151. package/dist/next-app-router-fs.js +64 -0
  152. package/dist/next-app-router.d.ts +11 -0
  153. package/dist/next-app-router.js +140 -0
  154. package/dist/preview-runtime.d.ts +394 -0
  155. package/dist/preview-runtime.js +102 -0
  156. package/dist/public-file-system.d.ts +7 -0
  157. package/dist/public-file-system.js +1 -0
  158. package/dist/runtime-sync.d.ts +95 -0
  159. package/dist/runtime-sync.js +321 -0
  160. package/dist/runtime.d.ts +340 -0
  161. package/dist/runtime.js +134 -0
  162. package/dist/site-edit-instrumentation.d.ts +19 -0
  163. package/dist/site-edit-instrumentation.js +322 -0
  164. package/dist/snapshot-file-system.d.ts +19 -0
  165. package/dist/snapshot-file-system.js +49 -0
  166. package/dist/source-watcher.d.ts +20 -0
  167. package/dist/source-watcher.js +150 -0
  168. package/dist/source-writeback-test-harness.d.ts +244 -0
  169. package/dist/source-writeback-test-harness.js +119 -0
  170. package/dist/types.d.ts +68 -0
  171. package/dist/types.js +1 -0
  172. package/dist/webpack-loader.cjs +592 -0
  173. package/dist/webpack-loader.d.ts +27 -0
  174. package/package.json +66 -0
@@ -0,0 +1,176 @@
1
+ import * as parser from "@babel/parser";
2
+ import { arrayExpression, booleanLiteral, identifier, jsxAttribute, jsxExpressionContainer, jsxIdentifier, nullLiteral, numericLiteral, objectExpression, objectProperty, stringLiteral, } from "@babel/types";
3
+ import { primitiveFailure } from "../diagnostics/index.js";
4
+ import { parseForMutation } from "../parser/index.js";
5
+ import { printAst } from "../printer/index.js";
6
+ import { resolveLocatorPath, } from "../locators/index.js";
7
+ // ---- Operation Builder ----
8
+ function computeSourceHash(source) {
9
+ let hash = 0;
10
+ for (let i = 0; i < source.length; i++) {
11
+ const char = source.charCodeAt(i);
12
+ hash = (hash << 5) - hash + char;
13
+ hash |= 0;
14
+ }
15
+ return `0x${Math.abs(hash).toString(16)}`;
16
+ }
17
+ export function buildOperationDescription(beforeSource, afterSource, params) {
18
+ return {
19
+ ok: true,
20
+ source: afterSource,
21
+ operation: {
22
+ type: params.kind,
23
+ nodeId: params.target,
24
+ kind: params.kind,
25
+ target: params.target,
26
+ beforeSourceHash: computeSourceHash(beforeSource),
27
+ afterSourceHash: computeSourceHash(afterSource),
28
+ inverse: params.inverse,
29
+ },
30
+ };
31
+ }
32
+ export function printMutationWithOperation(ast, beforeSource, params) {
33
+ const printResult = printAst({ ast, source: beforeSource });
34
+ if (!printResult.ok) {
35
+ return printResult;
36
+ }
37
+ return buildOperationDescription(beforeSource, printResult.source, params);
38
+ }
39
+ export function parseMutationSource(source, locatorKind) {
40
+ const parsed = parseForMutation(source, locatorKind);
41
+ if (!parsed.ok) {
42
+ return {
43
+ ok: false,
44
+ result: {
45
+ ok: false,
46
+ source,
47
+ diagnostic: parsed.diagnostic,
48
+ },
49
+ };
50
+ }
51
+ return {
52
+ ok: true,
53
+ ast: parsed.ast,
54
+ };
55
+ }
56
+ export function printMutation(ast, source) {
57
+ return printAst({ ast, source });
58
+ }
59
+ export function resolveRequiredJsxNode(ast, locator, source) {
60
+ const result = resolveLocatorPath(ast, locator);
61
+ if (!result.ok) {
62
+ return {
63
+ ok: false,
64
+ result: {
65
+ ok: false,
66
+ source,
67
+ diagnostic: result.diagnostic,
68
+ },
69
+ };
70
+ }
71
+ return { ok: true, match: result.match };
72
+ }
73
+ export function resolveRequiredJsxElement(ast, locator, source) {
74
+ const result = resolveRequiredJsxNode(ast, locator, source);
75
+ if (!result.ok) {
76
+ return result;
77
+ }
78
+ if (!result.match.path.isJSXElement()) {
79
+ return {
80
+ ok: false,
81
+ result: primitiveFailure(source, "unsupported-syntax", "JSX locator must resolve to JSXElement", "jsx-node"),
82
+ };
83
+ }
84
+ return result;
85
+ }
86
+ export function resolveRequiredJsxAttribute(ast, locator, source) {
87
+ const result = resolveLocatorPath(ast, locator);
88
+ if (!result.ok) {
89
+ return {
90
+ ok: false,
91
+ result: {
92
+ ok: false,
93
+ source,
94
+ diagnostic: result.diagnostic,
95
+ },
96
+ };
97
+ }
98
+ if (!result.match.path.isJSXAttribute()) {
99
+ return {
100
+ ok: false,
101
+ result: primitiveFailure(source, "unsupported-syntax", "JSX locator must resolve to JSXAttribute", "jsx-attribute"),
102
+ };
103
+ }
104
+ return { ok: true, match: result.match };
105
+ }
106
+ export function resolveOptionalJsxAttribute(ast, locator) {
107
+ const result = resolveLocatorPath(ast, locator);
108
+ if (result.ok) {
109
+ return { ok: true, match: result.match };
110
+ }
111
+ if (result.diagnostic.code === "locator-miss") {
112
+ return { ok: true, match: null };
113
+ }
114
+ return { ok: false, diagnostic: result.diagnostic };
115
+ }
116
+ export function valueToExpression(value) {
117
+ if (typeof value === "string") {
118
+ return stringLiteral(value);
119
+ }
120
+ if (typeof value === "number") {
121
+ return numericLiteral(value);
122
+ }
123
+ if (typeof value === "boolean") {
124
+ return booleanLiteral(value);
125
+ }
126
+ if (value === null) {
127
+ return nullLiteral();
128
+ }
129
+ if (Array.isArray(value)) {
130
+ return arrayExpression(value.map((item) => valueToExpression(item)));
131
+ }
132
+ return objectExpression(Object.entries(value).map(([key, item]) => objectProperty(identifier(key), valueToExpression(item))));
133
+ }
134
+ export function valueToJsxAttributeValue(value) {
135
+ if (typeof value === "string") {
136
+ return stringLiteral(value);
137
+ }
138
+ return jsxExpressionContainer(valueToExpression(value));
139
+ }
140
+ export function createJsxAttribute(name, value) {
141
+ return jsxAttribute(jsxIdentifier(name), valueToJsxAttributeValue(value));
142
+ }
143
+ export function parseJsxNodeSource(source, jsx) {
144
+ try {
145
+ const ast = parser.parse(`const __VD_NODE__ = (${jsx});`, {
146
+ sourceType: "module",
147
+ plugins: ["jsx", "typescript"],
148
+ });
149
+ const declaration = ast.program.body[0];
150
+ if (declaration?.type !== "VariableDeclaration" ||
151
+ declaration.declarations[0]?.type !== "VariableDeclarator" ||
152
+ !declaration.declarations[0].init ||
153
+ (declaration.declarations[0].init.type !== "JSXElement" &&
154
+ declaration.declarations[0].init.type !== "JSXFragment")) {
155
+ return {
156
+ ok: false,
157
+ result: primitiveFailure(source, "unsupported-syntax", "Provided JSX source does not resolve to a JSX node", "jsx-node"),
158
+ };
159
+ }
160
+ return {
161
+ ok: true,
162
+ node: declaration.declarations[0].init,
163
+ };
164
+ }
165
+ catch (error) {
166
+ return {
167
+ ok: false,
168
+ result: primitiveFailure(source, "parse-failed", `AST parse failed: ${error instanceof Error ? error.message : String(error)}`, "jsx-node"),
169
+ };
170
+ }
171
+ }
172
+ export function objectPropertyKey(name) {
173
+ return /^[$A-Z_][0-9A-Z_$]*$/i.test(name)
174
+ ? identifier(name)
175
+ : stringLiteral(name);
176
+ }
@@ -0,0 +1,23 @@
1
+ import type { NodePath } from "@babel/traverse";
2
+ import type * as t from "@babel/types";
3
+ import type { AstDiagnostic } from "../../types.js";
4
+ export type ClassExpressionMode = "static" | "call" | "class-map-reference";
5
+ export type ClassExpressionSegmentRole = "static" | "conditional-consequent" | "conditional-alternate" | "object-boolean" | "class-map";
6
+ export interface ClassExpressionSegment {
7
+ role: ClassExpressionSegmentRole;
8
+ value: string;
9
+ key?: string;
10
+ objectName?: string;
11
+ }
12
+ export type ClassExpressionAnalysis = {
13
+ ok: true;
14
+ mode: ClassExpressionMode;
15
+ calls: string[];
16
+ segments: ClassExpressionSegment[];
17
+ } | {
18
+ ok: false;
19
+ diagnostic: AstDiagnostic;
20
+ };
21
+ type ExpressionPath = NodePath<t.Expression | t.JSXEmptyExpression>;
22
+ export declare function analyzeClassExpression(path: ExpressionPath): ClassExpressionAnalysis;
23
+ export {};
@@ -0,0 +1,174 @@
1
+ import { createDiagnostic } from "../../diagnostics/index.js";
2
+ export function analyzeClassExpression(path) {
3
+ if (path.isStringLiteral()) {
4
+ return success("static", [], [{ role: "static", value: path.node.value }]);
5
+ }
6
+ const classMap = analyzeClassMapReference(path);
7
+ if (classMap.ok) {
8
+ return classMap;
9
+ }
10
+ if (path.isConditionalExpression()) {
11
+ return analyzeClassArgument(path, "static");
12
+ }
13
+ if (path.isCallExpression()) {
14
+ return analyzeClassCall(path);
15
+ }
16
+ return unsupported("Class expression must be a static string, clsx/twMerge call, or local class map reference");
17
+ }
18
+ function analyzeClassCall(path) {
19
+ const callee = callName(path.node.callee);
20
+ if (!isSupportedClassCallName(callee)) {
21
+ return unsupported("Class call expression must use cn(), clsx(), or twMerge()");
22
+ }
23
+ const calls = [callee];
24
+ const segments = [];
25
+ for (const argument of path.get("arguments")) {
26
+ if (!argument.isExpression()) {
27
+ return unsupported("Class call arguments must be expressions");
28
+ }
29
+ const analyzed = analyzeClassArgument(argument, "static");
30
+ if (!analyzed.ok) {
31
+ return analyzed;
32
+ }
33
+ calls.push(...analyzed.calls);
34
+ segments.push(...analyzed.segments);
35
+ }
36
+ return success("call", unique(calls), segments);
37
+ }
38
+ function analyzeClassArgument(path, role) {
39
+ if (path.isStringLiteral()) {
40
+ return success("static", [], [{ role, value: path.node.value }]);
41
+ }
42
+ if (path.isConditionalExpression()) {
43
+ const consequent = path.get("consequent");
44
+ const alternate = path.get("alternate");
45
+ const consequentResult = analyzeClassArgument(consequent, "conditional-consequent");
46
+ if (!consequentResult.ok)
47
+ return consequentResult;
48
+ const alternateResult = analyzeClassArgument(alternate, "conditional-alternate");
49
+ if (!alternateResult.ok)
50
+ return alternateResult;
51
+ return success("call", unique([...consequentResult.calls, ...alternateResult.calls]), [...consequentResult.segments, ...alternateResult.segments]);
52
+ }
53
+ if (path.isObjectExpression()) {
54
+ const segments = [];
55
+ for (const property of path.node.properties) {
56
+ if (property.type !== "ObjectProperty") {
57
+ return unsupported("Class object arguments cannot contain spreads or methods");
58
+ }
59
+ const key = objectPropertyKey(property.key);
60
+ if (!key) {
61
+ return unsupported("Class object keys must be static identifiers or strings");
62
+ }
63
+ segments.push({ role: "object-boolean", value: key, key });
64
+ }
65
+ return success("call", [], segments);
66
+ }
67
+ const classMap = analyzeClassMapReference(path);
68
+ if (classMap.ok) {
69
+ return classMap;
70
+ }
71
+ if (path.isCallExpression()) {
72
+ return analyzeClassCall(path);
73
+ }
74
+ return unsupported("Class argument is not statically analyzable");
75
+ }
76
+ function analyzeClassMapReference(path) {
77
+ if (!path.isMemberExpression()) {
78
+ return unsupported("Not a class map reference");
79
+ }
80
+ const object = path.get("object");
81
+ if (!object.isIdentifier()) {
82
+ return unsupported("Class map object must be an identifier");
83
+ }
84
+ const keys = memberExpressionKeys(path);
85
+ if (keys.length === 0) {
86
+ return unsupported("Class map key must be statically resolvable");
87
+ }
88
+ const binding = path.scope.getBinding(object.node.name);
89
+ const bindingPath = binding?.path;
90
+ if (!bindingPath?.isVariableDeclarator()) {
91
+ return unsupported("Class map must reference a local const object literal");
92
+ }
93
+ if (bindingPath.parent.type !== "VariableDeclaration" ||
94
+ bindingPath.parent.kind !== "const") {
95
+ return unsupported("Class map must reference a local const object literal");
96
+ }
97
+ const init = bindingPath.get("init");
98
+ if (!init?.isObjectExpression()) {
99
+ return unsupported("Class map binding must be an object literal");
100
+ }
101
+ const segments = [];
102
+ for (const key of keys) {
103
+ const value = objectExpressionStringValue(init.node, key);
104
+ if (value === null) {
105
+ return unsupported(`Class map key "${key}" must resolve to a string literal`);
106
+ }
107
+ segments.push({
108
+ role: "class-map",
109
+ value,
110
+ key,
111
+ objectName: object.node.name,
112
+ });
113
+ }
114
+ return success("class-map-reference", [], segments);
115
+ }
116
+ function memberExpressionKeys(path) {
117
+ if (!path.node.computed && path.node.property.type === "Identifier") {
118
+ return [path.node.property.name];
119
+ }
120
+ const property = path.get("property");
121
+ if (property.isStringLiteral()) {
122
+ return [property.node.value];
123
+ }
124
+ if (property.isConditionalExpression()) {
125
+ const consequent = property.get("consequent");
126
+ const alternate = property.get("alternate");
127
+ if (consequent.isStringLiteral() && alternate.isStringLiteral()) {
128
+ return [consequent.node.value, alternate.node.value];
129
+ }
130
+ }
131
+ return [];
132
+ }
133
+ function objectExpressionStringValue(object, key) {
134
+ for (const property of object.properties) {
135
+ if (property.type !== "ObjectProperty")
136
+ continue;
137
+ if (objectPropertyKey(property.key) !== key)
138
+ continue;
139
+ if (property.value.type !== "StringLiteral")
140
+ return null;
141
+ return property.value.value;
142
+ }
143
+ return null;
144
+ }
145
+ function objectPropertyKey(key) {
146
+ if (key.type === "Identifier")
147
+ return key.name;
148
+ if (key.type === "StringLiteral")
149
+ return key.value;
150
+ return null;
151
+ }
152
+ function callName(callee) {
153
+ return callee.type === "Identifier" ? callee.name : null;
154
+ }
155
+ function isSupportedClassCallName(name) {
156
+ return name === "cn" || name === "clsx" || name === "twMerge";
157
+ }
158
+ function success(mode, calls, segments) {
159
+ return {
160
+ ok: true,
161
+ mode,
162
+ calls,
163
+ segments,
164
+ };
165
+ }
166
+ function unsupported(message) {
167
+ return {
168
+ ok: false,
169
+ diagnostic: createDiagnostic("unsupported-syntax", message, "jsx-attribute"),
170
+ };
171
+ }
172
+ function unique(items) {
173
+ return [...new Set(items)];
174
+ }
@@ -0,0 +1 @@
1
+ export { setJsxAttribute, removeJsxAttribute, updateClassName, addTailwindClass, removeTailwindClass, updateStyleProperty, updateStyleProperties, updateCssModuleClassReference, type SetJsxAttributeParams, type RemoveJsxAttributeParams, type UpdateClassNameParams, type AddTailwindClassParams, type RemoveTailwindClassParams, type UpdateStylePropertyParams, type UpdateStylePropertiesParams, type UpdateCssModuleClassReferenceParams, } from "./style-primitives.js";
@@ -0,0 +1 @@
1
+ export { setJsxAttribute, removeJsxAttribute, updateClassName, addTailwindClass, removeTailwindClass, updateStyleProperty, updateStyleProperties, updateCssModuleClassReference, } from "./style-primitives.js";
@@ -0,0 +1,49 @@
1
+ import type { AstPrimitiveResult, JsxAttributeLocator, PrimitiveValue } from "../../types.js";
2
+ export interface SetJsxAttributeParams {
3
+ source: string;
4
+ locator: JsxAttributeLocator;
5
+ value: PrimitiveValue;
6
+ }
7
+ export interface RemoveJsxAttributeParams {
8
+ source: string;
9
+ locator: JsxAttributeLocator;
10
+ }
11
+ export interface UpdateClassNameParams {
12
+ source: string;
13
+ locator: JsxAttributeLocator;
14
+ value: string;
15
+ }
16
+ export interface AddTailwindClassParams {
17
+ source: string;
18
+ locator: JsxAttributeLocator;
19
+ token: string;
20
+ }
21
+ export interface RemoveTailwindClassParams {
22
+ source: string;
23
+ locator: JsxAttributeLocator;
24
+ token: string;
25
+ }
26
+ export interface UpdateStylePropertyParams {
27
+ source: string;
28
+ locator: JsxAttributeLocator;
29
+ property: string;
30
+ value: PrimitiveValue;
31
+ }
32
+ export interface UpdateStylePropertiesParams {
33
+ source: string;
34
+ locator: JsxAttributeLocator;
35
+ properties: Record<string, PrimitiveValue>;
36
+ }
37
+ export interface UpdateCssModuleClassReferenceParams {
38
+ source: string;
39
+ locator: JsxAttributeLocator;
40
+ nextClass: string;
41
+ }
42
+ export declare function setJsxAttribute(params: SetJsxAttributeParams): AstPrimitiveResult;
43
+ export declare function removeJsxAttribute(params: RemoveJsxAttributeParams): AstPrimitiveResult;
44
+ export declare function updateClassName(params: UpdateClassNameParams): AstPrimitiveResult;
45
+ export declare function addTailwindClass(params: AddTailwindClassParams): AstPrimitiveResult;
46
+ export declare function removeTailwindClass(params: RemoveTailwindClassParams): AstPrimitiveResult;
47
+ export declare function updateStyleProperty(params: UpdateStylePropertyParams): AstPrimitiveResult;
48
+ export declare function updateStyleProperties(params: UpdateStylePropertiesParams): AstPrimitiveResult;
49
+ export declare function updateCssModuleClassReference(params: UpdateCssModuleClassReferenceParams): AstPrimitiveResult;