@geastack/geatsc-plugin-gea 0.1.15 → 0.1.16
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
export declare function sourceLiteralResolver(files: Map<string, string>, initiallyOpaque: boolean): ((node: ts.Expression) => string[] | undefined) & {
|
|
3
3
|
isString(node: ts.Expression): boolean;
|
|
4
|
+
isBoolean(node: ts.Expression): boolean;
|
|
4
5
|
isNumeric(node: ts.Expression): boolean;
|
|
5
6
|
isSourceMethod(node: ts.Expression): boolean;
|
|
6
7
|
};
|
package/dist/analyze-literals.js
CHANGED
|
@@ -107,7 +107,16 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
|
|
|
107
107
|
return true;
|
|
108
108
|
if (ts.isIdentifier(node)) {
|
|
109
109
|
const declaration = declarationOf(node);
|
|
110
|
-
|
|
110
|
+
if (declaration?.initializer)
|
|
111
|
+
return localReceiver(declaration.initializer, seen);
|
|
112
|
+
// A default-exported instance has an ExportAssignment declaration,
|
|
113
|
+
// rather than a const variable. Follow its authored initializer too.
|
|
114
|
+
let symbol = typeChecker().getSymbolAtLocation(node);
|
|
115
|
+
if (symbol && (symbol.flags & ts.SymbolFlags.Alias))
|
|
116
|
+
symbol = typeChecker().getAliasedSymbol(symbol);
|
|
117
|
+
const exported = symbol?.valueDeclaration;
|
|
118
|
+
return !!exported && ts.isExportAssignment(exported) &&
|
|
119
|
+
sources.has(exported.getSourceFile().fileName) && localReceiver(exported.expression, seen);
|
|
111
120
|
}
|
|
112
121
|
if (ts.isNewExpression(node)) {
|
|
113
122
|
let symbol = typeChecker().getSymbolAtLocation(node.expression);
|
|
@@ -290,6 +299,16 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
|
|
|
290
299
|
const alternatives = type.isUnion() ? type.types : [type];
|
|
291
300
|
return alternatives.every(value => !!(value.flags & ts.TypeFlags.StringLike));
|
|
292
301
|
},
|
|
302
|
+
// A boolean named animate is an application flag, never a Web Animations
|
|
303
|
+
// API reference. Unknown or mixed types still retain animation support.
|
|
304
|
+
isBoolean(node) {
|
|
305
|
+
const at = original(node);
|
|
306
|
+
if (!at || initiallyOpaque)
|
|
307
|
+
return false;
|
|
308
|
+
const type = typeChecker().getTypeAtLocation(at);
|
|
309
|
+
const alternatives = type.isUnion() ? type.types : [type];
|
|
310
|
+
return alternatives.every(value => !!(value.flags & ts.TypeFlags.BooleanLike));
|
|
311
|
+
},
|
|
293
312
|
// In a statically lowered numeric slot no value can contain a CSS '%'.
|
|
294
313
|
// Ambiguous imports, assertions and any/unknown retain storage. A typed
|
|
295
314
|
// native number remains numeric when unrelated literal objects escape;
|
|
@@ -5,6 +5,7 @@ export declare function addUnknownRendererFeatures(features: Set<string>): void;
|
|
|
5
5
|
export interface StyleUsageObserver {
|
|
6
6
|
isSourceMethod?(node: ts.Expression): boolean;
|
|
7
7
|
isString?(node: ts.Expression): boolean;
|
|
8
|
+
isBoolean?(node: ts.Expression): boolean;
|
|
8
9
|
selector?(css: string): void;
|
|
9
10
|
property(name: string | undefined, value: string | undefined, expression?: ts.Expression): void;
|
|
10
11
|
unknown(): void;
|
package/dist/analyze-renderer.js
CHANGED
|
@@ -294,7 +294,7 @@ export function addRendererFeatures(file, text, features, observer, variables) {
|
|
|
294
294
|
// references as well as calls so aliases cannot bypass the proof. Frame
|
|
295
295
|
// scheduling (requestAnimationFrame) is independent and stays available.
|
|
296
296
|
if (ts.isIdentifier(node) && /^(?:animate|KeyframeEffect|Animation|AnimationEngine|DeclarativeAnimations|Reflect)$/.test(node.text) &&
|
|
297
|
-
!(node.text === 'animate' && observer?.isSourceMethod?.(node)))
|
|
297
|
+
!(node.text === 'animate' && (observer?.isSourceMethod?.(node) || observer?.isBoolean?.(node))))
|
|
298
298
|
allStyles();
|
|
299
299
|
if (ts.isBindingElement(node) && /^(?:createElement|createElementNS|animate|setAttribute|insertRule|replaceSync)$/.test(node.propertyName?.getText(source).replace(/^['"]|['"]$/g, '') ?? node.name.getText(source)))
|
|
300
300
|
allStyles();
|
package/dist/analyze.js
CHANGED
|
@@ -44,6 +44,7 @@ export function analyzeSourceHostBindings(entry) {
|
|
|
44
44
|
const observer = {
|
|
45
45
|
isSourceMethod: literals.isSourceMethod,
|
|
46
46
|
isString: literals.isString,
|
|
47
|
+
isBoolean: literals.isBoolean,
|
|
47
48
|
selector(value) { css.selector?.(value); ranges.selector?.(value); if (cssUsesNodeAttributes(value))
|
|
48
49
|
features.add('node-attributes'); },
|
|
49
50
|
property(name, value, expression) { css.property(name, value, expression); ranges.property(name, value); variables.property(name, value); },
|