@geastack/core 0.1.26 → 0.1.28
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/README.md +33 -0
- package/include/image.h +2 -4
- package/index.d.ts +2 -0
- package/package.json +4 -4
- package/runtime/compiler.ts +1 -0
- package/scripts/build-gea-vite-geatsc.mjs +2 -1
- package/scripts/gea-native-style-plugin.mjs +31 -0
package/README.md
CHANGED
|
@@ -24,6 +24,39 @@ and include roots to compile, and run its build driver, which bundles the app
|
|
|
24
24
|
with Vite, compiles it with `geatsc` and the Gea plugin, and hands the emitted
|
|
25
25
|
C++ to the target.
|
|
26
26
|
|
|
27
|
+
## Component startup
|
|
28
|
+
|
|
29
|
+
Use `@geastack/core` for applications targeting the native GeaStack hosts.
|
|
30
|
+
`Component` is the component base; `ReactiveComponent` makes its own fields
|
|
31
|
+
reactive, and `Store` holds shared reactive state. The web target supplies the
|
|
32
|
+
matching browser runtime. Direct use of `@geajs/core` belongs to the Gea web
|
|
33
|
+
framework and is not the native application contract.
|
|
34
|
+
|
|
35
|
+
Start loading data or drawing in `onAfterRender()`. The component's `el` is set
|
|
36
|
+
before this hook runs. Field initializers and constructors initialize state;
|
|
37
|
+
code that needs a rendered canvas belongs in the hook.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { ReactiveComponent } from '@geastack/core'
|
|
41
|
+
|
|
42
|
+
class Counter extends ReactiveComponent {
|
|
43
|
+
count = 0
|
|
44
|
+
onAfterRender(): void {
|
|
45
|
+
this.count = 1
|
|
46
|
+
}
|
|
47
|
+
template(): JSX.Element {
|
|
48
|
+
return <div>{this.count}</div>
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Compiler/runtime regressions should use generic language or framework cases.
|
|
54
|
+
Report compiler issues in `geastack/compiler`, host API and application-runtime
|
|
55
|
+
issues in `geastack/core`, Apple rendering/bindings in `geastack/apple`, and web
|
|
56
|
+
target integration in `geastack/simulator`. Contributions should include a
|
|
57
|
+
reproduction and target-specific validation. Lifecycle and representation
|
|
58
|
+
changes need to preserve the shared component and native-type contracts.
|
|
59
|
+
|
|
27
60
|
## Related packages
|
|
28
61
|
|
|
29
62
|
- `@geastack/engine` renders the element tree, `@geastack/host` supplies the
|
package/include/image.h
CHANGED
|
@@ -124,11 +124,9 @@ private:
|
|
|
124
124
|
void materializeDeferred(int id) const;
|
|
125
125
|
int decodeGif(ImageSlot &image, const std::uint8_t *data, int length);
|
|
126
126
|
int decodeStatic(ImageSlot &image, const std::uint8_t *data, int length, bool opaqueHint);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// large covers so they fit the fragmented PSRAM). Fills `image`, returns 0/-1.
|
|
127
|
+
// Native JPEG backends, selected automatically when provided by the target.
|
|
128
|
+
int decodeJpegEsp(ImageSlot &image, const std::uint8_t *data, int length);
|
|
130
129
|
int decodeJpegTjpgd(ImageSlot &image, const std::uint8_t *data, int length);
|
|
131
|
-
#endif
|
|
132
130
|
int decodeNextGifFrame(ImageSlot &image);
|
|
133
131
|
// dispose() body without taking slotMutex_ (callers hold it).
|
|
134
132
|
void disposeLocked(int id);
|
package/index.d.ts
CHANGED
|
@@ -746,6 +746,8 @@ export class Component<RootElement extends GeaElement = GeaElement, Props = void
|
|
|
746
746
|
// same thing as the mounted host node `el` points at. `null` is the base's
|
|
747
747
|
// own stub answer in `runtime/compiler.ts`.
|
|
748
748
|
template(props?: Props): GeaJsxElement | null
|
|
749
|
+
/** Called after the rendered root is available in el; start loading or drawing here. */
|
|
750
|
+
onAfterRender(): void
|
|
749
751
|
}
|
|
750
752
|
|
|
751
753
|
// Opt-in base for a component that holds its OWN reactive state — its instance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "GeaStack app API, reactivity headers, runtime sources, and type declarations.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@babel/parser": "^7.23.0",
|
|
61
61
|
"@babel/traverse": "^7.23.0",
|
|
62
62
|
"@babel/types": "^7.23.0",
|
|
63
|
-
"@geajs/core": "1.
|
|
64
|
-
"@geajs/vite-plugin": "1.
|
|
63
|
+
"@geajs/core": "1.5.1",
|
|
64
|
+
"@geajs/vite-plugin": "1.5.0",
|
|
65
65
|
"@geastack/compiler": "^1.0.15",
|
|
66
|
-
"@geastack/geatsc-plugin-gea": "^0.1.
|
|
66
|
+
"@geastack/geatsc-plugin-gea": "^0.1.8",
|
|
67
67
|
"opentype.js": "^2.0.0",
|
|
68
68
|
"vite": "^8.0.0"
|
|
69
69
|
}
|
package/runtime/compiler.ts
CHANGED
|
@@ -22,6 +22,7 @@ export class Component<RootElement extends GeaElement = GeaElement, Props = void
|
|
|
22
22
|
template(_props?: Props): GeaJsxElement | null {
|
|
23
23
|
return null
|
|
24
24
|
}
|
|
25
|
+
onAfterRender(): void {}
|
|
25
26
|
// NB: deliberately NO `render` here. `render` is synthesised onto compiled
|
|
26
27
|
// components by the embedded compiler. Declaring it on the base looks tidier
|
|
27
28
|
// (it would let mount() drop its cast) but it BREAKS embedded codegen: once
|
|
@@ -493,6 +493,7 @@ function writeCompatViteConfig({ configPath, compatSrcDir, appDir, entry, viteOu
|
|
|
493
493
|
.join('\n')
|
|
494
494
|
const config = `import { resolve } from 'node:path'
|
|
495
495
|
import { geaPlugin } from ${q(geaPluginResolved)}
|
|
496
|
+
import { geaNativeStylePlugin } from ${q(path.join(coreRoot, 'scripts/gea-native-style-plugin.mjs'))}
|
|
496
497
|
import { geaAppleNativeModuleAliases, geaModuleGraphPlugins } from ${q(moduleGraphPluginPath)}
|
|
497
498
|
|
|
498
499
|
const root = ${q(compatSrcDir)}
|
|
@@ -510,7 +511,7 @@ export default {
|
|
|
510
511
|
define: {
|
|
511
512
|
${defineEntries}
|
|
512
513
|
},
|
|
513
|
-
plugins: [geaPlugin({ ir: { enabled: true, outFile: ${q(geaIrPath)} } }), ...geaModuleGraph],
|
|
514
|
+
plugins: [geaNativeStylePlugin({ runtimeEntry: ${q(compilerRuntimeEntry)} }), geaPlugin({ ir: { enabled: true, outFile: ${q(geaIrPath)} } }), ...geaModuleGraph],
|
|
514
515
|
resolve: {
|
|
515
516
|
alias: [
|
|
516
517
|
${compilerRuntimeAlias}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
/** Native lengths are raw numbers; only an authored CSS unit may introduce scaling. */
|
|
5
|
+
export function geaNativeStylePlugin({ runtimeEntry }) {
|
|
6
|
+
if (!runtimeEntry) throw new Error('Native Gea styles require the typed @geajs/core source entry')
|
|
7
|
+
const sourceRoot = path.dirname(fs.realpathSync(runtimeEntry))
|
|
8
|
+
const serializer = path.join(sourceRoot, 'runtime/style-value.ts')
|
|
9
|
+
return {
|
|
10
|
+
name: 'geastack-native-style-units',
|
|
11
|
+
enforce: 'pre',
|
|
12
|
+
// Keep all compiler-generated runtime imports on the same typed source tree.
|
|
13
|
+
// Aliasing only the root left compiler-runtime on the browser dist path.
|
|
14
|
+
resolveId(id) {
|
|
15
|
+
const name = id === '@geajs/core' ? 'index' : id.startsWith('@geajs/core/') ? id.slice('@geajs/core/'.length) : null
|
|
16
|
+
if (name === null) return null
|
|
17
|
+
return [path.join(sourceRoot, `${name}.ts`), path.join(sourceRoot, name, 'index.ts')].find(entry => fs.existsSync(entry)) || null
|
|
18
|
+
},
|
|
19
|
+
load(id) {
|
|
20
|
+
if (id.split('?')[0] !== serializer) return null
|
|
21
|
+
// This module is the browser serialization boundary, not the JSX IR.
|
|
22
|
+
// Replacing it here preserves numeric values in the native IR and prevents
|
|
23
|
+
// browser px defaults from reaching native runtime-backed components/h().
|
|
24
|
+
return `export function styleProp(key: string): string {
|
|
25
|
+
return key.startsWith('--') ? key : key.replace(/[A-Z]/g, c => '-' + c.toLowerCase())
|
|
26
|
+
}
|
|
27
|
+
export function styleValue(_property: string, value: unknown): string { return String(value) }
|
|
28
|
+
`
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}
|