@timber-js/app 0.2.0-alpha.102 → 0.2.0-alpha.103
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.
- package/LICENSE +8 -0
- package/dist/fonts/ast.d.ts.map +1 -1
- package/dist/index.js +53 -39
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/cli.ts +0 -0
- package/src/fonts/ast.ts +64 -27
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
DONTFUCKINGUSE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Daniel Saewitz
|
|
4
|
+
|
|
5
|
+
This software may not be used, copied, modified, merged, published,
|
|
6
|
+
distributed, sublicensed, or sold by anyone other than the copyright holder.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
package/dist/fonts/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/fonts/ast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AAIhE,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAiID;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CA4DhF;AAiCD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA4CpF;AAID;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,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CAAA;KAAE,CAAC;CACtD;AAED,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,OAAO,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,0DAA0D;IAC1D,mBAAmB,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,qDAAqD;IACrD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE;AAkFD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAgIrE"}
|
package/dist/index.js
CHANGED
|
@@ -3386,6 +3386,24 @@ var LOCAL_FONT_SOURCES = new Set([
|
|
|
3386
3386
|
"@timber-js/app/fonts/local",
|
|
3387
3387
|
"next/font/local"
|
|
3388
3388
|
]);
|
|
3389
|
+
function isImportDeclaration(node) {
|
|
3390
|
+
return node.type === "ImportDeclaration";
|
|
3391
|
+
}
|
|
3392
|
+
function isVariableDeclaration(node) {
|
|
3393
|
+
return node.type === "VariableDeclaration";
|
|
3394
|
+
}
|
|
3395
|
+
function isExpressionStatement(node) {
|
|
3396
|
+
return node.type === "ExpressionStatement";
|
|
3397
|
+
}
|
|
3398
|
+
function isExportNamedDeclaration(node) {
|
|
3399
|
+
return node.type === "ExportNamedDeclaration";
|
|
3400
|
+
}
|
|
3401
|
+
function isCallExpression(node) {
|
|
3402
|
+
return node.type === "CallExpression";
|
|
3403
|
+
}
|
|
3404
|
+
function isIdentifier(node) {
|
|
3405
|
+
return node.type === "Identifier";
|
|
3406
|
+
}
|
|
3389
3407
|
/**
|
|
3390
3408
|
* Parse a full source file and find all font imports and call sites.
|
|
3391
3409
|
*
|
|
@@ -3401,7 +3419,7 @@ function findFontCallSites(source) {
|
|
|
3401
3419
|
const bindings = [];
|
|
3402
3420
|
const importNodesToRemove = [];
|
|
3403
3421
|
for (const stmt of program.body) {
|
|
3404
|
-
if (stmt
|
|
3422
|
+
if (!isImportDeclaration(stmt)) continue;
|
|
3405
3423
|
const importDecl = stmt;
|
|
3406
3424
|
const specSource = importDecl.source.value;
|
|
3407
3425
|
let provider = null;
|
|
@@ -3421,8 +3439,8 @@ function findFontCallSites(source) {
|
|
|
3421
3439
|
importNode: importDecl
|
|
3422
3440
|
});
|
|
3423
3441
|
importNodesToRemove.push({
|
|
3424
|
-
start:
|
|
3425
|
-
end:
|
|
3442
|
+
start: stmt.start,
|
|
3443
|
+
end: stmt.end
|
|
3426
3444
|
});
|
|
3427
3445
|
}
|
|
3428
3446
|
if (bindings.length === 0) return null;
|
|
@@ -3430,39 +3448,36 @@ function findFontCallSites(source) {
|
|
|
3430
3448
|
const callSites = [];
|
|
3431
3449
|
let dynamicCall = null;
|
|
3432
3450
|
for (const stmt of program.body) {
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
dynamicCall = `${calleeName}(${source.slice(argStart, argEnd)})`;
|
|
3446
|
-
}
|
|
3447
|
-
continue;
|
|
3451
|
+
const effectiveStmt = isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
|
|
3452
|
+
if (isVariableDeclaration(effectiveStmt)) for (const declarator of effectiveStmt.declarations) {
|
|
3453
|
+
if (!declarator.init) continue;
|
|
3454
|
+
if (!isCallExpression(declarator.init)) continue;
|
|
3455
|
+
const call = declarator.init;
|
|
3456
|
+
const site = matchCallExpression(call, bindingsByName, source);
|
|
3457
|
+
if (!site) continue;
|
|
3458
|
+
if (site === "dynamic") {
|
|
3459
|
+
if (!dynamicCall && isIdentifier(call.callee)) {
|
|
3460
|
+
const argStart = call.arguments[0].start;
|
|
3461
|
+
const argEnd = call.arguments[0].end;
|
|
3462
|
+
dynamicCall = `${call.callee.name}(${source.slice(argStart, argEnd)})`;
|
|
3448
3463
|
}
|
|
3449
|
-
|
|
3450
|
-
const { line, column } = offsetToLineColumn(source, call.start);
|
|
3451
|
-
callSites.push({
|
|
3452
|
-
binding: site.binding,
|
|
3453
|
-
assignedName,
|
|
3454
|
-
configNode: site.configNode,
|
|
3455
|
-
replaceStart: call.start,
|
|
3456
|
-
replaceEnd: call.end,
|
|
3457
|
-
line,
|
|
3458
|
-
column
|
|
3459
|
-
});
|
|
3464
|
+
continue;
|
|
3460
3465
|
}
|
|
3466
|
+
const assignedName = isIdentifier(declarator.id) ? declarator.id.name : null;
|
|
3467
|
+
const { line, column } = offsetToLineColumn(source, call.start);
|
|
3468
|
+
callSites.push({
|
|
3469
|
+
binding: site.binding,
|
|
3470
|
+
assignedName,
|
|
3471
|
+
configNode: site.configNode,
|
|
3472
|
+
replaceStart: call.start,
|
|
3473
|
+
replaceEnd: call.end,
|
|
3474
|
+
line,
|
|
3475
|
+
column
|
|
3476
|
+
});
|
|
3461
3477
|
}
|
|
3462
|
-
if (
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
const call = exprStmt.expression;
|
|
3478
|
+
if (isExpressionStatement(effectiveStmt)) {
|
|
3479
|
+
if (isCallExpression(effectiveStmt.expression)) {
|
|
3480
|
+
const call = effectiveStmt.expression;
|
|
3466
3481
|
const site = matchCallExpression(call, bindingsByName, source);
|
|
3467
3482
|
if (site && site !== "dynamic") {
|
|
3468
3483
|
const { line, column } = offsetToLineColumn(source, call.start);
|
|
@@ -3470,16 +3485,15 @@ function findFontCallSites(source) {
|
|
|
3470
3485
|
binding: site.binding,
|
|
3471
3486
|
assignedName: null,
|
|
3472
3487
|
configNode: site.configNode,
|
|
3473
|
-
replaceStart:
|
|
3474
|
-
replaceEnd:
|
|
3488
|
+
replaceStart: effectiveStmt.start,
|
|
3489
|
+
replaceEnd: effectiveStmt.end,
|
|
3475
3490
|
line,
|
|
3476
3491
|
column
|
|
3477
3492
|
});
|
|
3478
|
-
} else if (site === "dynamic" && !dynamicCall) {
|
|
3479
|
-
const calleeName = call.callee.name;
|
|
3493
|
+
} else if (site === "dynamic" && !dynamicCall && isIdentifier(call.callee)) {
|
|
3480
3494
|
const argStart = call.arguments[0].start;
|
|
3481
3495
|
const argEnd = call.arguments[0].end;
|
|
3482
|
-
dynamicCall = `${
|
|
3496
|
+
dynamicCall = `${call.callee.name}(${source.slice(argStart, argEnd)})`;
|
|
3483
3497
|
}
|
|
3484
3498
|
}
|
|
3485
3499
|
}
|
|
@@ -3553,7 +3567,7 @@ function walkForNestedFontCalls(node, bindings, source, out, isNested) {
|
|
|
3553
3567
|
* if the callee doesn't match any font binding.
|
|
3554
3568
|
*/
|
|
3555
3569
|
function matchCallExpression(call, bindings, _source) {
|
|
3556
|
-
if (call.callee
|
|
3570
|
+
if (!isIdentifier(call.callee)) return null;
|
|
3557
3571
|
const calleeName = call.callee.name;
|
|
3558
3572
|
const binding = bindings.get(calleeName);
|
|
3559
3573
|
if (!binding) return null;
|