@geastack/geatsc-plugin-gea 0.1.15 → 0.1.17
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/dist/analyze-literals.d.ts +1 -0
- package/dist/analyze-literals.js +20 -1
- package/dist/analyze-renderer.d.ts +1 -0
- package/dist/analyze-renderer.js +1 -1
- package/dist/analyze.js +1 -0
- package/dist/cpp-ir.js +4 -4
- package/dist/host-declarations.js +7 -0
- package/dist/host-shims.js +35 -1
- package/package.json +1 -1
|
@@ -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); },
|
package/dist/cpp-ir.js
CHANGED
|
@@ -1511,12 +1511,12 @@ export function directCanvasInteropSource(usesCanvas, options = {}) {
|
|
|
1511
1511
|
"}",
|
|
1512
1512
|
"",
|
|
1513
1513
|
"template <typename Image, typename X, typename Y>",
|
|
1514
|
-
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D
|
|
1514
|
+
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y) {",
|
|
1515
1515
|
" ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y));",
|
|
1516
1516
|
"}",
|
|
1517
1517
|
"",
|
|
1518
1518
|
"template <typename Image, typename X, typename Y, typename W, typename H>",
|
|
1519
|
-
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D
|
|
1519
|
+
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
|
|
1520
1520
|
" ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y), canvasInt(w), canvasInt(h));",
|
|
1521
1521
|
"}",
|
|
1522
1522
|
"",
|
|
@@ -2256,12 +2256,12 @@ function canvasInteropSource(usesCanvas, directCanvas) {
|
|
|
2256
2256
|
"}",
|
|
2257
2257
|
"",
|
|
2258
2258
|
"template <typename Image, typename X, typename Y>",
|
|
2259
|
-
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D
|
|
2259
|
+
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y) {",
|
|
2260
2260
|
" ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y));",
|
|
2261
2261
|
"}",
|
|
2262
2262
|
"",
|
|
2263
2263
|
"template <typename Image, typename X, typename Y, typename W, typename H>",
|
|
2264
|
-
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D
|
|
2264
|
+
"inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
|
|
2265
2265
|
" ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y), canvasInt(w), canvasInt(h));",
|
|
2266
2266
|
"}",
|
|
2267
2267
|
"",
|
|
@@ -87,6 +87,13 @@ const geaDeviceInfoHostMethods = ['deviceId', 'platform', 'chipModel', 'chipArch
|
|
|
87
87
|
const geaGea3dHostMethods = [
|
|
88
88
|
'createBuffer', 'bufferDataF32', 'bufferDataU32', 'beginFrame',
|
|
89
89
|
'ambientLight', 'directionalLight', 'drawElements', 'endFrame', 'stat',
|
|
90
|
+
// scene graph
|
|
91
|
+
'deleteBuffer', 'createGeometry', 'deleteGeometry', 'geometryBuffers',
|
|
92
|
+
'createMaterial', 'deleteMaterial', 'materialSet', 'createNode',
|
|
93
|
+
'deleteNode', 'nodeParent', 'nodeTransform', 'nodeMatrix', 'nodeFlags',
|
|
94
|
+
'nodeGeometry', 'nodeInstances', 'nodeLight', 'nodeLightTarget',
|
|
95
|
+
'cameraProjection', 'sceneEnvironment', 'renderOptions', 'renderTarget',
|
|
96
|
+
'createSurface', 'drawScene', 'raycast', 'rayResult',
|
|
90
97
|
];
|
|
91
98
|
const geaGea3dDeclarations = [...geaHostDeclarations, '#include "gea3d_native.h"'];
|
|
92
99
|
const geaMemoryHostMethods = [
|
package/dist/host-shims.js
CHANGED
|
@@ -663,6 +663,33 @@ export function createGeaHostShims() {
|
|
|
663
663
|
drawElements: "gea::host::gea3d::drawElements",
|
|
664
664
|
endFrame: "gea::host::gea3d::endFrame",
|
|
665
665
|
stat: "gea::host::gea3d::stat",
|
|
666
|
+
// The scene-graph engine (gea3d's three.js-style API): geometry,
|
|
667
|
+
// materials and nodes live natively and one drawScene renders a frame.
|
|
668
|
+
deleteBuffer: "gea::host::gea3d::deleteBuffer",
|
|
669
|
+
createGeometry: "gea::host::gea3d::createGeometry",
|
|
670
|
+
deleteGeometry: "gea::host::gea3d::deleteGeometry",
|
|
671
|
+
geometryBuffers: "gea::host::gea3d::geometryBuffers",
|
|
672
|
+
createMaterial: "gea::host::gea3d::createMaterial",
|
|
673
|
+
deleteMaterial: "gea::host::gea3d::deleteMaterial",
|
|
674
|
+
materialSet: "gea::host::gea3d::materialSet",
|
|
675
|
+
createNode: "gea::host::gea3d::createNode",
|
|
676
|
+
deleteNode: "gea::host::gea3d::deleteNode",
|
|
677
|
+
nodeParent: "gea::host::gea3d::nodeParent",
|
|
678
|
+
nodeTransform: "gea::host::gea3d::nodeTransform",
|
|
679
|
+
nodeMatrix: "gea::host::gea3d::nodeMatrix",
|
|
680
|
+
nodeFlags: "gea::host::gea3d::nodeFlags",
|
|
681
|
+
nodeGeometry: "gea::host::gea3d::nodeGeometry",
|
|
682
|
+
nodeInstances: "gea::host::gea3d::nodeInstances",
|
|
683
|
+
nodeLight: "gea::host::gea3d::nodeLight",
|
|
684
|
+
nodeLightTarget: "gea::host::gea3d::nodeLightTarget",
|
|
685
|
+
cameraProjection: "gea::host::gea3d::cameraProjection",
|
|
686
|
+
sceneEnvironment: "gea::host::gea3d::sceneEnvironment",
|
|
687
|
+
renderOptions: "gea::host::gea3d::renderOptions",
|
|
688
|
+
renderTarget: "gea::host::gea3d::renderTarget",
|
|
689
|
+
createSurface: "gea::host::gea3d::createSurface",
|
|
690
|
+
drawScene: "gea::host::gea3d::drawScene",
|
|
691
|
+
raycast: "gea::host::gea3d::raycast",
|
|
692
|
+
rayResult: "gea::host::gea3d::rayResult",
|
|
666
693
|
},
|
|
667
694
|
"navigator.geolocation": {
|
|
668
695
|
hasFix: "gea::host::navigator.geolocation.hasFix",
|
|
@@ -3045,7 +3072,7 @@ export function createGeaHostShims() {
|
|
|
3045
3072
|
returnType: "void",
|
|
3046
3073
|
},
|
|
3047
3074
|
],
|
|
3048
|
-
// `GeaEmbeddedImage`'s own
|
|
3075
|
+
// `GeaEmbeddedImage`'s own methods. The struct
|
|
3049
3076
|
// (`core/packages/host/include/host/image.h:19-29`) is held by value --
|
|
3050
3077
|
// `IMAGE_RECEIVER_TYPES` is what the property getters below already read
|
|
3051
3078
|
// it through -- so each is a direct call on the receiver, exactly like
|
|
@@ -3059,6 +3086,13 @@ export function createGeaHostShims() {
|
|
|
3059
3086
|
// table"), which is correct of the compiler and a gap in this table: the
|
|
3060
3087
|
// member exists in the header and in `index.d.ts`, and only the spelling
|
|
3061
3088
|
// that joins them was missing.
|
|
3089
|
+
decode: [
|
|
3090
|
+
{
|
|
3091
|
+
receiverTypes: IMAGE_RECEIVER_TYPES,
|
|
3092
|
+
emit: "({receiver}).decode()",
|
|
3093
|
+
returnType: "bool",
|
|
3094
|
+
},
|
|
3095
|
+
],
|
|
3062
3096
|
dispose: [
|
|
3063
3097
|
{
|
|
3064
3098
|
receiverTypes: IMAGE_RECEIVER_TYPES,
|