@geastack/geatsc-plugin-gea 0.1.10 → 0.1.12

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.
@@ -17,8 +17,8 @@ function join(left, right) {
17
17
  empty: a.empty && b.empty,
18
18
  }))));
19
19
  }
20
- // A positive proof selects inline capacity; no proof keeps the existing four
21
- // slots. Overflow remains supported, so capacity never truncates class names.
20
+ // A positive proof bounds every class assignment; unknown mutation invalidates
21
+ // it. Callers version inline-capacity tuning and overflow elimination separately.
22
22
  export function analyzeClassCapacity(files, opaque) {
23
23
  if (opaque)
24
24
  return undefined;
@@ -6,6 +6,7 @@ const number = /^[+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
6
6
  export function cssRangeObserver(features) {
7
7
  const bounds = new Map(families.map(name => [name, { raw: name === 'flex' ? 1 : 0, px: name === 'font' ? 16 : 0, unknown: false }]));
8
8
  let opaque = false;
9
+ let unknownCircle = false;
9
10
  let lineMultiplier = 0;
10
11
  const unknown = (...names) => { for (const name of names)
11
12
  bounds.get(name).unknown = true; };
@@ -29,6 +30,7 @@ export function cssRangeObserver(features) {
29
30
  };
30
31
  return {
31
32
  unknown() { opaque = true; },
33
+ unknownCircleBounds() { unknownCircle = true; },
32
34
  selector(css) { if (/@(?:-webkit-)?keyframes\b|@property\b/i.test(css))
33
35
  opaque = true; },
34
36
  property(name, value) {
@@ -94,6 +96,10 @@ export function cssRangeObserver(features) {
94
96
  },
95
97
  finish() {
96
98
  features.add('css-ranges-v1');
99
+ features.add('css-circle-cache-v1');
100
+ // Explicit unknown survives feature unions from separately analyzed roots.
101
+ if (opaque || unknownCircle || bounds.get('radius').unknown)
102
+ features.add('css-circle-cache-unbounded');
97
103
  if (opaque) {
98
104
  features.add('css-ranges-unknown');
99
105
  return;
@@ -1,8 +1,15 @@
1
1
  import type ts from 'typescript';
2
2
  import { type StyleUsageObserver } from './analyze-renderer.js';
3
- export declare const cssAnalysisVersion = "css-analysis-v15";
4
- export declare const cssFeatures: readonly ["css-pseudo-elements", "css-text-alpha", "css-border-alpha", "css-animations", "css-transforms", "css-grid", "css-floats", "css-writing-mode", "css-border-relief", "css-blink", "css-order", "css-percent-radius", "css-percent-gap", "css-opacity", "css-text-decoration", "css-text-transform", "css-visibility", "css-pointer-events", "css-mask", "css-image-fit", "css-filters", "css-box-shadow", "css-flex-wrap", "css-justify-items", "css-align-content", "css-align-self", "css-min-width", "css-height-expressions", "css-z-index", "css-aspect-ratio", "css-margin-trim", "css-containment", "css-justify-self", "css-flex-line-count", "css-box-expressions", "css-axis-gap", "css-corner-radius", "css-first-line", "css-side-borders", "css-background-layers", "css-line-height-expressions", "css-scrolling", "css-flex-basis-expressions", "css-custom-property-lengths", "css-max-height", "css-flex-basis", "css-overflow-axes", "css-position-top", "css-position-top-percent", "css-position-right", "css-position-right-percent", "css-position-bottom", "css-position-bottom-percent", "css-position-left", "css-position-left-percent"];
3
+ export declare const cssAnalysisVersion = "css-analysis-v19";
4
+ export declare const baseStyleFeatures: readonly ["css-flex-direction", "css-justify-content", "css-align-items", "css-box-sizing", "css-margin-auto", "css-line-height-multiplier", "css-width-expressions", "css-min-height", "css-max-width", "css-active-background"];
5
+ export declare const defaultStyleFeatures: readonly ["css-margins", "css-padding", "css-flex-factors", "css-gap", "css-border-widths", "css-border-colors", "css-font-weight", "css-text-align", "css-white-space", "css-text-overflow"];
6
+ export declare const sizePercentFeatures: readonly ["css-width-percent", "css-height-percent"];
7
+ export declare const compactStyleFeatures: readonly ["css-line-height", "css-display-explicit"];
8
+ export declare const cssFeatures: readonly ["css-line-height", "css-display-explicit", "css-width-percent", "css-height-percent", "css-custom-properties", "css-margins", "css-padding", "css-flex-factors", "css-gap", "css-border-widths", "css-border-colors", "css-font-weight", "css-text-align", "css-white-space", "css-text-overflow", "css-flex-direction", "css-justify-content", "css-align-items", "css-box-sizing", "css-margin-auto", "css-line-height-multiplier", "css-width-expressions", "css-min-height", "css-max-width", "css-active-background", "css-pseudo-elements", "css-text-alpha", "css-border-alpha", "css-animations", "css-transforms", "css-grid", "css-floats", "css-writing-mode", "css-border-relief", "css-blink", "css-order", "css-percent-radius", "css-percent-gap", "css-opacity", "css-text-decoration", "css-text-transform", "css-visibility", "css-pointer-events", "css-mask", "css-image-fit", "css-filters", "css-box-shadow", "css-flex-wrap", "css-justify-items", "css-align-content", "css-align-self", "css-min-width", "css-height-expressions", "css-z-index", "css-aspect-ratio", "css-margin-trim", "css-containment", "css-justify-self", "css-flex-line-count", "css-box-expressions", "css-axis-gap", "css-corner-radius", "css-first-line", "css-side-borders", "css-background-layers", "css-line-height-expressions", "css-scrolling", "css-flex-basis-expressions", "css-custom-property-lengths", "css-max-height", "css-flex-basis", "css-overflow-axes", "css-position-top", "css-position-top-percent", "css-position-right", "css-position-right-percent", "css-position-bottom", "css-position-bottom-percent", "css-position-left", "css-position-left-percent"];
5
9
  export declare function addUnknownCssFeatures(features: Set<string>): void;
6
- export declare function cssUsageObserver(features: Set<string>, resolve?: (node: ts.Expression) => string[] | undefined): StyleUsageObserver & {
10
+ export declare function cssUsageObserver(features: Set<string>, resolve?: ((node: ts.Expression) => string[] | undefined) & {
11
+ isNumeric?(node: ts.Expression): boolean;
12
+ }): StyleUsageObserver & {
7
13
  finish(): void;
14
+ unknownDefaults(): void;
8
15
  };
@@ -1,7 +1,11 @@
1
1
  import { colorAlphaObserver } from './analyze-alpha.js';
2
2
  import { colorVariableAnalysis } from './analyze-renderer.js';
3
- export const cssAnalysisVersion = 'css-analysis-v15';
4
- export const cssFeatures = ['css-pseudo-elements', 'css-text-alpha', 'css-border-alpha', 'css-animations', 'css-transforms', 'css-grid', 'css-floats', 'css-writing-mode', 'css-border-relief', 'css-blink', 'css-order', 'css-percent-radius', 'css-percent-gap', 'css-opacity', 'css-text-decoration', 'css-text-transform', 'css-visibility', 'css-pointer-events', 'css-mask', 'css-image-fit', 'css-filters', 'css-box-shadow', 'css-flex-wrap', 'css-justify-items', 'css-align-content', 'css-align-self', 'css-min-width', 'css-height-expressions', 'css-z-index', 'css-aspect-ratio', 'css-margin-trim', 'css-containment', 'css-justify-self', 'css-flex-line-count', 'css-box-expressions', 'css-axis-gap', 'css-corner-radius', 'css-first-line', 'css-side-borders', 'css-background-layers', 'css-line-height-expressions', 'css-scrolling', 'css-flex-basis-expressions', 'css-custom-property-lengths', 'css-max-height', 'css-flex-basis', 'css-overflow-axes', 'css-position-top', 'css-position-top-percent', 'css-position-right', 'css-position-right-percent', 'css-position-bottom', 'css-position-bottom-percent', 'css-position-left', 'css-position-left-percent'];
3
+ export const cssAnalysisVersion = 'css-analysis-v19';
4
+ export const baseStyleFeatures = ['css-flex-direction', 'css-justify-content', 'css-align-items', 'css-box-sizing', 'css-margin-auto', 'css-line-height-multiplier', 'css-width-expressions', 'css-min-height', 'css-max-width', 'css-active-background'];
5
+ export const defaultStyleFeatures = ['css-margins', 'css-padding', 'css-flex-factors', 'css-gap', 'css-border-widths', 'css-border-colors', 'css-font-weight', 'css-text-align', 'css-white-space', 'css-text-overflow'];
6
+ export const sizePercentFeatures = ['css-width-percent', 'css-height-percent'];
7
+ export const compactStyleFeatures = ['css-line-height', 'css-display-explicit'];
8
+ export const cssFeatures = [...compactStyleFeatures, ...sizePercentFeatures, 'css-custom-properties', ...defaultStyleFeatures, ...baseStyleFeatures, 'css-pseudo-elements', 'css-text-alpha', 'css-border-alpha', 'css-animations', 'css-transforms', 'css-grid', 'css-floats', 'css-writing-mode', 'css-border-relief', 'css-blink', 'css-order', 'css-percent-radius', 'css-percent-gap', 'css-opacity', 'css-text-decoration', 'css-text-transform', 'css-visibility', 'css-pointer-events', 'css-mask', 'css-image-fit', 'css-filters', 'css-box-shadow', 'css-flex-wrap', 'css-justify-items', 'css-align-content', 'css-align-self', 'css-min-width', 'css-height-expressions', 'css-z-index', 'css-aspect-ratio', 'css-margin-trim', 'css-containment', 'css-justify-self', 'css-flex-line-count', 'css-box-expressions', 'css-axis-gap', 'css-corner-radius', 'css-first-line', 'css-side-borders', 'css-background-layers', 'css-line-height-expressions', 'css-scrolling', 'css-flex-basis-expressions', 'css-custom-property-lengths', 'css-max-height', 'css-flex-basis', 'css-overflow-axes', 'css-position-top', 'css-position-top-percent', 'css-position-right', 'css-position-right-percent', 'css-position-bottom', 'css-position-bottom-percent', 'css-position-left', 'css-position-left-percent'];
5
9
  export function addUnknownCssFeatures(features) {
6
10
  for (const feature of cssFeatures)
7
11
  features.add(feature);
@@ -15,7 +19,10 @@ export function cssUsageObserver(features, resolve) {
15
19
  const deferredColors = [];
16
20
  return {
17
21
  unknown: () => { colors.unknown(); addUnknownCssFeatures(features); },
22
+ unknownDefaults: () => { for (const feature of [...compactStyleFeatures, ...sizePercentFeatures, 'css-custom-properties', ...baseStyleFeatures, ...defaultStyleFeatures])
23
+ features.add(feature); },
18
24
  finish() {
25
+ features.add('css-storage-v1');
19
26
  alpha.finish();
20
27
  for (const [feature, value] of deferredColors)
21
28
  if (!colors.isColor(value))
@@ -36,9 +43,12 @@ export function cssUsageObserver(features, resolve) {
36
43
  addUnknownCssFeatures(features);
37
44
  return;
38
45
  }
46
+ if (value !== undefined && /\bvar\s*\(/i.test(value))
47
+ features.add('css-custom-properties');
39
48
  if (name === 'content')
40
49
  features.add('css-pseudo-elements');
41
50
  if (name.startsWith('--')) {
51
+ features.add('css-custom-properties');
42
52
  // Quoted CSS strings remain raw text; the length parser never unquotes
43
53
  // them. Unknown values still keep the length cache automatically.
44
54
  const quoted = value !== undefined && /^(?:"(?:[^"\\\r\n]|\\[^\r\n])*"|'(?:[^'\\\r\n]|\\[^\r\n])*')(?:\s*!important)?$/i.test(value.trim());
@@ -46,9 +56,78 @@ export function cssUsageObserver(features, resolve) {
46
56
  deferredColors.push(['css-custom-property-lengths', value]);
47
57
  return;
48
58
  }
59
+ if (name === 'display')
60
+ features.add('css-display-explicit');
61
+ if (name === 'font' || name === 'line-height' || name === 'lineHeight')
62
+ features.add('css-line-height');
49
63
  const originalValue = value;
50
64
  name = name.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`).toLowerCase();
51
65
  value = value?.trim().toLowerCase();
66
+ // Viewport/font/physical units are lengths, not parent percentages.
67
+ // Functions, variables, opaque values and logical axes retain support
68
+ // unless every authored value is a literal non-percentage length/default.
69
+ const sizeAxes = name === 'width' ? ['width'] : name === 'height' ? ['height']
70
+ : /^(?:inline|block)-size$/.test(name) ? ['width', 'height'] : [];
71
+ const numericValue = value === undefined && expression !== undefined && resolve?.isNumeric?.(expression) === true;
72
+ const nonPercentSize = numericValue || value !== undefined && /^(?:(?:auto|initial|inherit|unset|revert|revert-layer|min-content|max-content|fit-content)|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|svw|svh|lvw|lvh|dvw|dvh|cm|mm|q|in|pt|pc)?)(?:\s*!important)?$/.test(value);
73
+ if (!nonPercentSize)
74
+ for (const axis of sizeAxes)
75
+ features.add(`css-${axis}-percent`);
76
+ // Unauthored default fields need no instance storage. Shorthands and
77
+ // logical declarations retain every physical representation they can set.
78
+ if (/^margin(?:-|$)/.test(name) && name !== 'margin-trim')
79
+ features.add('css-margins');
80
+ if (/^padding(?:-|$)/.test(name))
81
+ features.add('css-padding');
82
+ if (/^flex(?:-grow|-shrink)?$/.test(name))
83
+ features.add('css-flex-factors');
84
+ if (/^(?:grid-)?(?:(?:row|column)-)?gap$/.test(name))
85
+ features.add('css-gap');
86
+ if (/^border(?:-|$)/.test(name) && !name.endsWith('radius')) {
87
+ // Shorthand/style can establish the default border width and color;
88
+ // individual colors and widths retain only their own common family.
89
+ if (!name.endsWith('color'))
90
+ features.add('css-border-widths');
91
+ if (!name.endsWith('width'))
92
+ features.add('css-border-colors');
93
+ }
94
+ if (name === 'font' || name === 'font-weight')
95
+ features.add('css-font-weight');
96
+ if (/^text-align(?:-|$)/.test(name))
97
+ features.add('css-text-align');
98
+ if (/^(?:white-space(?:-|$)|text-wrap(?:-|$))/.test(name))
99
+ features.add('css-white-space');
100
+ if (name === 'text-overflow')
101
+ features.add('css-text-overflow');
102
+ // Independent common fields: their initial values need no per-node storage
103
+ // unless some authored declaration can change them. Logical dimensions
104
+ // may select either physical axis, so they retain both representations.
105
+ if (name === 'flex-direction' || name === 'flex-flow')
106
+ features.add('css-flex-direction');
107
+ if (name === 'justify-content' || name === 'place-content')
108
+ features.add('css-justify-content');
109
+ if (name === 'align-items' || name === 'place-items')
110
+ features.add('css-align-items');
111
+ if (name === 'box-sizing')
112
+ features.add('css-box-sizing');
113
+ if (/^active-background(?:-color)?$/.test(name))
114
+ features.add('css-active-background');
115
+ if (/^min-(?:height|inline-size|block-size)$/.test(name))
116
+ features.add('css-min-height');
117
+ if (/^max-(?:width|inline-size|block-size)$/.test(name))
118
+ features.add('css-max-width');
119
+ if (name === 'block-size' || name === 'inline-size' ||
120
+ (name === 'width' && (value === undefined || !/^(?:(?:auto|initial|inherit|unset|revert|revert-layer)|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:px|%)?)(?:\s*!important)?$/.test(value))))
121
+ features.add('css-width-expressions');
122
+ // Any line-height/font authoring may carry an inherited unitless number
123
+ // through variables or shorthand parsing. Font-size alone cannot do so.
124
+ if (name === 'line-height' || name === 'font')
125
+ features.add('css-line-height-multiplier');
126
+ if (/^margin(?:-|$)/.test(name) && name !== 'margin-trim') {
127
+ const fixed = value?.replace(/\s*!important$/, '').split(/\s+/).every(part => /^(?:(?:initial|inherit|unset|revert|revert-layer)|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:px|em|rem|vw|vh|vmin|vmax|%)?)$/.test(part));
128
+ if (!fixed)
129
+ features.add('css-margin-auto');
130
+ }
52
131
  // Only a proven literal without percentages or functions can omit these
53
132
  // alternate representations. var/calc and dynamic values retain them.
54
133
  // Equal literal edges need one stored value. Unknown functions/variables
@@ -58,7 +137,7 @@ export function cssUsageObserver(features, resolve) {
58
137
  // edge; functions, percentages and unknown values retain percent storage.
59
138
  const positionSides = /^(?:top|right|bottom|left)$/.test(name) ? [name]
60
139
  : /^inset(?:-|$)/.test(name) ? ['top', 'right', 'bottom', 'left'] : [];
61
- const fixedPosition = !!parts?.length && parts.length <= 4 && parts.every(part => /^(?:(?:auto|initial|inherit|unset|revert|revert-layer)|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?)$/.test(part));
140
+ const fixedPosition = numericValue || !!parts?.length && parts.length <= 4 && parts.every(part => /^(?:(?:auto|initial|inherit|unset|revert|revert-layer)|[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|svw|svh|lvw|lvh|dvw|dvh|cm|mm|q|in|pt|pc)?)$/.test(part));
62
141
  for (const side of positionSides) {
63
142
  features.add(`css-position-${side}`);
64
143
  if (!fixedPosition)
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
2
  export declare function sourceLiteralResolver(files: Map<string, string>, initiallyOpaque: boolean): ((node: ts.Expression) => string[] | undefined) & {
3
+ isNumeric(node: ts.Expression): boolean;
3
4
  isSourceMethod(node: ts.Expression): boolean;
4
5
  };
@@ -11,6 +11,7 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
11
11
  const arrays = new Set(), escapedArrays = new Set();
12
12
  const calledMembers = new Set();
13
13
  let opaque = initiallyOpaque;
14
+ let numericOpaque = initiallyOpaque;
14
15
  const nameOf = (node) => node && (ts.isIdentifier(node) || ts.isStringLiteralLike(node) || ts.isNumericLiteral(node)) ? node.text : undefined;
15
16
  const member = (node) => ts.isPropertyAccessExpression(node) ? node.name.text
16
17
  : ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression) ? node.argumentExpression.text : undefined;
@@ -56,11 +57,19 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
56
57
  opaque = true;
57
58
  collect(source);
58
59
  }
60
+ // Native numeric aliases and the collection signature needed to type a
61
+ // JSX map callback. No imported implementation is trusted by this type fact.
62
+ const intrinsicFile = '/__gea_numeric_style_intrinsics.d.ts';
63
+ const intrinsic = ts.createSourceFile(intrinsicFile, `
64
+ type int = number; type float = number; type double = number;
65
+ interface Array<T> { [n: number]: T; length: number; map<U>(fn: (value: T, index: number, array: T[]) => U): U[]; }
66
+ interface ReadonlyArray<T> { readonly [n: number]: T; readonly length: number; map<U>(fn: (value: T, index: number, array: readonly T[]) => U): U[]; }
67
+ `, ts.ScriptTarget.Latest, true);
59
68
  let checker;
60
69
  const typeChecker = () => {
61
70
  if (!checker) {
62
71
  const host = {
63
- getSourceFile: file => sources.get(path.resolve(file)), getDefaultLibFileName: () => '', writeFile: () => { },
72
+ getSourceFile: file => file === intrinsicFile ? intrinsic : sources.get(path.resolve(file)), getDefaultLibFileName: () => '', writeFile: () => { },
64
73
  getCurrentDirectory: () => '/', getDirectories: () => [], getCanonicalFileName: file => file,
65
74
  useCaseSensitiveFileNames: () => true, getNewLine: () => '\n',
66
75
  fileExists: file => sources.has(path.resolve(file)), readFile: file => files.get(path.resolve(file)),
@@ -72,7 +81,7 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
72
81
  return resolved ? { resolvedFileName: resolved, extension: /\.tsx$/.test(resolved) ? ts.Extension.Tsx : ts.Extension.Ts } : undefined;
73
82
  }),
74
83
  };
75
- checker = ts.createProgram([...sources.keys()], { noLib: true, target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler, jsx: ts.JsxEmit.Preserve, strict: true, allowJs: true }, host).getTypeChecker();
84
+ checker = ts.createProgram([...sources.keys(), intrinsicFile], { noLib: true, target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler, jsx: ts.JsxEmit.Preserve, strict: true, allowJs: true }, host).getTypeChecker();
76
85
  }
77
86
  return checker;
78
87
  };
@@ -150,10 +159,14 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
150
159
  (ts.isPropertyAccessExpression(node.left) || ts.isElementAccessExpression(node.left)) && localReceiver(node.right))
151
160
  opaque = true;
152
161
  if (ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isNonNullExpression(node) ||
153
- ts.isSpreadAssignment(node) || ts.isSpreadElement(node))
162
+ ts.isSpreadAssignment(node) || ts.isSpreadElement(node)) {
154
163
  opaque = true;
155
- if (ts.isIdentifier(node) && /^(?:Object|Reflect|Proxy|eval|Function)$/.test(node.text))
164
+ numericOpaque = true;
165
+ }
166
+ if (ts.isIdentifier(node) && /^(?:Object|Reflect|Proxy|eval|Function)$/.test(node.text)) {
156
167
  opaque = true;
168
+ numericOpaque = true;
169
+ }
157
170
  if (ts.isBinaryExpression(node) && node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment && node.operatorToken.kind <= ts.SyntaxKind.LastAssignment) {
158
171
  const lhs = node.left;
159
172
  if (ts.isPropertyAccessExpression(lhs) || ts.isElementAccessExpression(lhs)) {
@@ -265,6 +278,14 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
265
278
  index(source);
266
279
  const original = (node) => expressions.get(`${node.getSourceFile().fileName}:${node.pos}:${node.end}`);
267
280
  return Object.assign((node) => resolve(original(node)), {
281
+ // In a statically lowered numeric slot no value can contain a CSS '%'.
282
+ // Ambiguous imports, assertions and any/unknown retain storage. A typed
283
+ // native number remains numeric when unrelated literal objects escape;
284
+ // unlike the colour proof, its exact value need not be known.
285
+ isNumeric(node) {
286
+ const at = original(node);
287
+ return !!at && !numericOpaque && numeric(at);
288
+ },
268
289
  // A user-authored method called animate is not Element.animate. Require
269
290
  // both its implementation in the scanned graph and a local receiver;
270
291
  // an opaque/DOM receiver merely cast to a class is not sufficient.
@@ -273,6 +294,33 @@ export function sourceLiteralResolver(files, initiallyOpaque) {
273
294
  if (!at || initiallyOpaque)
274
295
  return false;
275
296
  const parent = at.parent;
297
+ // A locally declared frame callback may also be named animate. Resolve
298
+ // its binding instead of confusing the name with Element.animate.
299
+ if (ts.isIdentifier(at)) {
300
+ let symbol = typeChecker().getSymbolAtLocation(at);
301
+ if (symbol && (symbol.flags & ts.SymbolFlags.Alias))
302
+ symbol = typeChecker().getAliasedSymbol(symbol);
303
+ const declarations = symbol?.declarations;
304
+ if (declarations?.length && declarations.every(declaration => sources.has(declaration.getSourceFile().fileName) && ts.isFunctionDeclaration(declaration) && !!declaration.body)) {
305
+ let reassigned = false;
306
+ const checkWrites = (child) => {
307
+ if (ts.isBinaryExpression(child) && child.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
308
+ child.operatorToken.kind <= ts.SyntaxKind.LastAssignment) {
309
+ const checkTarget = (target) => {
310
+ if (ts.isIdentifier(target) && typeChecker().getSymbolAtLocation(target) === symbol)
311
+ reassigned = true;
312
+ ts.forEachChild(target, checkTarget);
313
+ };
314
+ checkTarget(child.left);
315
+ }
316
+ ts.forEachChild(child, checkWrites);
317
+ };
318
+ for (const source of sources.values())
319
+ checkWrites(source);
320
+ if (!reassigned)
321
+ return true;
322
+ }
323
+ }
276
324
  if (ts.isMethodDeclaration(parent) && parent.name === at && parent.body)
277
325
  return true;
278
326
  const access = ts.isPropertyAccessExpression(at) || ts.isElementAccessExpression(at) ? at
@@ -0,0 +1,6 @@
1
+ import ts from 'typescript';
2
+ export declare const nodeAuxVersion = "node-aux-v1";
3
+ export declare const nodeAuxFeatures: readonly ["node-listeners", "node-attributes", "node-default-styles"];
4
+ export declare function addUnknownNodeAux(features: Set<string>): void;
5
+ export declare function cssUsesNodeAttributes(css: string): boolean;
6
+ export declare function addNodeAuxFeatures(file: string, text: string, features: Set<string>, isNumeric: (node: ts.Expression) => boolean): void;
@@ -0,0 +1,94 @@
1
+ import ts from 'typescript';
2
+ export const nodeAuxVersion = 'node-aux-v1';
3
+ export const nodeAuxFeatures = ['node-listeners', 'node-attributes', 'node-default-styles'];
4
+ export function addUnknownNodeAux(features) {
5
+ for (const feature of nodeAuxFeatures)
6
+ features.add(feature);
7
+ }
8
+ // The CSS observer supplies a whole stylesheet. Only rule preludes may
9
+ // select attributes: declarations such as color:#fff do not need an ID store.
10
+ export function cssUsesNodeAttributes(css) {
11
+ let prelude = '', quote = '', escaped = false;
12
+ for (const ch of css) {
13
+ if (quote) {
14
+ prelude += ch;
15
+ if (escaped)
16
+ escaped = false;
17
+ else if (ch === '\\')
18
+ escaped = true;
19
+ else if (ch === quote)
20
+ quote = '';
21
+ continue;
22
+ }
23
+ if (ch === '"' || ch === "'") {
24
+ quote = ch;
25
+ prelude += ch;
26
+ continue;
27
+ }
28
+ if (ch === '{') {
29
+ if (/[#\[]/.test(prelude))
30
+ return true;
31
+ prelude = '';
32
+ }
33
+ else if (ch === '}' || ch === ';')
34
+ prelude = '';
35
+ else
36
+ prelude += ch;
37
+ }
38
+ return !!quote;
39
+ }
40
+ // This proof covers authored JSX and all discovered source, not a runtime
41
+ // census. Unresolved imports/native code, opaque DOM calls, spreads and native
42
+ // controls preserve the full owners. Ordinary class/style bindings use their
43
+ // own stores and do not require a generic attribute list.
44
+ export function addNodeAuxFeatures(file, text, features, isNumeric) {
45
+ if (/\.css$/i.test(file))
46
+ return;
47
+ const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, /\.[jt]sx$/i.test(file) ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
48
+ const unknown = () => addUnknownNodeAux(features);
49
+ const token = (name) => {
50
+ if (/^(?:addEventListener|removeEventListener|setEventListener|dispatchEvent|on[A-Z].*|on(?:click|pointer.*|touch.*|input|keydown|scroll)|click|touchstart|touchmove|touchend|pointerdown|pointermove|pointerup|input|keydown|scroll)$/.test(name))
51
+ features.add('node-listeners');
52
+ if (/^(?:id|dataset|attributes|getElementById|querySelector|querySelectorAll|ensureAppRoot|setAttribute|getAttribute|removeAttribute|hasAttribute|toggleAttribute|setPressId|setPressValue|pressId|pressValue|data-press-id|data-press-value)$/.test(name))
53
+ features.add('node-attributes');
54
+ if (name === 'setDefaultStyle')
55
+ features.add('node-default-styles');
56
+ if (/^(?:eval|Function|Reflect|Proxy|Object|DOMParser|innerHTML|outerHTML|insertAdjacentHTML|createElement|createElementNS|parseFromString|createContextualFragment|__gea_.*)$/.test(name) && name !== '__gea_Display')
57
+ unknown();
58
+ };
59
+ const visit = (node) => {
60
+ if (ts.isIdentifier(node) || ts.isStringLiteralLike(node))
61
+ token(node.text);
62
+ if (ts.isJsxSpreadAttribute(node))
63
+ unknown();
64
+ if (ts.isJsxAttribute(node)) {
65
+ const name = node.name.getText(source);
66
+ if (!/^(?:class|className|style|children|key)$/.test(name))
67
+ features.add('node-attributes');
68
+ if (/^on/i.test(name))
69
+ features.add('node-listeners');
70
+ if (name === 'ref')
71
+ unknown();
72
+ token(name);
73
+ }
74
+ if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
75
+ const tag = node.tagName.getText(source);
76
+ // Other builtins can install native listeners, attributes or defaults.
77
+ if (/^[a-z]/.test(tag) && !/^(?:div|span|p|section|main|header|footer|article|aside|nav)$/.test(tag))
78
+ unknown();
79
+ }
80
+ if (ts.isElementAccessExpression(node) && node.argumentExpression &&
81
+ !ts.isStringLiteralLike(node.argumentExpression) && !isNumeric(node.argumentExpression))
82
+ unknown();
83
+ if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) &&
84
+ /^(?:gea-embedded|@geastack\/(?:core|engine)|@geajs\/core)(?:\/|$)/.test(node.moduleSpecifier.text) &&
85
+ node.importClause && !node.importClause.isTypeOnly) {
86
+ const bindings = node.importClause.namedBindings;
87
+ if (node.importClause.name || !bindings || !ts.isNamedImports(bindings) ||
88
+ bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount|Display)$/.test((item.propertyName ?? item.name).text)))
89
+ unknown();
90
+ }
91
+ ts.forEachChild(node, visit);
92
+ };
93
+ visit(source);
94
+ }
@@ -39,12 +39,14 @@ export function addNodeFeatures(file, text, features) {
39
39
  }
40
40
  if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node))
41
41
  name(node.tagName.getText(source).split(':').at(-1));
42
+ // Display controls the panel/canvas; importing it cannot create native
43
+ // image or input nodes. Calls that actually create nodes are still scanned.
42
44
  if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) &&
43
45
  /^(?:gea-embedded|@geastack\/(?:core|engine)|@geajs\/core)(?:\/|$)/.test(node.moduleSpecifier.text) &&
44
46
  node.importClause && !node.importClause.isTypeOnly) {
45
47
  const bindings = node.importClause.namedBindings;
46
48
  if (node.importClause.name || !bindings || !ts.isNamedImports(bindings) ||
47
- bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount)$/.test((item.propertyName ?? item.name).text)))
49
+ bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount|Display)$/.test((item.propertyName ?? item.name).text)))
48
50
  unknown();
49
51
  }
50
52
  // Mutation/markup helpers can create descendants whose tags are not present
@@ -1,5 +1,6 @@
1
1
  import ts from 'typescript';
2
2
  export declare const rendererAnalysisVersion = "renderer-analysis-v1";
3
+ export declare const rendererOcclusionAnalysisVersion = "renderer-occlusion-v1";
3
4
  export declare function addUnknownRendererFeatures(features: Set<string>): void;
4
5
  export interface StyleUsageObserver {
5
6
  isSourceMethod?(node: ts.Expression): boolean;
@@ -7,6 +8,7 @@ export interface StyleUsageObserver {
7
8
  property(name: string | undefined, value: string | undefined, expression?: ts.Expression): void;
8
9
  unknown(): void;
9
10
  unknownRanges?(): void;
11
+ unknownCircleBounds?(): void;
10
12
  }
11
13
  export declare function colorVariableAnalysis(): {
12
14
  property(name: string | undefined, value: string | undefined): void;
@@ -1,9 +1,11 @@
1
1
  import ts from 'typescript';
2
2
  export const rendererAnalysisVersion = 'renderer-analysis-v1';
3
+ export const rendererOcclusionAnalysisVersion = 'renderer-occlusion-v1';
3
4
  const rendererFeatures = ['renderer-circles', 'renderer-transforms', 'renderer-linear-gradients', 'renderer-radial-gradients'];
4
5
  export function addUnknownRendererFeatures(features) {
5
6
  for (const feature of rendererFeatures)
6
7
  features.add(feature);
8
+ features.add('renderer-occlusion-triangles');
7
9
  }
8
10
  // Proof shared by CSS storage and renderer cache selection. Custom-property
9
11
  // identifiers are case-sensitive; missing/aliased/opaque definitions retain
@@ -64,6 +66,10 @@ export function addRendererFeatures(file, text, features, observer, variables) {
64
66
  return;
65
67
  }
66
68
  const cssName = name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).toLowerCase();
69
+ // CSS rounded boxes also use the circle span caches in Canvas.
70
+ if (/^border(?:-(?:top-left|top-right|bottom-left|bottom-right))?-radius$/.test(cssName) &&
71
+ (value === undefined || !/^0(?:px)?(?:\s+0(?:px)?)*$/i.test(value.trim())))
72
+ features.add('renderer-circles');
67
73
  if (/^(?:-webkit-)?(?:transform|perspective|translate|rotate|scale)$/.test(cssName)) {
68
74
  if (value?.trim().toLowerCase() !== 'none')
69
75
  features.add('renderer-transforms');
@@ -230,25 +236,50 @@ export function addRendererFeatures(file, text, features, observer, variables) {
230
236
  return opaqueCallable(node.expression, seen);
231
237
  return false;
232
238
  };
233
- const circleMethods = new Set(['arc', 'arcTo', 'ellipse', 'roundRect', 'fillCircle', 'fillCircles', 'fillCirclesRgb565', 'fillCirclesRgb565Uniform', 'fillCirclesRgb565WorldYSorted', 'fillCircleBox', 'fillEllipse', 'fillEllipseBatch', 'fillRoundedRectBoxesRgb565']);
239
+ const circleMethods = new Set(['arc', 'arcTo', 'ellipse', 'roundRect', 'fillCircle', 'fillCircleRgb565', 'drawImageCircle', 'drawImageRounded', 'fillCircles', 'fillCirclesRgb565', 'fillCirclesRgb565Uniform', 'fillCirclesRgb565WorldYSorted', 'fillCircleBox', 'fillEllipse', 'fillEllipseBatch', 'fillRoundedRectBoxesRgb565', 'fillRoundedRect', 'strokeCircle', 'strokeRoundedRect']);
234
240
  const visit = (node) => {
241
+ // Include references so aliased/destructured drawing cannot evade the proof.
242
+ if ((ts.isIdentifier(node) || ts.isStringLiteralLike(node)) && /^(?:fillTriangle\w*|TriangleEntry|eval|Function|Reflect)$/.test(node.text))
243
+ features.add('renderer-occlusion-triangles');
244
+ if (ts.isIdentifier(node) && /^__gea_/.test(node.text) && node.text !== '__gea_Display')
245
+ features.add('renderer-occlusion-triangles');
246
+ // CSS radius bounds say nothing about imperative drawing, including aliases
247
+ // and destructured/bare methods. Keep their full caches conservatively.
248
+ if ((ts.isIdentifier(node) || ts.isStringLiteralLike(node)) && circleMethods.has(node.text))
249
+ observer?.unknownCircleBounds?.();
235
250
  if (ts.isIdentifier(node) && /^__gea_/.test(node.text) && node.text !== '__gea_Display')
236
251
  observer?.unknownRanges?.();
237
252
  // These factories/hosts can inject native defaults or change length scaling
238
253
  // outside the authored CSS range proof. Type-only imports cannot do so.
254
+ // Display alone is safe: actual DPR setters and opaque calls below still
255
+ // invalidate bounds, including aliased and bracket-access setters.
239
256
  if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) &&
240
257
  /^(?:gea-embedded|@geastack\/(?:core|engine)|@geajs\/core)(?:\/|$)/.test(node.moduleSpecifier.text) &&
241
258
  node.importClause && !node.importClause.isTypeOnly) {
242
259
  const bindings = node.importClause.namedBindings;
243
260
  if (node.importClause.name || !bindings || !ts.isNamedImports(bindings) ||
244
- bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount)$/.test((item.propertyName ?? item.name).text)))
261
+ bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount|Display)$/.test((item.propertyName ?? item.name).text))) {
245
262
  observer?.unknownRanges?.();
263
+ features.add('renderer-occlusion-triangles');
264
+ }
246
265
  }
247
266
  if (ts.isIdentifier(node) && /^(?:setDevicePixelRatio|setViewportMetrics|devicePixelRatio|__gea_StyleSheet|createVirtualList|createInput|createTextInput|VirtualList|VirtualListElement|TextInput|VirtualKeyboard)$/.test(node.text))
248
267
  observer?.unknownRanges?.();
249
268
  if ((ts.isStringLiteralLike(node) && /^(?:virtual-list|input|textarea|select)$/i.test(node.text)) ||
250
269
  ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && /^(?:virtual-list|input|textarea|select)$/i.test(node.tagName.getText(source))))
251
270
  observer?.unknownRanges?.();
271
+ // Preserve intrinsic text defaults even when no CSS declaration spells
272
+ // them out. These observations also cover literal createElement tags.
273
+ const intrinsicTag = ts.isStringLiteralLike(node) ? node.text.toLowerCase()
274
+ : ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) ? node.tagName.getText(source).toLowerCase() : '';
275
+ if (/^(?:button|img|image|canvas|video|camera|audio|virtual-list|input|textarea|select)$/.test(intrinsicTag))
276
+ observer?.unknownCircleBounds?.();
277
+ if (/^(?:b|strong|h[1-6]|th)$/.test(intrinsicTag))
278
+ observer?.property('font-weight', undefined);
279
+ if (/^(?:pre|textarea)$/.test(intrinsicTag))
280
+ observer?.property('white-space', undefined);
281
+ if (/^(?:center|th)$/.test(intrinsicTag))
282
+ observer?.property('text-align', undefined);
252
283
  // Native controls can introduce scrollable descendants without authored
253
284
  // overflow CSS. Literal tag/factory use retains state; dynamic factories
254
285
  // and computed calls are opaque and keep all families below.
@@ -269,6 +300,8 @@ export function addRendererFeatures(file, text, features, observer, variables) {
269
300
  allStyles();
270
301
  if (ts.isBindingElement(node) && node.propertyName && ts.isComputedPropertyName(node.propertyName) && literal(node.propertyName.expression) === undefined)
271
302
  allStyles();
303
+ if (ts.isBindingElement(node) && node.propertyName && ts.isComputedPropertyName(node.propertyName) && /^fillTriangle\w*$/.test(literal(node.propertyName.expression) ?? ''))
304
+ features.add('renderer-occlusion-triangles');
272
305
  if (ts.isTaggedTemplateExpression(node) && ts.isTemplateExpression(node.template))
273
306
  allStyles();
274
307
  // Literal CSS also covers CSS templates, DOM setters and imported helpers.
@@ -278,8 +311,12 @@ export function addRendererFeatures(file, text, features, observer, variables) {
278
311
  const name = member(node);
279
312
  if (name && /^(?:setDevicePixelRatio|setViewportMetrics|devicePixelRatio)$/.test(name))
280
313
  observer?.unknownRanges?.();
281
- if (name && circleMethods.has(name))
314
+ if (name && circleMethods.has(name)) {
282
315
  features.add('renderer-circles');
316
+ observer?.unknownCircleBounds?.();
317
+ }
318
+ if (name && /^fillTriangle\w*$/.test(name))
319
+ features.add('renderer-occlusion-triangles');
283
320
  if (name === 'dataset' || (name === 'animate' && !observer?.isSourceMethod?.(node)))
284
321
  allStyles();
285
322
  if (name && /^(?:setAttribute|insertRule|replaceSync)$/.test(name) && !(ts.isCallExpression(node.parent) && node.parent.expression === node))
@@ -357,8 +394,12 @@ export function addRendererFeatures(file, text, features, observer, variables) {
357
394
  addUnknownRendererFeatures(features);
358
395
  observer?.unknown();
359
396
  }
360
- if (name && circleMethods.has(name))
397
+ if (name && circleMethods.has(name)) {
361
398
  features.add('renderer-circles');
399
+ observer?.unknownCircleBounds?.();
400
+ }
401
+ if (name && /^fillTriangle\w*$/.test(name))
402
+ features.add('renderer-occlusion-triangles');
362
403
  if (name === 'createLinearGradient')
363
404
  features.add('renderer-linear-gradients');
364
405
  if (name === 'createRadialGradient')
@@ -385,7 +426,12 @@ export function addRendererFeatures(file, text, features, observer, variables) {
385
426
  for (const arg of node.arguments.slice(1))
386
427
  styleObject(arg);
387
428
  }
388
- if (name === 'insertRule' || name === 'replaceSync' || name === 'replace') {
429
+ // String.replace is not CSSStyleSheet.replace. A literal receiver is
430
+ // a primitive string even when its replacement callback is dynamic.
431
+ const literalStringReplace = name === 'replace' &&
432
+ (ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression)) &&
433
+ literal(node.expression.expression) !== undefined;
434
+ if (name === 'insertRule' || name === 'replaceSync' || (name === 'replace' && !literalStringReplace)) {
389
435
  if (node.arguments[0])
390
436
  styleObject(node.arguments[0]);
391
437
  }
package/dist/analyze.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { nodeAuxVersion, addNodeAuxFeatures, addUnknownNodeAux, cssUsesNodeAttributes } from './analyze-node-aux.js';
1
2
  import { sourceLiteralResolver } from './analyze-literals.js';
2
3
  import fs from 'node:fs';
3
4
  import { analyzeClassCapacity } from './analyze-classes.js';
@@ -7,7 +8,7 @@ import { createRequire } from 'node:module';
7
8
  import { nodeAnalysisVersion, addNodeFeatures, addUnknownNodeFeatures } from './analyze-nodes.js';
8
9
  import { cssRangeObserver } from './analyze-css-ranges.js';
9
10
  import { cssAnalysisVersion, cssUsageObserver, addUnknownCssFeatures } from './analyze-css.js';
10
- import { addRendererFeatures, addUnknownRendererFeatures, rendererAnalysisVersion, rendererVariableAnalysis } from './analyze-renderer.js';
11
+ import { addRendererFeatures, addUnknownRendererFeatures, rendererAnalysisVersion, rendererOcclusionAnalysisVersion, rendererVariableAnalysis } from './analyze-renderer.js';
11
12
  export function capabilitiesToAnalyzePatch(capabilities) {
12
13
  const features = [];
13
14
  const bindings = [];
@@ -29,7 +30,7 @@ export function capabilitiesToAnalyzePatch(capabilities) {
29
30
  // connection with "No server verification option set".
30
31
  export function analyzeSourceHostBindings(entry) {
31
32
  const bindings = new Set();
32
- const features = new Set([rendererAnalysisVersion, cssAnalysisVersion, nodeAnalysisVersion]);
33
+ const features = new Set([rendererAnalysisVersion, rendererOcclusionAnalysisVersion, cssAnalysisVersion, nodeAnalysisVersion, nodeAuxVersion]);
33
34
  const discovery = discoverSourceFiles(entry);
34
35
  const classSources = new Map();
35
36
  let classUnknown = discovery.unknown;
@@ -40,15 +41,18 @@ export function analyzeSourceHostBindings(entry) {
40
41
  const ranges = cssRangeObserver(features);
41
42
  const observer = {
42
43
  isSourceMethod: literals.isSourceMethod,
43
- selector(value) { css.selector?.(value); ranges.selector?.(value); },
44
+ selector(value) { css.selector?.(value); ranges.selector?.(value); if (cssUsesNodeAttributes(value))
45
+ features.add('node-attributes'); },
44
46
  property(name, value, expression) { css.property(name, value, expression); ranges.property(name, value); variables.property(name, value); },
45
- unknown() { classUnknown = true; css.unknown(); ranges.unknown(); variables.unknown(); addUnknownNodeFeatures(features); },
46
- unknownRanges() { ranges.unknown(); },
47
+ unknown() { features.add('renderer-occlusion-triangles'); classUnknown = true; css.unknown(); ranges.unknown(); variables.unknown(); addUnknownNodeFeatures(features); addUnknownNodeAux(features); },
48
+ unknownRanges() { features.add('renderer-occlusion-triangles'); ranges.unknown(); css.unknownDefaults(); },
49
+ unknownCircleBounds() { ranges.unknownCircleBounds?.(); },
47
50
  };
48
51
  if (discovery.unknown) {
49
52
  variables.unknown();
50
53
  ranges.unknown();
51
54
  addUnknownNodeFeatures(features);
55
+ addUnknownNodeAux(features);
52
56
  }
53
57
  if (discovery.unknown) {
54
58
  addUnknownRendererFeatures(features);
@@ -65,10 +69,13 @@ export function analyzeSourceHostBindings(entry) {
65
69
  addFeaturesForUrlSchemes(text, features);
66
70
  addRendererFeatures(file, text, features, observer, variables);
67
71
  addNodeFeatures(file, text, features);
72
+ addNodeAuxFeatures(file, text, features, literals.isNumeric);
68
73
  }
69
74
  const classCapacity = analyzeClassCapacity(classSources, classUnknown || features.has('node-inputs') || features.has('node-images'));
70
- if (classCapacity !== undefined)
75
+ if (classCapacity !== undefined) {
71
76
  features.add(`node-class-capacity-v1-${classCapacity}`);
77
+ features.add(`node-class-storage-v1-${classCapacity}`);
78
+ }
72
79
  variables.finish();
73
80
  css.finish();
74
81
  ranges.finish();
@@ -150,6 +157,9 @@ function addBindingsForGeaEmbeddedImports(text, bindings) {
150
157
  const hostGlobalCalls = [
151
158
  [/(?<![.\w$])fetch\s*\(/, 'fetch'],
152
159
  [/(?<![.\w$])new\s+WebSocket\s*\(/, 'websocket'],
160
+ [/(?<![.\w$])new\s+(?:window\.|globalThis\.)?RTCPeerConnection\s*\(/, 'rtc'],
161
+ [/(?<![.\w$])navigator\s*\.\s*mediaDevices\s*\.\s*getUserMedia\s*\(/, 'audio'],
162
+ [/(?<![.\w$])new\s+(?:window\.|globalThis\.)?AudioContext\s*\(/, 'audio'],
153
163
  ];
154
164
  // A file that declares its own `fetch` (a class method, or a wrapper such as
155
165
  // image-demo's runtime.ts) calls that one; its network use, if any, shows up
@@ -193,6 +203,11 @@ function discoverSourceFiles(entry) {
193
203
  if (visited.has(resolved) || !fs.existsSync(resolved) || !fs.statSync(resolved).isFile())
194
204
  return;
195
205
  visited.add(resolved);
206
+ // Imported data is not executable source. Parsing a JPEG or JSON as TS
207
+ // manufactures syntax errors and falsely marks every renderer feature as
208
+ // reachable. Dynamic use of data as CSS is still observed at its call site.
209
+ if (/\.(?:json|png|jpe?g|gif|webp|bmp|ico|ttf|otf|woff2?|wav|mp3|ogg|mp4)$/i.test(resolved))
210
+ return;
196
211
  const text = fs.readFileSync(resolved, 'utf8');
197
212
  for (const specifier of /\.css$/i.test(resolved) ? [] : moduleSpecifiers(resolved, text)) {
198
213
  // Framework host imports do not inject renderer instructions. Other
@@ -246,11 +261,9 @@ function moduleSpecifiers(file, text) {
246
261
  return specifiers;
247
262
  }
248
263
  function resolvePackageModule(importer, specifier) {
249
- // CSS package imports must be traversed just like relative stylesheets. For
250
- // opaque JS packages keep the conservative feature set instead of assuming
251
- // their exports cannot render anything.
252
- if (!/\.css$/i.test(specifier))
253
- return null;
264
+ // Installed JS libraries can be the only consumers of networking and audio
265
+ // (e.g. livekit-client). Traverse their real source just like relative imports.
266
+ // Unresolved/native imports still retain the conservative renderer feature set.
254
267
  try {
255
268
  return createRequire(importer).resolve(specifier);
256
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/geatsc-plugin-gea",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Gea IR backend plugin for geatsc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -54,5 +54,6 @@
54
54
  "peerDependencies": {
55
55
  "typescript": ">=5.9.3",
56
56
  "@geastack/compiler": ">=1.0.19"
57
- }
57
+ },
58
+ "gitHead": "e375eddd8f725d7cc5de3fd46baca63e35936027"
58
59
  }