@codepress/codepress-engine 0.5.0-dev.hmr-rebase.20251104052503 → 0.5.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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Module Graph Collection for Babel Plugin
3
+ * Ported from SWC plugin (lib.rs lines 1143-1200)
4
+ */
5
+ import type * as Babel from "@babel/core";
6
+ export interface ImportRow {
7
+ local: string;
8
+ imported: string;
9
+ source: string;
10
+ span: string;
11
+ }
12
+ export interface ExportRow {
13
+ exported: string;
14
+ local: string;
15
+ span: string;
16
+ }
17
+ export interface ReexportRow {
18
+ exported: string;
19
+ imported: string;
20
+ source: string;
21
+ span: string;
22
+ }
23
+ export interface DefRow {
24
+ local: string;
25
+ kind: 'var' | 'let' | 'const' | 'func' | 'class';
26
+ span: string;
27
+ }
28
+ export interface MutationRow {
29
+ root: string;
30
+ path: string;
31
+ kind: 'assign' | 'update' | 'call:Object.assign' | 'call:push' | 'call:set';
32
+ span: string;
33
+ }
34
+ export interface LiteralIxRow {
35
+ export_name: string;
36
+ path: string;
37
+ text: string;
38
+ span: string;
39
+ }
40
+ export interface ModuleGraph {
41
+ imports: ImportRow[];
42
+ exports: ExportRow[];
43
+ reexports: ReexportRow[];
44
+ defs: DefRow[];
45
+ mutations: MutationRow[];
46
+ literal_index: LiteralIxRow[];
47
+ }
48
+ export declare class ModuleGraphCollector {
49
+ graph: ModuleGraph;
50
+ private filename;
51
+ constructor(filename: string);
52
+ visitImportDeclaration(path: Babel.NodePath<Babel.types.ImportDeclaration>): void;
53
+ visitExportNamedDeclaration(path: Babel.NodePath<Babel.types.ExportNamedDeclaration>): void;
54
+ visitVariableDeclarator(path: Babel.NodePath<Babel.types.VariableDeclarator>, kind: 'var' | 'let' | 'const'): void;
55
+ visitAssignmentExpression(path: Babel.NodePath<Babel.types.AssignmentExpression>): void;
56
+ visitUpdateExpression(path: Babel.NodePath<Babel.types.UpdateExpression>): void;
57
+ visitCallExpression(path: Babel.NodePath<Babel.types.CallExpression>): void;
58
+ private staticMemberPath;
59
+ private harvestLiteralIndex;
60
+ private makeSpan;
61
+ getGraph(): ModuleGraph;
62
+ }
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ /**
3
+ * Module Graph Collection for Babel Plugin
4
+ * Ported from SWC plugin (lib.rs lines 1143-1200)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ModuleGraphCollector = void 0;
8
+ class ModuleGraphCollector {
9
+ constructor(filename) {
10
+ this.filename = filename;
11
+ this.graph = {
12
+ imports: [],
13
+ exports: [],
14
+ reexports: [],
15
+ defs: [],
16
+ mutations: [],
17
+ literal_index: [],
18
+ };
19
+ }
20
+ // Port of visit_mut_import_decl (lib.rs:1549-1589)
21
+ visitImportDeclaration(path) {
22
+ const source = path.node.source.value;
23
+ for (const spec of path.node.specifiers) {
24
+ if (spec.type === 'ImportSpecifier') {
25
+ this.graph.imports.push({
26
+ local: spec.local.name,
27
+ imported: spec.imported.type === 'Identifier'
28
+ ? spec.imported.name
29
+ : spec.local.name,
30
+ source,
31
+ span: this.makeSpan(spec.loc),
32
+ });
33
+ }
34
+ else if (spec.type === 'ImportDefaultSpecifier') {
35
+ this.graph.imports.push({
36
+ local: spec.local.name,
37
+ imported: 'default',
38
+ source,
39
+ span: this.makeSpan(spec.loc),
40
+ });
41
+ }
42
+ else if (spec.type === 'ImportNamespaceSpecifier') {
43
+ this.graph.imports.push({
44
+ local: spec.local.name,
45
+ imported: '*',
46
+ source,
47
+ span: this.makeSpan(spec.loc),
48
+ });
49
+ }
50
+ }
51
+ }
52
+ // Port of visit_mut_export_decl (lib.rs:1592-1658)
53
+ visitExportNamedDeclaration(path) {
54
+ const { declaration, specifiers, source } = path.node;
55
+ if (source) {
56
+ // export { x } from './module' - Reexport
57
+ for (const spec of specifiers) {
58
+ if (spec.type === 'ExportSpecifier') {
59
+ this.graph.reexports.push({
60
+ exported: spec.exported.type === 'Identifier'
61
+ ? spec.exported.name
62
+ : spec.exported.value,
63
+ imported: spec.local.type === 'Identifier'
64
+ ? spec.local.name
65
+ : spec.local.value,
66
+ source: source.value,
67
+ span: this.makeSpan(spec.loc),
68
+ });
69
+ }
70
+ }
71
+ }
72
+ else if (declaration) {
73
+ // export const x = ...
74
+ if (declaration.type === 'VariableDeclaration') {
75
+ for (const declarator of declaration.declarations) {
76
+ if (declarator.id.type === 'Identifier') {
77
+ const name = declarator.id.name;
78
+ // Track definition
79
+ this.graph.defs.push({
80
+ local: name,
81
+ kind: declaration.kind,
82
+ span: this.makeSpan(declarator.loc),
83
+ });
84
+ // Track export
85
+ this.graph.exports.push({
86
+ exported: name,
87
+ local: name,
88
+ span: this.makeSpan(declarator.id.loc),
89
+ });
90
+ // Harvest literals from initializer
91
+ if (declarator.init) {
92
+ this.harvestLiteralIndex(name, declarator.init, '');
93
+ }
94
+ }
95
+ }
96
+ }
97
+ else if (declaration.type === 'FunctionDeclaration' && declaration.id) {
98
+ const name = declaration.id.name;
99
+ this.graph.defs.push({
100
+ local: name,
101
+ kind: 'func',
102
+ span: this.makeSpan(declaration.id.loc),
103
+ });
104
+ this.graph.exports.push({
105
+ exported: name,
106
+ local: name,
107
+ span: this.makeSpan(declaration.id.loc),
108
+ });
109
+ }
110
+ else if (declaration.type === 'ClassDeclaration' && declaration.id) {
111
+ const name = declaration.id.name;
112
+ this.graph.defs.push({
113
+ local: name,
114
+ kind: 'class',
115
+ span: this.makeSpan(declaration.id.loc),
116
+ });
117
+ this.graph.exports.push({
118
+ exported: name,
119
+ local: name,
120
+ span: this.makeSpan(declaration.id.loc),
121
+ });
122
+ }
123
+ }
124
+ else {
125
+ // export { x } (no source)
126
+ for (const spec of specifiers) {
127
+ if (spec.type === 'ExportSpecifier' && spec.local.type === 'Identifier') {
128
+ this.graph.exports.push({
129
+ exported: spec.exported.type === 'Identifier'
130
+ ? spec.exported.name
131
+ : spec.exported.value,
132
+ local: spec.local.name,
133
+ span: this.makeSpan(spec.local.loc),
134
+ });
135
+ }
136
+ }
137
+ }
138
+ }
139
+ // Port of visit_mut_var_declarator (lib.rs:1740-1753)
140
+ visitVariableDeclarator(path, kind) {
141
+ if (path.node.id.type === 'Identifier') {
142
+ this.graph.defs.push({
143
+ local: path.node.id.name,
144
+ kind,
145
+ span: this.makeSpan(path.node.loc),
146
+ });
147
+ }
148
+ }
149
+ // Port of visit_mut_assign_expr (lib.rs:1773-1814)
150
+ visitAssignmentExpression(path) {
151
+ const { left } = path.node;
152
+ if (left.type === 'Identifier') {
153
+ this.graph.mutations.push({
154
+ root: left.name,
155
+ path: '',
156
+ kind: 'assign',
157
+ span: this.makeSpan(path.node.loc),
158
+ });
159
+ }
160
+ else if (left.type === 'MemberExpression') {
161
+ const memberPath = this.staticMemberPath(left);
162
+ if (memberPath) {
163
+ this.graph.mutations.push({
164
+ root: memberPath.root,
165
+ path: memberPath.path,
166
+ kind: 'assign',
167
+ span: this.makeSpan(path.node.loc),
168
+ });
169
+ }
170
+ }
171
+ }
172
+ // Port of visit_mut_update_expr (lib.rs:1816-1830)
173
+ visitUpdateExpression(path) {
174
+ const { argument } = path.node;
175
+ if (argument.type === 'Identifier') {
176
+ this.graph.mutations.push({
177
+ root: argument.name,
178
+ path: '',
179
+ kind: 'update',
180
+ span: this.makeSpan(path.node.loc),
181
+ });
182
+ }
183
+ else if (argument.type === 'MemberExpression') {
184
+ const memberPath = this.staticMemberPath(argument);
185
+ if (memberPath) {
186
+ this.graph.mutations.push({
187
+ root: memberPath.root,
188
+ path: memberPath.path,
189
+ kind: 'update',
190
+ span: this.makeSpan(path.node.loc),
191
+ });
192
+ }
193
+ }
194
+ }
195
+ // Port of visit_mut_call_expr (lib.rs:1832-1859)
196
+ visitCallExpression(path) {
197
+ const { callee, arguments: args } = path.node;
198
+ // Object.assign(target, ...)
199
+ if (callee.type === 'MemberExpression' &&
200
+ callee.object.type === 'Identifier' &&
201
+ callee.object.name === 'Object' &&
202
+ callee.property.type === 'Identifier' &&
203
+ callee.property.name === 'assign') {
204
+ const firstArg = args[0];
205
+ if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.type) === 'Identifier') {
206
+ this.graph.mutations.push({
207
+ root: firstArg.name,
208
+ path: '',
209
+ kind: 'call:Object.assign',
210
+ span: this.makeSpan(path.node.loc),
211
+ });
212
+ }
213
+ else if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.type) === 'MemberExpression') {
214
+ const memberPath = this.staticMemberPath(firstArg);
215
+ if (memberPath) {
216
+ this.graph.mutations.push({
217
+ root: memberPath.root,
218
+ path: memberPath.path,
219
+ kind: 'call:Object.assign',
220
+ span: this.makeSpan(path.node.loc),
221
+ });
222
+ }
223
+ }
224
+ }
225
+ // array.push(), map.set(), etc.
226
+ else if (callee.type === 'MemberExpression' && callee.property.type === 'Identifier') {
227
+ const method = callee.property.name;
228
+ // Guard against Super type which staticMemberPath doesn't handle
229
+ if (callee.object.type === 'Super') {
230
+ return;
231
+ }
232
+ const memberPath = this.staticMemberPath(callee.object);
233
+ if (memberPath) {
234
+ let kind = 'assign';
235
+ if (['push', 'unshift', 'splice'].includes(method)) {
236
+ kind = 'call:push';
237
+ }
238
+ else if (['set', 'setIn'].includes(method)) {
239
+ kind = 'call:set';
240
+ }
241
+ this.graph.mutations.push({
242
+ root: memberPath.root,
243
+ path: memberPath.path,
244
+ kind,
245
+ span: this.makeSpan(path.node.loc),
246
+ });
247
+ }
248
+ }
249
+ }
250
+ // Port of static_member_path (lib.rs:348-397)
251
+ staticMemberPath(expr) {
252
+ if (expr.type === 'Identifier') {
253
+ return { root: expr.name, path: '' };
254
+ }
255
+ if (expr.type !== 'MemberExpression') {
256
+ return null;
257
+ }
258
+ const parts = [];
259
+ let current = expr;
260
+ while (current.type === 'MemberExpression') {
261
+ if (current.property.type === 'Identifier' && !current.computed) {
262
+ parts.unshift(`.${current.property.name}`);
263
+ }
264
+ else if (current.computed) {
265
+ if (current.property.type === 'StringLiteral') {
266
+ parts.unshift(`["${current.property.value}"]`);
267
+ }
268
+ else if (current.property.type === 'NumericLiteral') {
269
+ parts.unshift(`[${current.property.value}]`);
270
+ }
271
+ else {
272
+ return null; // Non-static computed property
273
+ }
274
+ }
275
+ current = current.object;
276
+ }
277
+ if (current.type === 'Identifier') {
278
+ return { root: current.name, path: parts.join('') };
279
+ }
280
+ return null;
281
+ }
282
+ // Port of harvest_literal_index (lib.rs:2264-2310)
283
+ harvestLiteralIndex(exportName, node, prefix) {
284
+ if (node.type === 'ObjectExpression') {
285
+ for (const prop of node.properties) {
286
+ if (prop.type === 'ObjectProperty') {
287
+ let key;
288
+ if (prop.key.type === 'Identifier') {
289
+ key = prop.key.name;
290
+ }
291
+ else if (prop.key.type === 'StringLiteral') {
292
+ key = prop.key.value;
293
+ }
294
+ else if (prop.key.type === 'NumericLiteral') {
295
+ key = String(prop.key.value);
296
+ }
297
+ else {
298
+ continue;
299
+ }
300
+ const path = prefix ? `${prefix}.${key}` : key;
301
+ this.harvestLiteralIndex(exportName, prop.value, path);
302
+ }
303
+ }
304
+ }
305
+ else if (node.type === 'ArrayExpression') {
306
+ node.elements.forEach((el, idx) => {
307
+ if (el && el.type !== 'SpreadElement') {
308
+ const path = `${prefix}[${idx}]`;
309
+ this.harvestLiteralIndex(exportName, el, path);
310
+ }
311
+ });
312
+ }
313
+ else if (node.type === 'StringLiteral') {
314
+ this.graph.literal_index.push({
315
+ export_name: exportName,
316
+ path: prefix,
317
+ text: node.value,
318
+ span: this.makeSpan(node.loc),
319
+ });
320
+ }
321
+ }
322
+ makeSpan(loc) {
323
+ if (!loc)
324
+ return `${this.filename}:0`;
325
+ return `${this.filename}:${loc.start.line}`;
326
+ }
327
+ getGraph() {
328
+ return this.graph;
329
+ }
330
+ }
331
+ exports.ModuleGraphCollector = ModuleGraphCollector;
332
+ //# sourceMappingURL=module-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-graph.js","sourceRoot":"","sources":["../../src/babel/module-graph.ts"],"names":[],"mappings":";AAAA;;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CAAC,GAAG,CAAC;aAC9B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,GAAkD;QACjE,IAAI,CAAC,GAAG;YAAE,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC;QACtC,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAvVD,oDAuVC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Provenance Tracking for Babel Plugin
3
+ * Ported from SWC plugin (lib.rs lines 1203-1283, 553-904)
4
+ */
5
+ import type * as Babel from "@babel/core";
6
+ export type ProvNode = {
7
+ kind: 'Literal';
8
+ span: string;
9
+ value_kind: 'string' | 'number' | 'other';
10
+ } | {
11
+ kind: 'Ident';
12
+ name: string;
13
+ span: string;
14
+ } | {
15
+ kind: 'Init';
16
+ span: string;
17
+ } | {
18
+ kind: 'Import';
19
+ source: string;
20
+ imported: string;
21
+ span: string;
22
+ } | {
23
+ kind: 'Member';
24
+ span: string;
25
+ } | {
26
+ kind: 'ObjectProp';
27
+ key: string;
28
+ span: string;
29
+ } | {
30
+ kind: 'ArrayElem';
31
+ index: number;
32
+ span: string;
33
+ } | {
34
+ kind: 'Call';
35
+ callee: string;
36
+ callsite: string;
37
+ callee_span: string;
38
+ fn_def_span?: string;
39
+ } | {
40
+ kind: 'Ctor';
41
+ callee: string;
42
+ span: string;
43
+ } | {
44
+ kind: 'Op';
45
+ op: string;
46
+ span: string;
47
+ } | {
48
+ kind: 'Env';
49
+ key: string;
50
+ span: string;
51
+ } | {
52
+ kind: 'Unknown';
53
+ span: string;
54
+ };
55
+ export interface Candidate {
56
+ target: string;
57
+ reason: string;
58
+ }
59
+ export interface SymbolRef {
60
+ file: string;
61
+ local: string;
62
+ path: string;
63
+ span: string;
64
+ }
65
+ export declare class ProvenanceTracker {
66
+ private bindings;
67
+ private filename;
68
+ constructor(filename: string);
69
+ collectBindings(program: Babel.NodePath<Babel.types.Program>): void;
70
+ traceExpression(expr: Babel.types.Expression, chain: ProvNode[], depth?: number, seen?: Set<string>): void;
71
+ rankCandidates(chain: ProvNode[]): Candidate[];
72
+ aggregateKinds(chain: ProvNode[]): string[];
73
+ collectSymbolRefs(expr: Babel.types.Expression, refs: SymbolRef[]): void;
74
+ private detectEnvMember;
75
+ private staticMemberPath;
76
+ private makeSpan;
77
+ }