@geastack/core 0.1.23

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.
Files changed (73) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -0
  3. package/app_frame_perf.cpp +77 -0
  4. package/css.d.ts +1 -0
  5. package/events.cpp +67 -0
  6. package/gea_app_entry.cpp +317 -0
  7. package/gea_sources.mjs +126 -0
  8. package/gea_sources.sh +36 -0
  9. package/include/app.h +60 -0
  10. package/include/apps.h +46 -0
  11. package/include/audio.h +90 -0
  12. package/include/ble.h +212 -0
  13. package/include/bluetooth/hid_profile.h +92 -0
  14. package/include/camera.h +107 -0
  15. package/include/canvas.h +290 -0
  16. package/include/display.h +390 -0
  17. package/include/display_present.h +869 -0
  18. package/include/event.h +32 -0
  19. package/include/events.h +116 -0
  20. package/include/gea/embedded.h +13 -0
  21. package/include/gea/reactive_runtime.h +32 -0
  22. package/include/gea.h +14 -0
  23. package/include/gea_perf_config.h +96 -0
  24. package/include/geaos/abi.h +165 -0
  25. package/include/geolocation.h +126 -0
  26. package/include/gpio.h +61 -0
  27. package/include/graphics/font.h +122 -0
  28. package/include/i2c.h +20 -0
  29. package/include/image.h +156 -0
  30. package/include/imu.h +23 -0
  31. package/include/input.h +33 -0
  32. package/include/memory.h +52 -0
  33. package/include/pixel.h +907 -0
  34. package/include/platform/file_cache.h +18 -0
  35. package/include/power.h +11 -0
  36. package/include/runtime.h +83 -0
  37. package/include/services/app_runner.h +10 -0
  38. package/include/services/app_state.h +14 -0
  39. package/include/services/battery_service.h +12 -0
  40. package/include/services/bluetooth_service.h +13 -0
  41. package/include/services/diagnostics.h +76 -0
  42. package/include/services/diagnostics_platform.h +54 -0
  43. package/include/services/frame_scheduler.h +71 -0
  44. package/include/services/mirror.h +49 -0
  45. package/include/services/network_services.h +25 -0
  46. package/include/services/ota.h +32 -0
  47. package/include/services/runtime_log.h +11 -0
  48. package/include/services/storage_service.h +26 -0
  49. package/include/touch.h +38 -0
  50. package/include/ui/signal.h +149 -0
  51. package/include/wifi.h +67 -0
  52. package/index.d.ts +1940 -0
  53. package/jsx.d.ts +1 -0
  54. package/package.json +70 -0
  55. package/runtime/ble.ts +49 -0
  56. package/runtime/color.ts +21 -0
  57. package/runtime/compiler.ts +43 -0
  58. package/runtime/host.ts +1083 -0
  59. package/runtime/images.ts +129 -0
  60. package/runtime/primitives.ts +49 -0
  61. package/runtime-surface.ts +180 -0
  62. package/runtime.cpp +431 -0
  63. package/runtime.ts +34 -0
  64. package/scripts/build-gea-vite-geatsc.mjs +4514 -0
  65. package/scripts/dotenv-defines.mjs +98 -0
  66. package/scripts/gea-bundle-type-hints.mjs +546 -0
  67. package/scripts/gea-embedded-compat-staging.mjs +17 -0
  68. package/scripts/gea-embedded-compat-transform.mjs +427 -0
  69. package/scripts/gea-vite-module-graph-plugin.mjs +578 -0
  70. package/scripts/generate-gea-embedded-assets.mjs +296 -0
  71. package/scripts/generate-gea-embedded-fonts.mjs +1252 -0
  72. package/scripts/generate-installed-app-plan.mjs +55 -0
  73. package/scripts/native-object-cache.sh +244 -0
@@ -0,0 +1,129 @@
1
+ import type { GeaEmbeddedImage } from '../index'
2
+
3
+ export type LoadImageOptions = {
4
+ opaque?: boolean
5
+ }
6
+
7
+ declare const image: {
8
+ loadBytes(bytes: Uint8Array): number
9
+ loadBytesOpaque(bytes: Uint8Array): number
10
+ // Read + decode an image directly from a persistent-cache file (e.g. microSD).
11
+ // Returns a slot id, or -1 when the file is missing/undecodable.
12
+ loadFile(path: string): number
13
+ loadFileOpaque(path: string): number
14
+ // Decode a BUILD-EMBEDDED asset by its path relative to the app directory
15
+ // (e.g. 'assets/icons/00-music.png'). Returns a slot id, or -1 when no such
16
+ // asset was bundled.
17
+ loadAssetPath(path: string): number
18
+ // Save raw bytes to a persistent-cache file (creating parent dirs). Returns
19
+ // true on success, false when no persistent storage is available.
20
+ writeFile(path: string, bytes: Uint8Array): boolean
21
+ // Read a whole file's raw bytes (e.g. a .pmtiles on microSD). Empty when the
22
+ // file is missing or no storage is mounted.
23
+ readFile(path: string): Uint8Array
24
+ // Read a .pmtiles archive flashed into the spare ota_1 partition. Empty when
25
+ // none present (or off-device).
26
+ readMapArchive(): Uint8Array
27
+ // Read a byte range [offset, offset+length) from a file without loading it
28
+ // all. Empty when absent / no storage.
29
+ readFileRange(path: string, offset: number, length: number): Uint8Array
30
+ // List a directory's regular-file names (non-recursive), newline-joined.
31
+ // Empty string when the directory is missing or no storage is mounted.
32
+ listFiles(path: string): string
33
+ // Synchronous HTTP GET over WiFi.
34
+ fetchBytes(url: string): Uint8Array
35
+ fetchText(url: string): string
36
+ // Wrap a decoded slot id in the native `GeaEmbeddedImage` handle, snapshotting
37
+ // its immutable dimensions. Lowering this through the host keeps the returned
38
+ // value a concrete struct (no boxed record), so callers and any
39
+ // `GeaEmbeddedImage[]` cache stay fully typed.
40
+ make(id: number): GeaEmbeddedImage
41
+ }
42
+
43
+ export function loadImage(src: Uint8Array, options?: LoadImageOptions): GeaEmbeddedImage {
44
+ const opaque = options ? options.opaque || false : false
45
+ return loadImageWithOpaque(src, opaque)
46
+ }
47
+
48
+ // Scalar fast path for embedded callers whose opacity is already known. This
49
+ // keeps the hot image decode call native without constructing an options
50
+ // record at the C++ boundary.
51
+ export function loadImageWithOpaque(src: Uint8Array, opaque: boolean): GeaEmbeddedImage {
52
+ const id = opaque ? image.loadBytesOpaque(src) : image.loadBytes(src)
53
+ return image.make(id)
54
+ }
55
+
56
+ // Load + decode an image from a persistent-cache file path (e.g. an SD-card tile
57
+ // cache). The returned handle has width === 0 when the file is absent or fails
58
+ // to decode, so callers treat that as a cache miss and fetch over the network.
59
+ export function loadImageFile(path: string, options?: LoadImageOptions): GeaEmbeddedImage {
60
+ const opaque = options ? options.opaque || false : false
61
+ const id = opaque ? image.loadFileOpaque(path) : image.loadFile(path)
62
+ return image.make(id)
63
+ }
64
+
65
+ // Load + decode a BUILD-EMBEDDED asset by its path relative to the app
66
+ // directory (e.g. 'assets/icons/00-music.png'), the same bytes `<img src>`
67
+ // would use. The JSX path lowers a string LITERAL straight to the generated
68
+ // `gea_asset_<path>` symbol, which is unavailable to a canvas app that picks
69
+ // among N bundled images at runtime -- this resolves the path through the
70
+ // generated lookup table instead. Decoding is deferred to first draw and
71
+ // memoized per asset, so calling it repeatedly for the same path is free.
72
+ // The returned handle has `width === 0` when no such asset was bundled.
73
+ export function loadAssetImage(path: string): GeaEmbeddedImage {
74
+ // Two statements, not a nested call: the host-object lowering only qualifies
75
+ // the OUTERMOST `image.<method>` receiver, so `image.make(image.loadX(...))`
76
+ // emits an unqualified inner `image` and fails to compile.
77
+ const id = image.loadAssetPath(path)
78
+ return image.make(id)
79
+ }
80
+
81
+ // Persist raw bytes to the file cache (e.g. /sdcard/...). Returns false when no
82
+ // writable storage is mounted, so callers can ignore the result.
83
+ export function writeCacheFile(path: string, bytes: Uint8Array): boolean {
84
+ return image.writeFile(path, bytes)
85
+ }
86
+
87
+ // Read a whole file's raw bytes from the persistent cache (e.g. a .pmtiles
88
+ // pushed to /sdcard). Returns an empty Uint8Array when absent / no storage.
89
+ export function readCacheFile(path: string): Uint8Array {
90
+ return image.readFile(path)
91
+ }
92
+
93
+ // Read a .pmtiles archive flashed into the spare ota_1 partition over USB
94
+ // (esptool) — a reliable data path independent of the SD card. Empty when none.
95
+ export function readMapArchive(): Uint8Array {
96
+ return image.readMapArchive()
97
+ }
98
+
99
+ // Read a byte range from a persistent-cache file (e.g. one tile out of a
100
+ // .pmtiles on microSD) without loading the whole file.
101
+ export function readFileRange(path: string, offset: number, length: number): Uint8Array {
102
+ return image.readFileRange(path, offset, length)
103
+ }
104
+
105
+ // List a directory's regular-file names (non-recursive) from persistent storage
106
+ // (e.g. the EPUBs in /sdcard/books). Empty array when the directory is missing
107
+ // or no storage is mounted.
108
+ export function listCacheFiles(path: string): string[] {
109
+ const joined = image.listFiles(path)
110
+ if (joined.length == 0) return []
111
+ return joined.split('\n')
112
+ }
113
+
114
+ // Synchronous HTTP GET over WiFi — body as bytes (e.g. an MVT tile) or text
115
+ // (e.g. a TileJSON). Empty when WiFi is down / the request fails.
116
+ export function fetchBytes(url: string): Uint8Array {
117
+ return image.fetchBytes(url)
118
+ }
119
+
120
+ export function fetchText(url: string): string {
121
+ return image.fetchText(url)
122
+ }
123
+
124
+ // Wrap an already-decoded image-store slot id (e.g. one delivered by the async
125
+ // tile loader) in the native GeaEmbeddedImage handle. width === 0 when the id
126
+ // is invalid.
127
+ export function imageFromId(id: number): GeaEmbeddedImage {
128
+ return image.make(id)
129
+ }
@@ -0,0 +1,49 @@
1
+ import { Component } from './compiler'
2
+
3
+ /**
4
+ * Whatever the `document` in scope hands back for an id, minus the miss.
5
+ *
6
+ * Not a named element type. This file is compiled under two different worlds:
7
+ * a project that includes lib.dom (`document` is lib.dom's, answering
8
+ * `HTMLElement`) and one that does not (`document` is the framework's,
9
+ * answering the framework's `Element`). Naming either one is wrong under the
10
+ * other, and naming `HTMLElement` in particular made the DOM library a build
11
+ * requirement of every pipeline that compiles this file.
12
+ */
13
+ type MountRoot = NonNullable<ReturnType<typeof document.getElementById>>
14
+ // Typed as a component constructor — no `any`. geatsc lowers a `new () => T`
15
+ // parameter to an abbreviated-template forwarding reference, so this function is
16
+ // instantiated per call site and `new component()` constructs the concrete app
17
+ // class natively (no boxing, no dynamic construct path).
18
+ //
19
+ // The parameter is named `component`, NOT `App`: geatsc emits user classes into
20
+ // flat global C++ scope, so a parameter named after a common root class would
21
+ // shadow it at this construction site.
22
+ export function mount<RootComponent extends Component>(component: new () => RootComponent): void {
23
+ const root = document.getElementById('app')
24
+ if (!root) throw new Error('gea-embedded mount root #app was not found')
25
+ const instance = new component()
26
+ // `render` is synthesised onto compiled components and is not on the base
27
+ // `Component` type (see compiler.ts for why it must not be), so reach it
28
+ // through a local structural cast rather than widening the parameter to `any`.
29
+ //
30
+ // The cast goes through `unknown` because the two types genuinely do not
31
+ // overlap: the base declares no `render` at all, so a direct assertion is one
32
+ // TypeScript rightly rejects. It was only ever accepted while this file went
33
+ // unchecked -- a pipeline resolving `@geastack/core` to `index.d.ts` never
34
+ // compiles it.
35
+ //
36
+ // The parameter is spelled off `root` itself rather than by name. It used to
37
+ // read `HTMLElement` -- a lib.dom global this framework never declares -- and
38
+ // that one word made the DOM library a build requirement of every pipeline
39
+ // that compiles this file, which then merged lib.dom's `Window`/`globalThis`
40
+ // into apps that had declared their own. Naming the framework's `Element`
41
+ // instead is no better in the other direction: under a project that DOES
42
+ // include lib.dom, `document` is lib.dom's and its `getElementById` answers
43
+ // `HTMLElement`, which is not assignable to it. `typeof root` is neither: it
44
+ // is whatever `document` in scope actually answers, which is the only correct
45
+ // answer in both. Read off the METHOD rather than off `root`: `typeof root`
46
+ // inside this assertion really is circular, because narrowing makes `root`'s
47
+ // type here depend on the assertion being resolved first.
48
+ ;(instance as unknown as { render(root: MountRoot, depth: number): void }).render(root, 1)
49
+ }
@@ -0,0 +1,180 @@
1
+ export * from './runtime/compiler'
2
+ export * from './runtime/host'
3
+ export * from './runtime/ble'
4
+ export * from './runtime/images'
5
+ export * from './runtime/color'
6
+ export { mount } from './runtime/primitives'
7
+ // The embedded/geatsc pipeline aliases '@geastack/core' to runtime.ts, so an
8
+ // app's `import type { GeaCanvasElement, GeaEmbeddedImage } from
9
+ // '@geastack/core'` resolves HERE, not through the package's index.d.ts.
10
+ // Without these re-exports those names silently fail to resolve, the checker
11
+ // types the annotated binding `any`, and geatsc lowers it to a boxed
12
+ // `gea_cpp_value` instead of the typed native handle (NodeHandle /
13
+ // gea::host::GeaEmbeddedImage) the annotation exists to pin.
14
+ export type {
15
+ GeaNode,
16
+ GeaElement,
17
+ GeaCanvasElement,
18
+ GeaCameraElement,
19
+ GeaEmbeddedImage,
20
+ FetchResponse,
21
+ TouchSample,
22
+ // Also a lib.dom global. An app annotating a context `CanvasRenderingContext2D`
23
+ // and resolving it here got the DOM one (or nothing), not the framework's --
24
+ // which declares the whole embedded surface (`fillCirclesRgb565`, `flush`,
25
+ // `beginBatch`) that the DOM interface has never heard of.
26
+ CanvasRenderingContext2D,
27
+ Element,
28
+ } from './index'
29
+
30
+ /**
31
+ * Every remaining type `index.d.ts` publishes, re-exported so the name an app
32
+ * imports resolves whichever file the specifier landed on.
33
+ *
34
+ * The package answers `"."` with two files -- `types: ./index.d.ts` for an
35
+ * editor, `default: ./runtime.ts` (which is this module) for anything that
36
+ * compiles the framework from source. A name declared only in the first is a
37
+ * name the second does not have, and an app that imports it there gets
38
+ * `Module '"@geastack/core"' has no exported member 'X'` -- after which the
39
+ * checker types the annotated binding `any` and a compiler lowers it to a
40
+ * boxed dynamic value instead of the native handle the annotation exists to
41
+ * pin. `VirtualListElement` cost `examples/virtual-list` 25 boxed values
42
+ * exactly that way.
43
+ *
44
+ * The block above states the names whose resolution was already known to
45
+ * matter, with the reasoning for each; this states the rest, derived by
46
+ * DIFFERENCE rather than by hand -- every type-only export of `index.d.ts`
47
+ * that this surface did not already carry. Adding them one at a time as each
48
+ * app trips over one is how the gap appeared in the first place.
49
+ *
50
+ * Type-only, deliberately. `index.d.ts` also declares values (`fetchAsync`
51
+ * and its siblings, the two brand constants) that nothing here defines;
52
+ * re-exporting one of those would make a program that calls it compile and
53
+ * then fail to link, which is worse than the honest "no exported member" it
54
+ * gets today.
55
+ */
56
+ export type {
57
+ AccelerometerController,
58
+ AccelerometerReading,
59
+ AppsController,
60
+ AudioBuffer,
61
+ AudioBufferSourceNode,
62
+ AudioConstructor,
63
+ AudioContext,
64
+ AudioContextConstructor,
65
+ AudioController,
66
+ AudioDestinationNode,
67
+ AudioParam,
68
+ AudioProps,
69
+ BatteryController,
70
+ BluetoothConfig,
71
+ BluetoothConnections,
72
+ BluetoothController,
73
+ BluetoothHidHost,
74
+ BluetoothKeyboard,
75
+ BluetoothMidi,
76
+ BluetoothMouse,
77
+ ButtonProps,
78
+ CameraController,
79
+ CameraProps,
80
+ CanvasProps,
81
+ ClassMap,
82
+ ClassValue,
83
+ ClockController,
84
+ DOMTokenList,
85
+ DataAttributes,
86
+ DeviceControlController,
87
+ DisplayController,
88
+ DisplayEpaperRefreshConfig,
89
+ DisplayFlushConfig,
90
+ DisplayMemoryConfig,
91
+ DisplayOrientation,
92
+ DisplayOrientationSupport,
93
+ DisplayPixelFormat,
94
+ Document,
95
+ EmbeddedDefaults,
96
+ Event,
97
+ EventTarget,
98
+ FetchHeaders,
99
+ FetchHeadersInit,
100
+ FetchRequestInit,
101
+ GeaAudioBlob,
102
+ GeaEventMap,
103
+ GeaJsxElement,
104
+ GeaJsxElementChildrenAttribute,
105
+ GeaLocalStorage,
106
+ GeaWindow,
107
+ GeolocationController,
108
+ GeolocationCoordinates,
109
+ GeolocationPosition,
110
+ GeolocationPositionError,
111
+ HTMLAudioElement,
112
+ HttpModule,
113
+ HttpRequestHandler,
114
+ HttpServer,
115
+ ImageProps,
116
+ ImageSource,
117
+ IncomingMessage,
118
+ InputController,
119
+ InputElementProps,
120
+ InputEvent,
121
+ InputEventTarget,
122
+ KeyEvent,
123
+ MediaDevices,
124
+ MediaRecorder,
125
+ MediaRecorderConstructor,
126
+ MediaRecorderDataAvailableEvent,
127
+ MediaRecorderOptions,
128
+ MediaRecorderState,
129
+ MediaStream,
130
+ MediaStreamConstraints,
131
+ MediaStreamConstructor,
132
+ MediaStreamTrack,
133
+ MemoryController,
134
+ NativeButtonProps,
135
+ NativeEventAttributes,
136
+ NativeInputElementProps,
137
+ NativeTextAreaElementProps,
138
+ NativeTouchEventAttributes,
139
+ NativeViewProps,
140
+ NativeVirtualListProps,
141
+ Node,
142
+ NotifyController,
143
+ OscillatorNode,
144
+ OscillatorType,
145
+ PointerEvent,
146
+ PositionOptions,
147
+ PressEvent,
148
+ PressEventArgument,
149
+ PressEventTarget,
150
+ PressHandler,
151
+ ProfilerController,
152
+ RTCConfiguration,
153
+ RTCIceCandidateInit,
154
+ RTCIceServer,
155
+ RTCPeerConnectionConstructor,
156
+ RTCPeerConnectionIceEvent,
157
+ RTCPeerConnectionInstance,
158
+ RTCSessionDescriptionInit,
159
+ RTCTrackEvent,
160
+ RotaryEvent,
161
+ RotaryEventHandler,
162
+ ScrollIntoViewOptions,
163
+ Style,
164
+ StyleBox,
165
+ StyleLength,
166
+ TextAreaElementProps,
167
+ TextProps,
168
+ TouchEvent,
169
+ TouchEventHandler,
170
+ TouchHost,
171
+ TouchPoint,
172
+ ViewProps,
173
+ VirtualListElement,
174
+ WebSocketCloseEvent,
175
+ WebSocketConstructor,
176
+ WebSocketErrorEvent,
177
+ WebSocketInstance,
178
+ WebSocketMessageEvent,
179
+ WiFiController,
180
+ } from './index'