@geastack/geatsc-plugin-gea 0.1.24 → 0.1.26

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.
@@ -1,4 +1,5 @@
1
1
  export declare const nodeAnalysisVersion = "node-analysis-v1";
2
2
  export declare const nodeFeatures: readonly ["node-images", "node-inputs"];
3
+ export declare const videoNodeAnalysisVersion = "node-video-analysis-v1";
3
4
  export declare function addUnknownNodeFeatures(features: Set<string>): void;
4
5
  export declare function addNodeFeatures(file: string, text: string, features: Set<string>): void;
@@ -1,9 +1,21 @@
1
1
  import ts from 'typescript';
2
2
  export const nodeAnalysisVersion = 'node-analysis-v1';
3
3
  export const nodeFeatures = ['node-images', 'node-inputs'];
4
+ // Separate marker: an analyzer without it never reports node-videos, and its
5
+ // absence must not let a newer CLI drop the video host from the firmware.
6
+ export const videoNodeAnalysisVersion = 'node-video-analysis-v1';
7
+ const nodeFreeCoreExports = new RegExp('^(?:' + [
8
+ 'Component', 'ReactiveComponent', 'Store', 'mount', 'Display', 'rgb', 'rgba',
9
+ 'touch', 'Input', 'Accelerometer', 'Magnetometer', 'Geolocation', 'geolocation', 'Clock', 'Battery', 'Memory', 'Profiler',
10
+ 'WiFi', 'wifi', 'BLE', 'bluetooth', 'BLEServer', 'registerBleServer', 'initBleServers', 'EspNow', 'Uart', 'Gpio', 'Digital', 'Buttons', 'Led', 'Haptics', 'Notify', 'DeviceControl',
11
+ 'Audio', 'audioContext', 'flushAudioWorkletOutput',
12
+ 'writeCacheFile', 'readCacheFile', 'removeCacheFile', 'listCacheFiles', 'readFileRange', 'readMapArchive',
13
+ 'http', 'fetchBytes', 'fetchText', 'fetchAsync', 'fetchReady', 'fetchResult', 'fetchRelease',
14
+ ].join('|') + ')$');
4
15
  export function addUnknownNodeFeatures(features) {
5
16
  for (const feature of nodeFeatures)
6
17
  features.add(feature);
18
+ features.add('node-videos');
7
19
  }
8
20
  // Native node payloads are selected from the whole discovered source graph.
9
21
  // CSS rendering features remain independent: a background image does not make
@@ -18,6 +30,8 @@ export function addNodeFeatures(file, text, features) {
18
30
  features.add('node-images');
19
31
  if (/^(?:input|textarea|select|contenteditable)$/i.test(value) || /^(?:TextInput|InputElement|TextInputElement|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|VirtualKeyboard|createInput|createTextInput)$/.test(value))
20
32
  features.add('node-inputs');
33
+ if (/^video$/i.test(value) || /^(?:VideoElement|HTMLVideoElement|createVideo)$/.test(value))
34
+ features.add('node-videos');
21
35
  };
22
36
  const visit = (node) => {
23
37
  if (ts.isIdentifier(node)) {
@@ -34,19 +48,21 @@ export function addNodeFeatures(file, text, features) {
34
48
  if (/^(?:createElement|createElementNS)$/.test(node.text) &&
35
49
  !ts.isElementAccessExpression(node.parent))
36
50
  unknown();
37
- if (/<(?:img|image|input|textarea|select)\b/i.test(node.text))
51
+ if (/<(?:img|image|input|textarea|select|video)\b/i.test(node.text))
38
52
  unknown();
39
53
  }
40
54
  if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node))
41
55
  name(node.tagName.getText(source).split(':').at(-1));
42
- // Display controls the panel/canvas; importing it cannot create native
43
- // image or input nodes. Calls that actually create nodes are still scanned.
56
+ // Display controls the panel/canvas, and the device services (sensors,
57
+ // radios, storage, audio, clock) have no DOM surface: importing them cannot
58
+ // create image, input or video nodes. Calls that actually create nodes are
59
+ // still scanned.
44
60
  if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier) &&
45
61
  /^(?:gea-embedded|@geastack\/(?:core|engine)|@geajs\/core)(?:\/|$)/.test(node.moduleSpecifier.text) &&
46
62
  node.importClause && !node.importClause.isTypeOnly) {
47
63
  const bindings = node.importClause.namedBindings;
48
64
  if (node.importClause.name || !bindings || !ts.isNamedImports(bindings) ||
49
- bindings.elements.some(item => !item.isTypeOnly && !/^(?:Component|Store|mount|Display)$/.test((item.propertyName ?? item.name).text)))
65
+ bindings.elements.some(item => !item.isTypeOnly && !nodeFreeCoreExports.test((item.propertyName ?? item.name).text)))
50
66
  unknown();
51
67
  }
52
68
  // Mutation/markup helpers can create descendants whose tags are not present
package/dist/analyze.js CHANGED
@@ -7,7 +7,7 @@ import { analyzeClassCapacity } from './analyze-classes.js';
7
7
  import ts from 'typescript';
8
8
  import path from 'node:path';
9
9
  import { createRequire } from 'node:module';
10
- import { nodeAnalysisVersion, addNodeFeatures, addUnknownNodeFeatures } from './analyze-nodes.js';
10
+ import { nodeAnalysisVersion, videoNodeAnalysisVersion, addNodeFeatures, addUnknownNodeFeatures } from './analyze-nodes.js';
11
11
  import { cssRangeObserver } from './analyze-css-ranges.js';
12
12
  import { cssAnalysisVersion, cssUsageObserver, addUnknownCssFeatures } from './analyze-css.js';
13
13
  import { addRendererFeatures, addUnknownRendererFeatures, rendererAnalysisVersion, rendererOcclusionAnalysisVersion, rendererVariableAnalysis } from './analyze-renderer.js';
@@ -32,7 +32,7 @@ export function capabilitiesToAnalyzePatch(capabilities) {
32
32
  // connection with "No server verification option set".
33
33
  export function analyzeSourceHostBindings(entry) {
34
34
  const bindings = new Set();
35
- const features = new Set([rendererAnalysisVersion, rendererOcclusionAnalysisVersion, cssAnalysisVersion, nodeAnalysisVersion, nodeAuxVersion]);
35
+ const features = new Set([rendererAnalysisVersion, rendererOcclusionAnalysisVersion, cssAnalysisVersion, nodeAnalysisVersion, videoNodeAnalysisVersion, nodeAuxVersion]);
36
36
  const discovery = discoverSourceFiles(entry);
37
37
  const classSources = new Map();
38
38
  let classUnknown = discovery.unknown;
@@ -948,6 +948,17 @@ function lowerHostFacadeCall(context, path, args) {
948
948
  // BatteryController — charge percentage from the platform PMU.
949
949
  'Battery.level': { target: 'gea::host::Battery.level' },
950
950
  '__gea_Battery.level': { target: 'gea::host::Battery.level' },
951
+ // ButtonsController — the board's named physical buttons.
952
+ 'Buttons.count': { target: 'gea::host::Buttons.count' },
953
+ '__gea_Buttons.count': { target: 'gea::host::Buttons.count' },
954
+ 'Buttons.code': { target: 'gea::host::Buttons.code', hints: ['number'] },
955
+ '__gea_Buttons.code': { target: 'gea::host::Buttons.code', hints: ['number'] },
956
+ 'Buttons.key': { target: 'gea::host::Buttons.key', hints: ['number'] },
957
+ '__gea_Buttons.key': { target: 'gea::host::Buttons.key', hints: ['number'] },
958
+ 'Buttons.pin': { target: 'gea::host::Buttons.pin', hints: ['number'] },
959
+ '__gea_Buttons.pin': { target: 'gea::host::Buttons.pin', hints: ['number'] },
960
+ 'Buttons.pressed': { target: 'gea::host::Buttons.pressed', hints: ['string'] },
961
+ '__gea_Buttons.pressed': { target: 'gea::host::Buttons.pressed', hints: ['string'] },
951
962
  // NotifyController — transient host->app notification channel.
952
963
  'Notify.text': { target: 'gea::host::Notify.text' },
953
964
  '__gea_Notify.text': { target: 'gea::host::Notify.text' },
@@ -61,7 +61,8 @@ const geaGeolocationHostMethods = [
61
61
  'clearWatch',
62
62
  ];
63
63
  const geaInputHostMethods = ['consumeBackButton'];
64
- const geaGpioHostMethods = ['configureOutput', 'configureInput', 'write', 'read'];
64
+ const geaGpioHostMethods = ['configureOutput', 'configureInput', 'write', 'read', 'open', 'get', 'set', 'close'];
65
+ const geaButtonsHostMethods = ['count', 'code', 'key', 'pin', 'pressed'];
65
66
  const geaMagnetometerHostMethods = ['open', 'close', 'count', 'read'];
66
67
  const geaEspNowHostMethods = ['open', 'isOpen', 'canSend', 'setMaxTxPower', 'getMaxTxPower', 'close', 'addPeer', 'send', 'receive'];
67
68
  const geaUartHostMethods = ['open', 'isOpen', 'close', 'read', 'write', 'available', 'writable'];
@@ -147,6 +148,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
147
148
  ...geaMemoryHostMethods.map((method) => [`gea::host::Memory.${method}`, geaHostDeclarations]),
148
149
  ...geaInputHostMethods.map((method) => [`gea::host::Input.${method}`, geaHostDeclarations]),
149
150
  ...geaGpioHostMethods.map((method) => [`gea::host::Gpio.${method}`, geaHostDeclarations]),
151
+ ...geaButtonsHostMethods.map((method) => [`gea::host::Buttons.${method}`, geaHostDeclarations]),
150
152
  ...geaMagnetometerHostMethods.map((method) => [`gea::host::Magnetometer.${method}`, geaHostDeclarations]),
151
153
  ...geaEspNowHostMethods.map((method) => [`gea::host::EspNow.${method}`, geaHostDeclarations]),
152
154
  ...geaUartHostMethods.map((method) => [`gea::host::Uart.${method}`, geaHostDeclarations]),
@@ -553,7 +553,8 @@ export function createGeaHostShims() {
553
553
  Memory: "gea::host::Memory",
554
554
  memory: "gea::host::Memory",
555
555
  Input: "gea::host::Input",
556
- Gpio: "gea::host::Gpio",
556
+ // `Gpio` itself is a TS class (core runtime/gpio.ts) over `__gea_Gpio`.
557
+ Buttons: "gea::host::Buttons",
557
558
  Led: "gea::host::Led",
558
559
  Clock: "gea::host::Clock",
559
560
  Haptics: "gea::host::Haptics",
@@ -570,6 +571,7 @@ export function createGeaHostShims() {
570
571
  __gea_Memory: "gea::host::Memory",
571
572
  __gea_Input: "gea::host::Input",
572
573
  __gea_Gpio: "gea::host::Gpio",
574
+ __gea_Buttons: "gea::host::Buttons",
573
575
  __gea_EspNow: "gea::host::EspNow",
574
576
  __gea_Magnetometer: "gea::host::Magnetometer",
575
577
  __gea_Uart: "gea::host::Uart",
@@ -1307,17 +1309,30 @@ export function createGeaHostShims() {
1307
1309
  __gea_Input: {
1308
1310
  consumeBackButton: "gea::host::Input.consumeBackButton",
1309
1311
  },
1310
- Gpio: {
1311
- configureOutput: "gea::host::Gpio.configureOutput",
1312
- configureInput: "gea::host::Gpio.configureInput",
1313
- write: "gea::host::Gpio.write",
1314
- read: "gea::host::Gpio.read",
1315
- },
1312
+ // The one backend under the `Gpio` and ECMA-419 `Digital` classes.
1316
1313
  __gea_Gpio: {
1317
1314
  configureOutput: "gea::host::Gpio.configureOutput",
1318
1315
  configureInput: "gea::host::Gpio.configureInput",
1319
1316
  write: "gea::host::Gpio.write",
1320
1317
  read: "gea::host::Gpio.read",
1318
+ open: "gea::host::Gpio.open",
1319
+ get: "gea::host::Gpio.get",
1320
+ set: "gea::host::Gpio.set",
1321
+ close: "gea::host::Gpio.close",
1322
+ },
1323
+ Buttons: {
1324
+ count: "gea::host::Buttons.count",
1325
+ code: "gea::host::Buttons.code",
1326
+ key: "gea::host::Buttons.key",
1327
+ pin: "gea::host::Buttons.pin",
1328
+ pressed: "gea::host::Buttons.pressed",
1329
+ },
1330
+ __gea_Buttons: {
1331
+ count: "gea::host::Buttons.count",
1332
+ code: "gea::host::Buttons.code",
1333
+ key: "gea::host::Buttons.key",
1334
+ pin: "gea::host::Buttons.pin",
1335
+ pressed: "gea::host::Buttons.pressed",
1321
1336
  },
1322
1337
  __gea_Magnetometer: {
1323
1338
  open: "gea::host::Magnetometer.open",
@@ -1423,8 +1438,10 @@ export function createGeaHostShims() {
1423
1438
  __gea_Memory: MEMORY_NO_THROW_METHODS,
1424
1439
  Input: ["consumeBackButton"],
1425
1440
  __gea_Input: ["consumeBackButton"],
1426
- Gpio: ["configureOutput", "configureInput", "write", "read"],
1427
- __gea_Gpio: ["configureOutput", "configureInput", "write", "read"],
1441
+ // open() stores its callback; it runs later, from Application::frame.
1442
+ __gea_Gpio: ["configureOutput", "configureInput", "write", "read", "open", "get", "set", "close"],
1443
+ Buttons: ["count", "code", "key", "pin", "pressed"],
1444
+ __gea_Buttons: ["count", "code", "key", "pin", "pressed"],
1428
1445
  __gea_EspNow: ["open", "isOpen", "canSend", "setMaxTxPower", "getMaxTxPower", "close"],
1429
1446
  __gea_Magnetometer: ["open", "close", "count"],
1430
1447
  __gea_Uart: ["open", "isOpen", "close", "available", "writable"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/geatsc-plugin-gea",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Gea IR backend plugin for geatsc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {