@geastack/geatsc-plugin-gea 0.1.21 → 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.
@@ -47,7 +47,7 @@ export function addNodeAuxFeatures(file, text, features, isNumeric) {
47
47
  const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, /\.[jt]sx$/i.test(file) ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
48
48
  const unknown = () => addUnknownNodeAux(features);
49
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))
50
+ if (/^(?:addEventListener|removeEventListener|setEventListener|dispatchEvent|on[A-Z].*|on(?:click|pointer.*|touch.*|input|keydown|keyup|scroll)|click|touchstart|touchmove|touchend|pointerdown|pointermove|pointerup|input|keydown|keyup|scroll)$/.test(name))
51
51
  features.add('node-listeners');
52
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
53
  features.add('node-attributes');
package/dist/analyze.js CHANGED
@@ -201,11 +201,81 @@ function addBindingsForEmbeddedHostNames(text, bindings) {
201
201
  if (documentHostRegex.test(text))
202
202
  bindings.add('dom');
203
203
  }
204
+ function applicationDir(entry) {
205
+ let dir = path.dirname(path.resolve(entry));
206
+ for (;;) {
207
+ if (fs.existsSync(path.join(dir, 'package.json')))
208
+ return dir;
209
+ const parent = path.dirname(dir);
210
+ if (parent === dir)
211
+ return null;
212
+ dir = parent;
213
+ }
214
+ }
215
+ function buildSourceAliases(entry) {
216
+ const appDir = applicationDir(entry);
217
+ if (!appDir)
218
+ return [];
219
+ const aliases = [];
220
+ let geaThreejs = false;
221
+ try {
222
+ const manifest = JSON.parse(fs.readFileSync(path.join(appDir, 'package.json'), 'utf8'));
223
+ geaThreejs = manifest.gea?.geaThreejs === true;
224
+ const raw = manifest.gea?.moduleAliases;
225
+ if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
226
+ for (const [specifier, target] of Object.entries(raw)) {
227
+ if (typeof target !== 'string' || !target)
228
+ continue;
229
+ const replacement = path.resolve(appDir, target);
230
+ aliases.push({ find: specifier, replacement: () => replacement });
231
+ }
232
+ }
233
+ }
234
+ catch {
235
+ // An unreadable manifest names no aliases; the build reports it.
236
+ }
237
+ // The three.js redirect is opt-in, exactly as in the build.
238
+ if (!geaThreejs)
239
+ return aliases;
240
+ const appRequire = createRequire(path.join(appDir, 'package.json'));
241
+ let geaThreeSrcDir = '';
242
+ try {
243
+ geaThreeSrcDir = path.join(path.dirname(fs.realpathSync(appRequire.resolve('@geastack/gea-threejs/package.json'))), 'src');
244
+ }
245
+ catch {
246
+ return aliases;
247
+ }
248
+ aliases.push({ find: /^three$/, replacement: () => path.join(geaThreeSrcDir, 'Three.ts') });
249
+ aliases.push({ find: /^three\/src\/(.+)\.js$/, replacement: (m) => path.join(geaThreeSrcDir, `${m[1]}.ts`) });
250
+ try {
251
+ appRequire.resolve('troika-three-text');
252
+ const troika = fs.realpathSync(appRequire.resolve('@geastack/native-webgl-angle/troika-three-text'));
253
+ aliases.push({ find: /^troika-three-text$/, replacement: () => troika });
254
+ }
255
+ catch {
256
+ // No troika, or no native text module: the build fails on the latter itself.
257
+ }
258
+ return aliases;
259
+ }
260
+ function aliasedModule(aliases, specifier) {
261
+ for (const alias of aliases) {
262
+ if (typeof alias.find === 'string') {
263
+ if (specifier === alias.find)
264
+ return alias.replacement([specifier]);
265
+ continue;
266
+ }
267
+ const match = specifier.match(alias.find);
268
+ if (match)
269
+ return alias.replacement(match);
270
+ }
271
+ return null;
272
+ }
204
273
  function discoverSourceFiles(entry) {
205
274
  const visited = new Set();
206
275
  const files = [];
207
276
  let unknown = false;
208
277
  let runtimeUnknown = false;
278
+ const aliases = buildSourceAliases(entry);
209
279
  function visit(file) {
210
280
  const resolved = path.resolve(file);
211
281
  // An entry that is a directory (a configure run without app metadata)
@@ -241,7 +311,8 @@ function discoverSourceFiles(entry) {
241
311
  // external code may supply styles/components we cannot inspect here.
242
312
  if (/^(?:gea-embedded|@geastack\/(?:core|engine)|@geajs\/core)(?:\/|$)/.test(specifier))
243
313
  continue;
244
- const dependency = specifier.startsWith('.') ? resolveRelativeModule(resolved, specifier) : resolvePackageModule(resolved, specifier);
314
+ const aliased = aliasedModule(aliases, specifier);
315
+ const dependency = aliased ?? (specifier.startsWith('.') ? resolveRelativeModule(resolved, specifier) : resolvePackageModule(resolved, specifier));
245
316
  if (dependency)
246
317
  visit(dependency);
247
318
  else
@@ -1212,7 +1212,7 @@ function lowerRootEvent(varName, slot, storeFields = [], storeMethods = [], fiel
1212
1212
  // `document` (no body delegation, no containsNode/currentTarget bookkeeping)
1213
1213
  // and the runtime dispatches them off-tree.
1214
1214
  const isDocumentLevel = eventType === 'rotary' ||
1215
- (eventType === 'keydown' && rootTag !== undefined && rootTag.toLowerCase() !== 'input');
1215
+ ((eventType === 'keydown' || eventType === 'keyup') && rootTag !== undefined && rootTag.toLowerCase() !== 'input');
1216
1216
  if (isDocumentLevel) {
1217
1217
  const docCaptures = [
1218
1218
  ...(hoisted.handler.some((line) => new RegExp(`\\b${varName}\\b`).test(line)) ? [varName] : []),
@@ -965,6 +965,7 @@ function lowerHostFacadeCall(context, path, args) {
965
965
  'Camera.draw': { target: 'gea::host::Camera.draw', hints: ['number', 'number', 'number', 'number'] },
966
966
  'Camera.capture': { target: 'gea::host::Camera.capture', optionsRecord: true },
967
967
  'Camera.captureMirrored': { target: 'gea::host::Camera.captureMirrored' },
968
+ 'Camera.captureFrame': { target: 'gea::host::Camera.captureFrame' },
968
969
  'Camera.setFlash': { target: 'gea::host::Camera.setFlash', hints: ['string'] },
969
970
  'Camera.setZoom': { target: 'gea::host::Camera.setZoom', hints: ['number'] },
970
971
  'Camera.setMirror': { target: 'gea::host::Camera.setMirror', hints: ['boolean'] },
@@ -35,6 +35,7 @@ const geaBase64Declarations = [...geaHostDeclarations, '#include "gea/base64-run
35
35
  export const geaVirtualListRowHeightEmit = 'static_cast<double>(gea::embedded::ui::VirtualListRenderer::rowHeight(({receiver}).id()))';
36
36
  export const geaHostHeaderDeclarationToken = '__gea_cpp_api_header';
37
37
  const geaImageHostMethods = [
38
+ 'removeFile',
38
39
  'loadBytes',
39
40
  'loadBytesOpaque',
40
41
  'draw',
@@ -60,12 +61,13 @@ const geaGeolocationHostMethods = [
60
61
  'clearWatch',
61
62
  ];
62
63
  const geaInputHostMethods = ['consumeBackButton'];
64
+ const geaUartHostMethods = ['open', 'isOpen', 'close', 'read', 'write', 'available', 'writable'];
63
65
  const geaGpioHostMethods = ['configureOutput', 'configureInput', 'write', 'read'];
64
66
  const geaLedHostMethods = ['set', 'off', 'attach', 'setPixel', 'show', 'detach'];
65
- const geaClockHostMethods = ['epochMs'];
67
+ const geaClockHostMethods = ['epochMs', 'setEpochMs'];
66
68
  const geaProfilerHostMethods = ['nowUs', 'nowCycles'];
67
69
  const geaStorageHostMethods = ['getItem', 'setItem', 'removeItem', 'clear', 'key'];
68
- const geaBatteryHostMethods = ['level'];
70
+ const geaBatteryHostMethods = ['level', 'charging'];
69
71
  const geaNotifyHostMethods = ['text', 'seq'];
70
72
  const geaDeviceControlHostMethods = ['exec'];
71
73
  const geaNativeBenchHostMethods = [
@@ -138,6 +140,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
138
140
  ...geaTouchHostMethods.map((method) => [`gea::host::touch.${method}`, geaHostDeclarations]),
139
141
  ...geaMemoryHostMethods.map((method) => [`gea::host::Memory.${method}`, geaHostDeclarations]),
140
142
  ...geaInputHostMethods.map((method) => [`gea::host::Input.${method}`, geaHostDeclarations]),
143
+ ...geaUartHostMethods.map((method) => [`gea::host::Uart.${method}`, geaHostDeclarations]),
141
144
  ...geaGpioHostMethods.map((method) => [`gea::host::Gpio.${method}`, geaHostDeclarations]),
142
145
  ...geaLedHostMethods.map((method) => [`gea::host::Led.${method}`, geaHostDeclarations]),
143
146
  ...geaClockHostMethods.map((method) => [`gea::host::Clock.${method}`, geaHostDeclarations]),
@@ -164,7 +167,8 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
164
167
  ['gea::host::fetchRelease', geaHostDeclarations],
165
168
  ['gea::host::websocket::create_handle', geaHostDeclarations],
166
169
  ['gea::host::WebSocket', geaHostDeclarations],
167
- ['gea::host::http::create_server', geaHostDeclarations],
170
+ ['gea::host::http::create_typed_server', [...geaHostDeclarations, '#include "gea/http-native-runtime.h"']],
171
+ ['gea::host::Haptics.vibrate', geaHostDeclarations],
168
172
  ['gea::host::HttpServer', geaHostDeclarations],
169
173
  ['gea::host::media::get_user_media_audio', geaHostDeclarations],
170
174
  ...geaGeolocationHostMethods.map((method) => [`gea::host::navigator.geolocation.${method}`, geaHostDeclarations]),
@@ -188,6 +192,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
188
192
  ['gea::host::sharedAudioContext()', geaHostDeclarations],
189
193
  ['gea::host::sharedAudioContext().createOscillator', geaHostDeclarations],
190
194
  ['gea::host::sharedAudioContext().createBufferSource', geaHostDeclarations],
195
+ ['gea::host::sharedAudioContext().createBuffer', geaHostDeclarations],
191
196
  ['gea::host::sharedAudioContext().decodeAudioData', geaHostDeclarations],
192
197
  ['gea::host::sharedAudioContext().currentTime', geaHostDeclarations],
193
198
  ['gea::host::sharedAudioContext().destination', geaHostDeclarations],
@@ -325,6 +330,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
325
330
  ['gea::host::Camera.draw', geaHostDeclarations],
326
331
  ['gea::host::Camera.capture', geaHostDeclarations],
327
332
  ['gea::host::Camera.captureMirrored', geaHostDeclarations],
333
+ ['gea::host::Camera.captureFrame', geaHostDeclarations],
328
334
  ['gea::host::Camera.setFlash', geaHostDeclarations],
329
335
  ['gea::host::Camera.setZoom', geaHostDeclarations],
330
336
  ['gea::host::Camera.setMirror', geaHostDeclarations]
@@ -36,6 +36,8 @@ const EVENT_RECEIVER_TYPES = [
36
36
  // `EventTarget.addEventListener(type, listener)` declare.
37
37
  "Event",
38
38
  "PointerEvent",
39
+ "PressEvent",
40
+ "PressEventArgument",
39
41
  "TouchEvent",
40
42
  "RotaryEvent",
41
43
  // `InputEvent` and `KeyEvent` (index.d.ts) are the same one runtime struct:
@@ -66,6 +68,7 @@ const RTC_PEER_CONNECTION_RECEIVER_TYPES = [
66
68
  const EVENT_TARGET_RECEIVER_TYPES = [
67
69
  "gea::framework::events::EventTarget",
68
70
  "InputEventTarget",
71
+ "PressEventTarget",
69
72
  ];
70
73
  // Receiver type names for a concrete `gea::host::GeaEmbeddedImage` value: the
71
74
  // qualified storage type, the unqualified TS interface name, and the `LoadedImage`
@@ -315,6 +318,8 @@ export function createGeaHostShims() {
315
318
  // never reached it either. A wrapper `<div>`'s drag handlers received
316
319
  // nothing, silently, and the app just did not respond.
317
320
  PointerEvent: "gea::framework::events::PointerEvent",
321
+ PressEvent: "gea::framework::events::PointerEvent",
322
+ PressEventArgument: "gea::framework::events::PointerEvent",
318
323
  TouchEvent: "gea::framework::events::PointerEvent",
319
324
  RotaryEvent: "gea::framework::events::PointerEvent",
320
325
  // The base interface, for `onScroll={e => ...}` and any listener typed by
@@ -344,6 +349,7 @@ export function createGeaHostShims() {
344
349
  // attribute). v1 emitted exactly this:
345
350
  // `event.currentTarget.getAttribute("value")`.
346
351
  InputEventTarget: "gea::framework::events::EventTarget",
352
+ PressEventTarget: "gea::framework::events::EventTarget",
347
353
  // gea-embedded's own element interfaces (index.d.ts) — without these a
348
354
  // `Component<GeaCanvasElement>`'s `this.el` lowers to a record-alias struct
349
355
  // of std::functions whose boxed form has no `__gea_node_id`, so
@@ -528,6 +534,7 @@ export function createGeaHostShims() {
528
534
  WiFi: "gea::host::navigator.wifi",
529
535
  wifi: "gea::host::navigator.wifi",
530
536
  http: "gea::host::http",
537
+ __gea_http: "gea::host::http",
531
538
  Accelerometer: "Accelerometer",
532
539
  __gea_Accelerometer: "gea::host::Accelerometer",
533
540
  Camera: "gea::host::Camera",
@@ -540,6 +547,7 @@ export function createGeaHostShims() {
540
547
  Gpio: "gea::host::Gpio",
541
548
  Led: "gea::host::Led",
542
549
  Clock: "gea::host::Clock",
550
+ Haptics: "gea::host::Haptics",
543
551
  Profiler: "gea::host::Profiler",
544
552
  Battery: "gea::host::Battery",
545
553
  Notify: "gea::host::Notify",
@@ -552,9 +560,11 @@ export function createGeaHostShims() {
552
560
  __gea_Display: "gea::host::Display",
553
561
  __gea_Memory: "gea::host::Memory",
554
562
  __gea_Input: "gea::host::Input",
563
+ __gea_Uart: "gea::host::Uart",
555
564
  __gea_Gpio: "gea::host::Gpio",
556
565
  __gea_Led: "gea::host::Led",
557
566
  __gea_Clock: "gea::host::Clock",
567
+ __gea_Haptics: "gea::host::Haptics",
558
568
  __gea_Profiler: "gea::host::Profiler",
559
569
  __gea_Battery: "gea::host::Battery",
560
570
  __gea_Notify: "gea::host::Notify",
@@ -726,6 +736,7 @@ export function createGeaHostShims() {
726
736
  loadFileOpaque: "gea::host::image.loadFileOpaque",
727
737
  loadAssetPath: "gea::host::image.loadAssetPath",
728
738
  writeFile: "gea::host::image.writeFile",
739
+ removeFile: "gea::host::image.removeFile",
729
740
  readFile: "gea::host::image.readFile",
730
741
  readMapArchive: "gea::host::image.readMapArchive",
731
742
  readFileRange: "gea::host::image.readFileRange",
@@ -975,6 +986,11 @@ export function createGeaHostShims() {
975
986
  getIP: "gea::host::navigator.wifi.ip",
976
987
  mac: "gea::host::navigator.wifi.mac",
977
988
  configure: "gea::host::navigator.wifi.configure",
989
+ startAccessPoint: "gea::host::navigator.wifi.startAccessPoint",
990
+ stopAccessPoint: "gea::host::navigator.wifi.stopAccessPoint",
991
+ accessPointMac: "gea::host::navigator.wifi.accessPointMac",
992
+ startCaptivePortal: "gea::host::navigator.wifi.startCaptivePortal",
993
+ stopCaptivePortal: "gea::host::navigator.wifi.stopCaptivePortal",
978
994
  waitForConnection: "gea::host::navigator.wifi.waitForConnection",
979
995
  startScan: "gea::host::navigator.wifi.startScan",
980
996
  scanning: "gea::host::navigator.wifi.scanning",
@@ -996,6 +1012,11 @@ export function createGeaHostShims() {
996
1012
  getIP: "gea::host::navigator.wifi.ip",
997
1013
  mac: "gea::host::navigator.wifi.mac",
998
1014
  configure: "gea::host::navigator.wifi.configure",
1015
+ startAccessPoint: "gea::host::navigator.wifi.startAccessPoint",
1016
+ stopAccessPoint: "gea::host::navigator.wifi.stopAccessPoint",
1017
+ accessPointMac: "gea::host::navigator.wifi.accessPointMac",
1018
+ startCaptivePortal: "gea::host::navigator.wifi.startCaptivePortal",
1019
+ stopCaptivePortal: "gea::host::navigator.wifi.stopCaptivePortal",
999
1020
  waitForConnection: "gea::host::navigator.wifi.waitForConnection",
1000
1021
  startScan: "gea::host::navigator.wifi.startScan",
1001
1022
  scanning: "gea::host::navigator.wifi.scanning",
@@ -1017,6 +1038,11 @@ export function createGeaHostShims() {
1017
1038
  getIP: "gea::host::navigator.wifi.ip",
1018
1039
  mac: "gea::host::navigator.wifi.mac",
1019
1040
  configure: "gea::host::navigator.wifi.configure",
1041
+ startAccessPoint: "gea::host::navigator.wifi.startAccessPoint",
1042
+ stopAccessPoint: "gea::host::navigator.wifi.stopAccessPoint",
1043
+ accessPointMac: "gea::host::navigator.wifi.accessPointMac",
1044
+ startCaptivePortal: "gea::host::navigator.wifi.startCaptivePortal",
1045
+ stopCaptivePortal: "gea::host::navigator.wifi.stopCaptivePortal",
1020
1046
  waitForConnection: "gea::host::navigator.wifi.waitForConnection",
1021
1047
  startScan: "gea::host::navigator.wifi.startScan",
1022
1048
  scanning: "gea::host::navigator.wifi.scanning",
@@ -1051,6 +1077,7 @@ export function createGeaHostShims() {
1051
1077
  // forms remain on the __gea_Camera table for the runtime shim's own use.
1052
1078
  capture: "gea::host::Camera.capturePhoto",
1053
1079
  capturePhoto: "gea::host::Camera.capturePhoto",
1080
+ captureFrame: "gea::host::Camera.captureFrame",
1054
1081
  captureMirrored: "gea::host::Camera.captureMirrored",
1055
1082
  startRecording: "gea::host::Camera.startRecording",
1056
1083
  stopRecording: "gea::host::Camera.stopRecordingClip",
@@ -1075,6 +1102,7 @@ export function createGeaHostShims() {
1075
1102
  isOpen: "gea::host::Camera.isOpen",
1076
1103
  draw: "gea::host::Camera.draw",
1077
1104
  capture: "gea::host::Camera.capture",
1105
+ captureFrame: "gea::host::Camera.captureFrame",
1078
1106
  captureMirrored: "gea::host::Camera.captureMirrored",
1079
1107
  startRecording: "gea::host::Camera.startRecording",
1080
1108
  stopRecording: "gea::host::Camera.stopRecording",
@@ -1092,11 +1120,13 @@ export function createGeaHostShims() {
1092
1120
  __gea_audioContext: {
1093
1121
  createOscillator: "gea::host::sharedAudioContext().createOscillator",
1094
1122
  createBufferSource: "gea::host::sharedAudioContext().createBufferSource",
1123
+ createBuffer: "gea::host::sharedAudioContext().createBuffer",
1095
1124
  decodeAudioData: "gea::host::sharedAudioContext().decodeAudioData",
1096
1125
  },
1097
1126
  audioContext: {
1098
1127
  createOscillator: "gea::host::sharedAudioContext().createOscillator",
1099
1128
  createBufferSource: "gea::host::sharedAudioContext().createBufferSource",
1129
+ createBuffer: "gea::host::sharedAudioContext().createBuffer",
1100
1130
  decodeAudioData: "gea::host::sharedAudioContext().decodeAudioData",
1101
1131
  },
1102
1132
  __gea_Audio: {
@@ -1268,6 +1298,15 @@ export function createGeaHostShims() {
1268
1298
  write: "gea::host::Gpio.write",
1269
1299
  read: "gea::host::Gpio.read",
1270
1300
  },
1301
+ __gea_Uart: {
1302
+ open: "gea::host::Uart.open",
1303
+ isOpen: "gea::host::Uart.isOpen",
1304
+ close: "gea::host::Uart.close",
1305
+ read: "gea::host::Uart.read",
1306
+ write: "gea::host::Uart.write",
1307
+ available: "gea::host::Uart.available",
1308
+ writable: "gea::host::Uart.writable",
1309
+ },
1271
1310
  __gea_Gpio: {
1272
1311
  configureOutput: "gea::host::Gpio.configureOutput",
1273
1312
  configureInput: "gea::host::Gpio.configureInput",
@@ -1291,9 +1330,11 @@ export function createGeaHostShims() {
1291
1330
  detach: "gea::host::Led.detach",
1292
1331
  },
1293
1332
  Clock: {
1333
+ setEpochMs: "gea::host::Clock.setEpochMs",
1294
1334
  epochMs: "gea::host::Clock.epochMs",
1295
1335
  },
1296
1336
  __gea_Clock: {
1337
+ setEpochMs: "gea::host::Clock.setEpochMs",
1297
1338
  epochMs: "gea::host::Clock.epochMs",
1298
1339
  },
1299
1340
  Profiler: {
@@ -1311,10 +1352,18 @@ export function createGeaHostShims() {
1311
1352
  clear: "gea::host::Storage.clear",
1312
1353
  key: "gea::host::Storage.key",
1313
1354
  },
1355
+ Haptics: {
1356
+ vibrate: "gea::host::Haptics.vibrate",
1357
+ },
1314
1358
  Battery: {
1359
+ charging: "gea::host::Battery.charging",
1315
1360
  level: "gea::host::Battery.level",
1316
1361
  },
1362
+ __gea_Haptics: {
1363
+ vibrate: "gea::host::Haptics.vibrate",
1364
+ },
1317
1365
  __gea_Battery: {
1366
+ charging: "gea::host::Battery.charging",
1318
1367
  level: "gea::host::Battery.level",
1319
1368
  },
1320
1369
  Notify: {
@@ -1343,13 +1392,14 @@ export function createGeaHostShims() {
1343
1392
  Input: ["consumeBackButton"],
1344
1393
  __gea_Input: ["consumeBackButton"],
1345
1394
  Gpio: ["configureOutput", "configureInput", "write", "read"],
1395
+ __gea_Uart: ["open", "isOpen", "close", "available", "writable"],
1346
1396
  __gea_Gpio: ["configureOutput", "configureInput", "write", "read"],
1347
1397
  Led: ["set", "off", "attach", "setPixel", "show", "detach"],
1348
1398
  __gea_Led: ["set", "off", "attach", "setPixel", "show", "detach"],
1349
1399
  Clock: ["epochMs"],
1350
1400
  __gea_Clock: ["epochMs"],
1351
- Profiler: ["nowUs"],
1352
- __gea_Profiler: ["nowUs"],
1401
+ Profiler: ["nowUs", "nowCycles"],
1402
+ __gea_Profiler: ["nowUs", "nowCycles"],
1353
1403
  Battery: ["level"],
1354
1404
  __gea_Battery: ["level"],
1355
1405
  Notify: ["seq"],
@@ -1640,6 +1690,20 @@ export function createGeaHostShims() {
1640
1690
  receiverTypes: EVENT_RECEIVER_TYPES,
1641
1691
  },
1642
1692
  ],
1693
+ pressId: [
1694
+ {
1695
+ emit: "static_cast<double>(({receiver}).pressId)",
1696
+ returnType: "double",
1697
+ receiverTypes: EVENT_RECEIVER_TYPES,
1698
+ },
1699
+ ],
1700
+ pressValue: [
1701
+ {
1702
+ emit: "static_cast<double>(({receiver}).pressValue)",
1703
+ returnType: "double",
1704
+ receiverTypes: EVENT_RECEIVER_TYPES,
1705
+ },
1706
+ ],
1643
1707
  // `KeyEvent.keyCode` / `.which` (index.d.ts). One engine field backs both,
1644
1708
  // exactly as the DOM's own two spellings alias one value; `keydown` is
1645
1709
  // filled by `Tree::dispatchDocumentKey` and by the macOS key bridge.
@@ -1974,14 +2038,20 @@ export function createGeaHostShims() {
1974
2038
  {
1975
2039
  emit: "({receiver}).kind()",
1976
2040
  returnType: "std::string",
1977
- receiverTypes: ["gea::host::MediaStreamTrack", "MediaStreamTrack"],
2041
+ receiverTypes: [
2042
+ "gea::host::MediaStreamTrack",
2043
+ "MediaStreamTrack",
2044
+ ],
1978
2045
  },
1979
2046
  ],
1980
2047
  readyState: [
1981
2048
  {
1982
2049
  emit: "({receiver}).readyState()",
1983
2050
  returnType: "std::string",
1984
- receiverTypes: ["gea::host::MediaStreamTrack", "MediaStreamTrack"],
2051
+ receiverTypes: [
2052
+ "gea::host::MediaStreamTrack",
2053
+ "MediaStreamTrack",
2054
+ ],
1985
2055
  },
1986
2056
  ],
1987
2057
  // `pc.connectionState` -- a TS PROPERTY (`readonly connectionState:
@@ -2009,7 +2079,10 @@ export function createGeaHostShims() {
2009
2079
  {
2010
2080
  emit: "({receiver}).enabled()",
2011
2081
  returnType: "bool",
2012
- receiverTypes: ["gea::host::MediaStreamTrack", "MediaStreamTrack"],
2082
+ receiverTypes: [
2083
+ "gea::host::MediaStreamTrack",
2084
+ "MediaStreamTrack",
2085
+ ],
2013
2086
  },
2014
2087
  ],
2015
2088
  state: [
@@ -2114,6 +2187,27 @@ export function createGeaHostShims() {
2114
2187
  receiverTypes: NODE_HANDLE_RECEIVER_TYPES,
2115
2188
  },
2116
2189
  ],
2190
+ length: [
2191
+ {
2192
+ emit: "({receiver}).getLength()",
2193
+ returnType: "double",
2194
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
2195
+ },
2196
+ ],
2197
+ duration: [
2198
+ {
2199
+ emit: "({receiver}).getDuration()",
2200
+ returnType: "double",
2201
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
2202
+ },
2203
+ ],
2204
+ numberOfChannels: [
2205
+ {
2206
+ emit: "({receiver}).getNumberOfChannels()",
2207
+ returnType: "double",
2208
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
2209
+ },
2210
+ ],
2117
2211
  buffer: [
2118
2212
  {
2119
2213
  emit: "static_cast<gea::host::AudioBuffer>(({receiver}).buffer)",
@@ -2243,7 +2337,10 @@ export function createGeaHostShims() {
2243
2337
  enabled: [
2244
2338
  {
2245
2339
  emit: "({receiver}).setEnabled({value})",
2246
- receiverTypes: ["gea::host::MediaStreamTrack", "MediaStreamTrack"],
2340
+ receiverTypes: [
2341
+ "gea::host::MediaStreamTrack",
2342
+ "MediaStreamTrack",
2343
+ ],
2247
2344
  },
2248
2345
  ],
2249
2346
  buffer: [
@@ -2430,6 +2527,9 @@ export function createGeaHostShims() {
2430
2527
  },
2431
2528
  ],
2432
2529
  hostExternDeclarations: geaHostExternDeclarations,
2530
+ nativeFunctionSignatureSources: {
2531
+ requestAnimationFrame: { packageName: "@geastack/host", header: "include/host/timers.h" },
2532
+ },
2433
2533
  embeddedHostFunctions: {
2434
2534
  // These are declared by core/index.d.ts rather than the standard lib;
2435
2535
  // btoa also has the host's existing ArrayBuffer/Uint8Array overloads.
@@ -2542,14 +2642,34 @@ export function createGeaHostShims() {
2542
2642
  noThrow: true,
2543
2643
  },
2544
2644
  },
2645
+ Haptics: {
2646
+ vibrate: {
2647
+ emit: "gea::host::Haptics.vibrate({args})",
2648
+ returnType: "bool",
2649
+ },
2650
+ },
2545
2651
  Battery: {
2652
+ charging: {
2653
+ emit: "gea::host::Battery.charging({args})",
2654
+ returnType: "bool",
2655
+ },
2546
2656
  level: {
2547
2657
  emit: "gea::host::Battery.level({args})",
2548
2658
  returnType: "double",
2549
2659
  noThrow: true,
2550
2660
  },
2551
2661
  },
2662
+ __gea_Haptics: {
2663
+ vibrate: {
2664
+ emit: "gea::host::Haptics.vibrate({args})",
2665
+ returnType: "bool",
2666
+ },
2667
+ },
2552
2668
  __gea_Battery: {
2669
+ charging: {
2670
+ emit: "gea::host::Battery.charging({args})",
2671
+ returnType: "bool",
2672
+ },
2553
2673
  level: {
2554
2674
  emit: "gea::host::Battery.level({args})",
2555
2675
  returnType: "double",
@@ -2562,6 +2682,11 @@ export function createGeaHostShims() {
2562
2682
  returnType: "double",
2563
2683
  noThrow: true,
2564
2684
  },
2685
+ nowCycles: {
2686
+ emit: "gea::host::Profiler.nowCycles({args})",
2687
+ returnType: "double",
2688
+ noThrow: true,
2689
+ },
2565
2690
  },
2566
2691
  __gea_Profiler: {
2567
2692
  nowUs: {
@@ -2569,12 +2694,21 @@ export function createGeaHostShims() {
2569
2694
  returnType: "double",
2570
2695
  noThrow: true,
2571
2696
  },
2697
+ nowCycles: {
2698
+ emit: "gea::host::Profiler.nowCycles({args})",
2699
+ returnType: "double",
2700
+ noThrow: true,
2701
+ },
2572
2702
  },
2573
2703
  __gea_audioContext: {
2574
2704
  createOscillator: {
2575
2705
  emit: "gea::host::sharedAudioContext().createOscillator({args})",
2576
2706
  returnType: "gea::host::OscillatorNode",
2577
2707
  },
2708
+ createBuffer: {
2709
+ emit: "gea::host::sharedAudioContext().createBuffer({args})",
2710
+ returnType: "gea::host::AudioBuffer",
2711
+ },
2578
2712
  createBufferSource: {
2579
2713
  emit: "gea::host::sharedAudioContext().createBufferSource({args})",
2580
2714
  returnType: "gea::host::AudioBufferSourceNode",
@@ -2589,6 +2723,10 @@ export function createGeaHostShims() {
2589
2723
  emit: "gea::host::sharedAudioContext().createOscillator({args})",
2590
2724
  returnType: "gea::host::OscillatorNode",
2591
2725
  },
2726
+ createBuffer: {
2727
+ emit: "gea::host::sharedAudioContext().createBuffer({args})",
2728
+ returnType: "gea::host::AudioBuffer",
2729
+ },
2592
2730
  createBufferSource: {
2593
2731
  emit: "gea::host::sharedAudioContext().createBufferSource({args})",
2594
2732
  returnType: "gea::host::AudioBufferSourceNode",
@@ -2643,14 +2781,26 @@ export function createGeaHostShims() {
2643
2781
  },
2644
2782
  },
2645
2783
  // `http.createServer(handler)` yields the native HttpServer handle. The
2646
- // handler arg is a boxed callable (dynamic boundary, like a WebSocket
2647
- // callback); registering the return type keeps `const server = ...` a
2784
+ // handler is adapted directly from its typed callable; registering the
2785
+ // return type keeps `const server = ...` a
2648
2786
  // concrete `gea::host::HttpServer` instead of a gea_cpp_value record.
2649
2787
  http: {
2650
2788
  // create_server returns the numeric handle; wrap it in the HttpServer
2651
2789
  // handle type (its ctors are explicit) so the binding stores native.
2652
2790
  createServer: {
2653
- emit: "gea::host::HttpServer(gea::host::http::create_server({args}))",
2791
+ emit: "gea::host::HttpServer(gea::host::http::create_typed_server({args}))",
2792
+ returnType: "gea::host::HttpServer",
2793
+ },
2794
+ close: {
2795
+ emit: "gea::host::http::close_server({args})",
2796
+ returnType: "void",
2797
+ },
2798
+ },
2799
+ __gea_http: {
2800
+ // create_server returns the numeric handle; wrap it in the HttpServer
2801
+ // handle type (its ctors are explicit) so the binding stores native.
2802
+ createServer: {
2803
+ emit: "gea::host::HttpServer(gea::host::http::create_typed_server({args}))",
2654
2804
  returnType: "gea::host::HttpServer",
2655
2805
  },
2656
2806
  close: {
@@ -2882,6 +3032,11 @@ export function createGeaHostShims() {
2882
3032
  // `Tree::getAttribute`) -- so wrapping it in `std::string` is total, not
2883
3033
  // a guess, and the declared TypeScript return is an ordinary `string`.
2884
3034
  getAttribute: [
3035
+ {
3036
+ receiverTypes: EVENT_TARGET_RECEIVER_TYPES,
3037
+ emit: "std::string(({receiver}).getAttribute(std::string({arg0}).c_str()))",
3038
+ returnType: "std::string",
3039
+ },
2885
3040
  {
2886
3041
  receiverTypes: NODE_HANDLE_RECEIVER_TYPES,
2887
3042
  emit: "std::string(({receiver}).getAttribute({arg0}))",
@@ -3064,7 +3219,10 @@ export function createGeaHostShims() {
3064
3219
  // This is distinct from the NODE_HANDLE_RECEIVER_TYPES row below,
3065
3220
  // which reconstructs the wrapper from a generic DOM node id and is
3066
3221
  // untouched.
3067
- receiverTypes: ["gea::host::HTMLAudioElement", "HTMLAudioElement"],
3222
+ receiverTypes: [
3223
+ "gea::host::HTMLAudioElement",
3224
+ "HTMLAudioElement",
3225
+ ],
3068
3226
  emit: "gea::runtime::hostaudio::play({receiver})",
3069
3227
  returnType: "gea::Promise<void>",
3070
3228
  },
@@ -3083,7 +3241,10 @@ export function createGeaHostShims() {
3083
3241
  {
3084
3242
  // See `play` above: a statically HTMLAudioElement-typed receiver
3085
3243
  // calls directly, no reconstruction from a node id.
3086
- receiverTypes: ["gea::host::HTMLAudioElement", "HTMLAudioElement"],
3244
+ receiverTypes: [
3245
+ "gea::host::HTMLAudioElement",
3246
+ "HTMLAudioElement",
3247
+ ],
3087
3248
  emit: "({receiver}).pause()",
3088
3249
  returnType: "void",
3089
3250
  },
@@ -3140,6 +3301,34 @@ export function createGeaHostShims() {
3140
3301
  returnType: "gea::host::OscillatorNode",
3141
3302
  },
3142
3303
  ],
3304
+ getChannelData: [
3305
+ {
3306
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
3307
+ emit: "({receiver}).getChannelData({args})",
3308
+ returnType: "gea::Ref<gea::TypedArray<float>>",
3309
+ },
3310
+ ],
3311
+ copyToChannel: [
3312
+ {
3313
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
3314
+ emit: "({receiver}).copyToChannel({args})",
3315
+ returnType: "void",
3316
+ },
3317
+ ],
3318
+ copyFromChannel: [
3319
+ {
3320
+ receiverTypes: ["gea::host::AudioBuffer", "AudioBuffer"],
3321
+ emit: "({receiver}).copyFromChannel({args})",
3322
+ returnType: "void",
3323
+ },
3324
+ ],
3325
+ createBuffer: [
3326
+ {
3327
+ receiverTypes: ["gea::host::AudioContext", "AudioContext"],
3328
+ emit: "({receiver}).createBuffer({args})",
3329
+ returnType: "gea::host::AudioBuffer",
3330
+ },
3331
+ ],
3143
3332
  createBufferSource: [
3144
3333
  {
3145
3334
  receiverTypes: ["gea::host::AudioContext", "AudioContext"],
@@ -3201,7 +3390,10 @@ export function createGeaHostShims() {
3201
3390
  // receivers: the rows are keyed by receiver carrier, which is what lets
3202
3391
  // the audio nodes below share the spelling without sharing a type.
3203
3392
  {
3204
- receiverTypes: ["gea::host::MediaStreamTrack", "MediaStreamTrack"],
3393
+ receiverTypes: [
3394
+ "gea::host::MediaStreamTrack",
3395
+ "MediaStreamTrack",
3396
+ ],
3205
3397
  emit: "({receiver}).stop()",
3206
3398
  returnType: "void",
3207
3399
  },
package/dist/types.d.ts CHANGED
@@ -98,6 +98,11 @@ export interface HostShimDefinitions {
98
98
  type: string;
99
99
  }>;
100
100
  embeddedHostFunctions?: Record<string, string>;
101
+ /** Headers inspected for native signatures; no duplicated scalar/callback type metadata. */
102
+ nativeFunctionSignatureSources?: Record<string, {
103
+ packageName: string;
104
+ header: string;
105
+ }>;
101
106
  embeddedHostNoThrowFunctions?: string[];
102
107
  hostNamespaceNoThrowMethods?: Record<string, string[]>;
103
108
  embeddedHostFunctionReturnTypes?: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/geatsc-plugin-gea",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Gea IR backend plugin for geatsc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {