@geastack/geatsc-plugin-gea 0.1.6
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 +202 -0
- package/README.md +37 -0
- package/dist/analyze.d.ts +4 -0
- package/dist/analyze.js +195 -0
- package/dist/cpp-canvas-colors.d.ts +4 -0
- package/dist/cpp-canvas-colors.js +226 -0
- package/dist/cpp-field-access.d.ts +49 -0
- package/dist/cpp-field-access.js +144 -0
- package/dist/cpp-ir-dom-style.d.ts +1 -0
- package/dist/cpp-ir-dom-style.js +49 -0
- package/dist/cpp-ir.d.ts +30 -0
- package/dist/cpp-ir.js +2426 -0
- package/dist/cpp-keyed-component-diagnostics.d.ts +8 -0
- package/dist/cpp-keyed-component-diagnostics.js +74 -0
- package/dist/cpp-keyed-list-diagnostics.d.ts +17 -0
- package/dist/cpp-keyed-list-diagnostics.js +84 -0
- package/dist/cpp-mounted-lowering.d.ts +81 -0
- package/dist/cpp-mounted-lowering.js +2235 -0
- package/dist/cpp-mounted.d.ts +25 -0
- package/dist/cpp-mounted.js +1376 -0
- package/dist/cpp-reactive-component-diagnostics.d.ts +2 -0
- package/dist/cpp-reactive-component-diagnostics.js +76 -0
- package/dist/cpp-reactive-component.d.ts +14 -0
- package/dist/cpp-reactive-component.js +349 -0
- package/dist/cpp-replacements.d.ts +14 -0
- package/dist/cpp-replacements.js +787 -0
- package/dist/cpp-source-replacements.d.ts +11 -0
- package/dist/cpp-source-replacements.js +257 -0
- package/dist/cpp-store-hub.d.ts +7 -0
- package/dist/cpp-store-hub.js +160 -0
- package/dist/cpp-store-method-body-parser.d.ts +2 -0
- package/dist/cpp-store-method-body-parser.js +392 -0
- package/dist/cpp-store-method-context.d.ts +48 -0
- package/dist/cpp-store-method-context.js +114 -0
- package/dist/cpp-store-method-expressions.d.ts +12 -0
- package/dist/cpp-store-method-expressions.js +1263 -0
- package/dist/cpp-store-method-replacements.d.ts +5 -0
- package/dist/cpp-store-method-replacements.js +1521 -0
- package/dist/cpp-store-method-targets.d.ts +19 -0
- package/dist/cpp-store-method-targets.js +296 -0
- package/dist/cpp-store-typed-arrays.d.ts +2 -0
- package/dist/cpp-store-typed-arrays.js +655 -0
- package/dist/cpp-stores.d.ts +73 -0
- package/dist/cpp-stores.js +1739 -0
- package/dist/cpp-template-renderer.d.ts +23 -0
- package/dist/cpp-template-renderer.js +3530 -0
- package/dist/css-style-declaration-shims.d.ts +3 -0
- package/dist/css-style-declaration-shims.js +47 -0
- package/dist/host-declarations.d.ts +11 -0
- package/dist/host-declarations.js +320 -0
- package/dist/host-shims.d.ts +3 -0
- package/dist/host-shims.js +3217 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1239 -0
- package/dist/load-ir.d.ts +7 -0
- package/dist/load-ir.js +40 -0
- package/dist/types.d.ts +604 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.js +723 -0
- package/dist/validate.d.ts +3 -0
- package/dist/validate.js +226 -0
- package/package.json +57 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GeaIrComponent } from './types.js';
|
|
2
|
+
export declare function reactiveChildInstanceExpression(child: GeaIrComponent): string;
|
|
3
|
+
export interface ReactiveFieldRef {
|
|
4
|
+
fieldName: string;
|
|
5
|
+
readerName: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface BindReactiveRequest {
|
|
8
|
+
deps: string[];
|
|
9
|
+
fields: ReactiveFieldRef[];
|
|
10
|
+
captures: string[];
|
|
11
|
+
body: string[];
|
|
12
|
+
disposerVar?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface FieldAccess {
|
|
15
|
+
readonly paramDecl: string;
|
|
16
|
+
readonly rootExpr: string;
|
|
17
|
+
readonly typed: boolean;
|
|
18
|
+
childMountStoreArg(child: GeaIrComponent): string | null;
|
|
19
|
+
readOwnField(field: ReactiveFieldRef): string;
|
|
20
|
+
readOwnFieldLocal(field: ReactiveFieldRef): string;
|
|
21
|
+
bindReactiveOwn(request: BindReactiveRequest): string[];
|
|
22
|
+
callOwnMethod(method: string, args: string[]): string;
|
|
23
|
+
}
|
|
24
|
+
export declare class BoxedStoreFieldAccess implements FieldAccess {
|
|
25
|
+
readonly paramDecl: string;
|
|
26
|
+
readonly rootExpr = "store";
|
|
27
|
+
readonly typed = false;
|
|
28
|
+
private readonly resolveChildStoreArg;
|
|
29
|
+
private readonly typedParamClass;
|
|
30
|
+
constructor(childStoreArg?: (child: GeaIrComponent) => string | null, typedParamClass?: string | null);
|
|
31
|
+
childMountStoreArg(child: GeaIrComponent): string | null;
|
|
32
|
+
readOwnField(field: ReactiveFieldRef): string;
|
|
33
|
+
readOwnFieldLocal(field: ReactiveFieldRef): string;
|
|
34
|
+
bindReactiveOwn(request: BindReactiveRequest): string[];
|
|
35
|
+
callOwnMethod(method: string, args: string[]): string;
|
|
36
|
+
}
|
|
37
|
+
export declare class TypedSelfFieldAccess implements FieldAccess {
|
|
38
|
+
readonly typed = true;
|
|
39
|
+
readonly rootExpr = "store";
|
|
40
|
+
readonly paramDecl: string;
|
|
41
|
+
private readonly className;
|
|
42
|
+
private readonly resolveChildStoreArg;
|
|
43
|
+
constructor(className: string, childStoreArg?: (child: GeaIrComponent) => string | null);
|
|
44
|
+
childMountStoreArg(child: GeaIrComponent): string | null;
|
|
45
|
+
readOwnField(field: ReactiveFieldRef): string;
|
|
46
|
+
readOwnFieldLocal(field: ReactiveFieldRef): string;
|
|
47
|
+
bindReactiveOwn(request: BindReactiveRequest): string[];
|
|
48
|
+
callOwnMethod(method: string, args: string[]): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// The seam that lets the ONE mounted renderer emit either boxed or fully-typed
|
|
2
|
+
// reads. The renderer's tree/keyed-list/conditional/child logic is type-agnostic;
|
|
3
|
+
// only the leaves differ — how a store field is read, how a reactive binding is
|
|
4
|
+
// installed, how a method is called, and the renderer's store/self parameter.
|
|
5
|
+
//
|
|
6
|
+
// BoxedStore — today's behavior, byte-for-byte: `read_X_field(store)`,
|
|
7
|
+
// `bindReactiveApply(store, …)`, `const gea_cpp_value &store`.
|
|
8
|
+
// TypedSelf — a self-store ReactiveComponent: `self->field.get()`, per-field
|
|
9
|
+
// `self->field.subscribe(apply)`, `const std::shared_ptr<App> &self`.
|
|
10
|
+
// No gea_cpp_value anywhere in the read/bind/call path.
|
|
11
|
+
//
|
|
12
|
+
// A field whose type isn't statically known still falls back to a boxed read even
|
|
13
|
+
// under TypedSelf (the renderer marks such reads), so "emit types as much as
|
|
14
|
+
// possible" degrades gracefully rather than failing.
|
|
15
|
+
import { cppString, sanitizeCppIdentifier } from './utils.js';
|
|
16
|
+
import { storeFieldLocalName } from './cpp-mounted-lowering.js';
|
|
17
|
+
// A ReactiveComponent child mounts a fresh typed instance of its own class in
|
|
18
|
+
// EVERY parent mode — its renderer takes `shared_ptr<Child>`, never the
|
|
19
|
+
// parent's store.
|
|
20
|
+
export function reactiveChildInstanceExpression(child) {
|
|
21
|
+
return `std::make_shared<${sanitizeCppIdentifier(child.exportName)}>()`;
|
|
22
|
+
}
|
|
23
|
+
// ── BoxedStore: today's exact emit (keep byte-identical) ───────────────────────
|
|
24
|
+
export class BoxedStoreFieldAccess {
|
|
25
|
+
paramDecl;
|
|
26
|
+
rootExpr = 'store';
|
|
27
|
+
typed = false;
|
|
28
|
+
// Optional child-aware resolver: a child whose mount takes the TYPED
|
|
29
|
+
// shared_ptr store can't accept the parent's boxed `store` forward — the
|
|
30
|
+
// resolver (injected by cpp-mounted, which has the component/store context)
|
|
31
|
+
// passes the child's typed global accessor instead. Default keeps the
|
|
32
|
+
// legacy forward.
|
|
33
|
+
resolveChildStoreArg;
|
|
34
|
+
// Set when the component's single subtree store is a typed-carrier global:
|
|
35
|
+
// the store param becomes the `std::shared_ptr<Class>` itself. Field reads
|
|
36
|
+
// keep the same `read_X(store)` shape (typed overloads resolve), binds go
|
|
37
|
+
// through the typed hub, and a genuinely dynamic own-method call boxes via
|
|
38
|
+
// gea_cpp_key at that boundary.
|
|
39
|
+
typedParamClass;
|
|
40
|
+
constructor(childStoreArg, typedParamClass = null) {
|
|
41
|
+
this.resolveChildStoreArg =
|
|
42
|
+
childStoreArg ?? ((child) => (child.reactiveState ? reactiveChildInstanceExpression(child) : 'store'));
|
|
43
|
+
this.typedParamClass = typedParamClass;
|
|
44
|
+
this.paramDecl = typedParamClass ? `const std::shared_ptr<${typedParamClass}> &store` : 'const gea_cpp_value &store';
|
|
45
|
+
}
|
|
46
|
+
childMountStoreArg(child) {
|
|
47
|
+
return this.resolveChildStoreArg(child);
|
|
48
|
+
}
|
|
49
|
+
readOwnField(field) {
|
|
50
|
+
return `${field.readerName}(store)`;
|
|
51
|
+
}
|
|
52
|
+
readOwnFieldLocal(field) {
|
|
53
|
+
return `const auto ${storeFieldLocalName(field.fieldName)} = ${field.readerName}(store);`;
|
|
54
|
+
}
|
|
55
|
+
bindReactiveOwn(request) {
|
|
56
|
+
const deps = [...new Set(request.deps)].map((dep) => cppString(dep)).join(', ');
|
|
57
|
+
const captures = [...request.captures, 'store'].join(', ');
|
|
58
|
+
const disposerVar = request.disposerVar ?? 'disposer';
|
|
59
|
+
if (this.typedParamClass) {
|
|
60
|
+
const lines = [` gea_rc_bind_hub_apply(store, ${disposerVar}, {${deps}}, std::function<void()>([${captures}]() mutable -> void {`];
|
|
61
|
+
for (const field of request.fields)
|
|
62
|
+
lines.push(` ${this.readOwnFieldLocal(field)}`);
|
|
63
|
+
for (const line of request.body)
|
|
64
|
+
lines.push(` ${line}`);
|
|
65
|
+
lines.push(' }));');
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
const lines = [` bindReactiveApply(store, ${disposerVar}, {${deps}}, [${captures}]() mutable -> void {`];
|
|
69
|
+
for (const field of request.fields)
|
|
70
|
+
lines.push(` ${this.readOwnFieldLocal(field)}`);
|
|
71
|
+
for (const line of request.body)
|
|
72
|
+
lines.push(` ${line}`);
|
|
73
|
+
lines.push(' });');
|
|
74
|
+
return lines;
|
|
75
|
+
}
|
|
76
|
+
callOwnMethod(method, args) {
|
|
77
|
+
// Existing event lowering resolves `this.method()` against `store` via the
|
|
78
|
+
// shared_ptr facade; preserved verbatim by the caller in the boxed path.
|
|
79
|
+
// A typed param boxes through gea_cpp_key (the retained tracked proxy)
|
|
80
|
+
// for this genuinely dynamic lookup.
|
|
81
|
+
const receiver = this.typedParamClass ? `gea_cpp_key(${this.rootExpr})` : this.rootExpr;
|
|
82
|
+
return `${receiver}.record_get_literal(${cppString(method)})(${args.join(', ')})`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// ── TypedSelf: fully-typed self-store ReactiveComponent ────────────────────────
|
|
86
|
+
export class TypedSelfFieldAccess {
|
|
87
|
+
typed = true;
|
|
88
|
+
// Crucially, the renderer's store parameter keeps the name `store` in BOTH
|
|
89
|
+
// modes — only its TYPE differs (gea_cpp_value vs shared_ptr<Class>). That way
|
|
90
|
+
// the ~100 `store` references and every `read_X(store)` call in the shared
|
|
91
|
+
// renderer stay byte-identical; the difference lives entirely in (a) the
|
|
92
|
+
// generated read-helper BODIES (typed: `store->field.get()`), (b) this param
|
|
93
|
+
// type, (c) the reactive binding, and (d) method calls.
|
|
94
|
+
rootExpr = 'store';
|
|
95
|
+
paramDecl;
|
|
96
|
+
className;
|
|
97
|
+
// Resolves the store argument for a non-reactive child's mount call (see the
|
|
98
|
+
// interface comment). Injected by selfStoreMountedRenderer, which has the
|
|
99
|
+
// full component/store context this class deliberately doesn't depend on.
|
|
100
|
+
resolveChildStoreArg;
|
|
101
|
+
constructor(className, childStoreArg = () => 'gea_cpp_value::missing()') {
|
|
102
|
+
this.className = sanitizeCppIdentifier(className);
|
|
103
|
+
this.paramDecl = `const std::shared_ptr<${this.className}> &store`;
|
|
104
|
+
this.resolveChildStoreArg = childStoreArg;
|
|
105
|
+
}
|
|
106
|
+
childMountStoreArg(child) {
|
|
107
|
+
if (child.reactiveState)
|
|
108
|
+
return reactiveChildInstanceExpression(child);
|
|
109
|
+
return this.resolveChildStoreArg(child);
|
|
110
|
+
}
|
|
111
|
+
// Same call shape as boxed — `read_X(store)` — but the emitted helper for a
|
|
112
|
+
// self-store is generated typed (returns `store->field.get()`).
|
|
113
|
+
readOwnField(field) {
|
|
114
|
+
return `${field.readerName}(store)`;
|
|
115
|
+
}
|
|
116
|
+
readOwnFieldLocal(field) {
|
|
117
|
+
return `const auto ${storeFieldLocalName(field.fieldName)} = ${this.readOwnField(field)};`;
|
|
118
|
+
}
|
|
119
|
+
// Run the apply once for the initial render, then subscribe it to each
|
|
120
|
+
// dependency's typed Signal. No gea_cpp_value, no string-keyed observe.
|
|
121
|
+
bindReactiveOwn(request) {
|
|
122
|
+
const captures = [...request.captures, 'store'].join(', ');
|
|
123
|
+
const applyBody = [];
|
|
124
|
+
for (const field of request.fields)
|
|
125
|
+
applyBody.push(` ${this.readOwnFieldLocal(field)}`);
|
|
126
|
+
for (const line of request.body)
|
|
127
|
+
applyBody.push(` ${line}`);
|
|
128
|
+
const lines = [
|
|
129
|
+
` {`,
|
|
130
|
+
` auto __gea_apply = [${captures}]() mutable -> void {`,
|
|
131
|
+
...applyBody.map((line) => ` ${line}`),
|
|
132
|
+
` };`,
|
|
133
|
+
` __gea_apply();`,
|
|
134
|
+
];
|
|
135
|
+
for (const dep of [...new Set(request.deps)]) {
|
|
136
|
+
lines.push(` store->${sanitizeCppIdentifier(dep)}.subscribe(__gea_apply);`);
|
|
137
|
+
}
|
|
138
|
+
lines.push(' }');
|
|
139
|
+
return lines;
|
|
140
|
+
}
|
|
141
|
+
callOwnMethod(method, args) {
|
|
142
|
+
return `store->${sanitizeCppIdentifier(method)}(${args.join(', ')})`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function domStyleAccessorInteropSource(): string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// `node.style` — the flat-call `gea_ir::domStyle(node)` accessor the
|
|
2
|
+
// `style` `nativeMemberPropertyGetters` binding in host-shims.ts calls
|
|
3
|
+
// (`property-access-plan-solver.ts`'s `solveHostNativeMemberPropertyRead` only
|
|
4
|
+
// plans a property read whose emit template is exactly `symbol({receiver})` —
|
|
5
|
+
// a dot-call like `({receiver}).style()`, the form this binding used before,
|
|
6
|
+
// has no template slot at all and stays permanently unplanned, exactly like
|
|
7
|
+
// `.content` still does; see that function's own doc comment). Mirrors
|
|
8
|
+
// `domNextSibling` in `cpp-ir.ts` right next to it: a typed, non-boxed
|
|
9
|
+
// result (`gea::embedded::ui::Style` is itself just a thin `{nodeId}` view,
|
|
10
|
+
// same shape as `NodeHandle`), plus a `gea_cpp_value` overload so a
|
|
11
|
+
// value-bridged node (e.g. `event.target.style`) resolves identically to a
|
|
12
|
+
// typed `NodeHandle` receiver.
|
|
13
|
+
//
|
|
14
|
+
// Split into its own module rather than growing `cpp-ir.ts` (already well
|
|
15
|
+
// past the file-size ratchet) — spliced into `canvasInteropSource`'s output
|
|
16
|
+
// alongside the existing `domStyleInteropSource()` call.
|
|
17
|
+
export function domStyleAccessorInteropSource() {
|
|
18
|
+
return [
|
|
19
|
+
'inline gea::embedded::ui::Style domStyle(gea::embedded::ui::NodeHandle node) {',
|
|
20
|
+
' return node.style();',
|
|
21
|
+
'}',
|
|
22
|
+
'',
|
|
23
|
+
'inline gea::embedded::ui::Style domStyle(const gea_cpp_value &node) {',
|
|
24
|
+
' return domStyle(gea::embedded::ui::NodeHandle(nodeIdFromValue(node)));',
|
|
25
|
+
'}',
|
|
26
|
+
'',
|
|
27
|
+
// Flat, receiver-carrying free functions for `style.setProperty(...)` /
|
|
28
|
+
// `style.removeProperty(...)`. These exist ONLY because
|
|
29
|
+
// `driver/host-member-calls.ts`'s `callSymbolFromReceiverTemplate` (the
|
|
30
|
+
// sole live producer for a receiver-carrying host member CALL in the
|
|
31
|
+
// checker-derived pipeline) plans exclusively the flat shape
|
|
32
|
+
// `symbol({receiver}, {arg0}, ...)` and declines any dot-call template
|
|
33
|
+
// (`({receiver}).setProperty({args})` — the shape every OTHER
|
|
34
|
+
// `nativeMemberMethods` dot-call entry in host-shims.ts also uses, e.g.
|
|
35
|
+
// `scrollIntoView`/`connect`/`play` — which that same planner declines
|
|
36
|
+
// identically; those routed through a now-defunct text-emitter consumer
|
|
37
|
+
// this driver never replaced, per that file's own doc comment). Wrapping
|
|
38
|
+
// `Style::setProperty`/`removeProperty` in flat free functions is the
|
|
39
|
+
// only shape this producer can actually plan today.
|
|
40
|
+
'inline void domStyleSetProperty(gea::embedded::ui::Style style, const std::string &property, const std::string &value) {',
|
|
41
|
+
' style.setProperty(property, value);',
|
|
42
|
+
'}',
|
|
43
|
+
'',
|
|
44
|
+
'inline bool domStyleRemoveProperty(gea::embedded::ui::Style style, const std::string &property) {',
|
|
45
|
+
' return style.removeProperty(property);',
|
|
46
|
+
'}',
|
|
47
|
+
''
|
|
48
|
+
];
|
|
49
|
+
}
|
package/dist/cpp-ir.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EmitModule, GeaIrBundleV1, GeaIrConstant } from "./types.js";
|
|
2
|
+
export declare function generateCppIrSource(ir: GeaIrBundleV1, irPath: string | null, modules: EmitModule[], microtasksNamespace?: string): string;
|
|
3
|
+
export declare function irUsesCanvas(ir: GeaIrBundleV1, modules?: readonly EmitModule[]): boolean;
|
|
4
|
+
export declare function generateCppIrNamespaceSource(ir: GeaIrBundleV1, modules: readonly EmitModule[], options?: {
|
|
5
|
+
includeDomInterop?: boolean;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function generateCppIrMountedSource(ir: GeaIrBundleV1, knownGlobalAccessorTypes?: ReadonlyMap<string, string>): string;
|
|
8
|
+
export declare function generateCppIrAssetForwardDeclarations(ir: GeaIrBundleV1): string;
|
|
9
|
+
export declare function collectIrConstants(ir: GeaIrBundleV1): ReadonlyMap<string, GeaIrConstant>;
|
|
10
|
+
/**
|
|
11
|
+
* What the consuming compiler's value model provides.
|
|
12
|
+
*
|
|
13
|
+
* geatsc v1 always has its boxed carrier (`gea_cpp_value`) and its
|
|
14
|
+
* single-precision scalar (`gea_f32`), and the helpers below carry overloads
|
|
15
|
+
* that exist only to accept them. A consumer whose scalars are plain `double`
|
|
16
|
+
* and which never boxes -- geatsc -- has neither type in the translation
|
|
17
|
+
* unit, so those four overloads would name an undeclared type. Passing
|
|
18
|
+
* `boxedValueModel: false` omits them and forward-declares `gea_f32`, which is
|
|
19
|
+
* all the surviving `std::is_same_v<..., gea_f32>` tests need.
|
|
20
|
+
*
|
|
21
|
+
* Everything else in the block is unconditional: the dispatch it encodes --
|
|
22
|
+
* RRGGBBAA colours to native pixels, the typed-array pointer path, the
|
|
23
|
+
* string-versus-colour fill -- is what the ENGINE requires of any caller, and
|
|
24
|
+
* a second copy of it in another compiler would be a second authority over the
|
|
25
|
+
* same question.
|
|
26
|
+
*/
|
|
27
|
+
export interface CanvasInteropOptions {
|
|
28
|
+
readonly boxedValueModel?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function directCanvasInteropSource(usesCanvas: boolean, options?: CanvasInteropOptions): string[];
|