@geastack/cli 0.1.104 → 0.1.106

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/docs/SPEC.md CHANGED
@@ -287,9 +287,19 @@ same thing for any native target.
287
287
 
288
288
  - `nativeSources` — C/C++/ObjC sources compiled into the board's main component.
289
289
  Their directories become include paths.
290
+ - `targets.windows.nativeSources`, `nativeIncludeDirectories`,
291
+ `nativeSystemLibraries`, `nativeResources`, `providers`, `tsconfig`,
292
+ `prebuild` — the Windows target's own native sources (`.mm` included),
293
+ include directories, system import libraries, resource directories staged
294
+ into `Resources/<name>`, runtime providers for capabilities a package
295
+ requires, the TypeScript project the compiler reads the program under, and a
296
+ command run in the app folder before the build. The Windows target documents
297
+ their semantics and its typed `build.native` settings.
290
298
  - `compilerPlugins` — the app's own geatsc plugins, e.g. one declaring the native
291
299
  host functions its TSX calls. They are passed to the compiler for every native
292
- target, because the boundary they describe is the app's, not a board's.
300
+ target, because the boundary they describe is the app's, not a board's. On
301
+ Windows they follow the plugins of the app's dependencies and its own
302
+ `geatsc-plugin.mjs`, which compose rather than replace each other.
293
303
  - `defines` — preprocessor macros, as an object or as `NAME=value` strings; a
294
304
  value of `true` emits a bare define and `false` drops the entry. These apply
295
305
  to the **whole** native build: a macro that sizes a framework type changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/cli",
3
- "version": "0.1.104",
3
+ "version": "0.1.106",
4
4
  "description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@clack/prompts": "^1.8.0",
40
40
  "@geastack/simulator": "^0.1.15",
41
- "@geastack/targets": "^0.1.104",
41
+ "@geastack/targets": "^0.1.106",
42
42
  "picocolors": "^1.1.1",
43
43
  "serialport": "^13.0.0"
44
44
  },
@@ -31,6 +31,21 @@ export const buildOptions = {
31
31
  'diagnostics.performanceCounters': { type: 'boolean', macro: 'GEA_EMBEDDED_PERF' },
32
32
  'diagnostics.frameTiming': { type: 'boolean', macro: 'GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LITE' },
33
33
  'services.wifi': { values: ['auto', 'disabled'], macro: 'GEA_EMBEDDED_WIFI_DISABLED', encode: v => v === 'disabled' ? 1 : undefined },
34
+ // Native toolchain choices of desktop targets that compile and link the
35
+ // program themselves (see the target's documentation for each one's effect).
36
+ // Paths are relative to the app; patterns are regular expressions matched
37
+ // against a source's path with forward slashes.
38
+ 'native.jobs': { type: 'integer', min: 0 },
39
+ 'native.arch': { values: ['default', 'AVX2', 'AVX512'] },
40
+ 'native.debugInfo': { type: 'boolean' },
41
+ 'native.lto': { values: ['off', 'thin'] },
42
+ 'native.ltoJobs': { type: 'integer', min: 0 },
43
+ 'native.ltoCache': { type: 'string' },
44
+ 'native.ltoExcludeSources': { type: 'string' },
45
+ 'native.unoptimizedSources': { type: 'string' },
46
+ 'native.pgo': { values: ['off', 'generate', 'use'] },
47
+ 'native.pgoProfile': { type: 'string' },
48
+ 'native.package': { values: ['none', 'zip'] },
34
49
  }
35
50
  const macros = new Map(Object.entries(buildOptions).filter(([, spec]) => spec.macro).map(([key, spec]) => [spec.macro, key]))
36
51
  const removedEnvironment = {
@@ -95,6 +95,9 @@ const rangeFamilies = ['padding', 'gap', 'border', 'radius', 'font', 'line-heigh
95
95
  const compactStyleDefines = [['css-line-height', 'GEA_CSS_LINE_HEIGHT'], ['css-display-explicit', 'GEA_CSS_DISPLAY_EXPLICIT']]
96
96
  const nodeAuxFeatureDefines = [['node-listeners', 'GEA_UI_NODE_LISTENERS'], ['node-attributes', 'GEA_UI_NODE_ATTRIBUTES'], ['node-default-styles', 'GEA_UI_DEFAULT_STYLES']]
97
97
  const nodeFeatureDefines = [['node-images', 'GEA_UI_IMAGE_NODES'], ['node-inputs', 'GEA_UI_INPUT_NODES']]
98
+ // A separate marker: analyzers older than it never report node-videos.
99
+ const videoNodeAnalysis = 'node-video-analysis-v1'
100
+ const videoNodeMacro = 'GEA_UI_VIDEO_NODES'
98
101
  const rangeMacro = family => `GEA_CSS_U8_${family.replaceAll('-', '_').toUpperCase()}`
99
102
 
100
103
  export function withRendererFeatureDefines(defines, features, { devicePixelRatio } = {}) {
@@ -102,11 +105,13 @@ export function withRendererFeatureDefines(defines, features, { devicePixelRatio
102
105
  // version marker is not proof of unreachability: retain engine defaults.
103
106
  const generatedNames = new Set([...rendererFeatureDefines, ...cssFeatureVersions.flat(), ...nodeFeatureDefines, ...nodeAuxFeatureDefines, ...compactStyleDefines].map(([, name]) => name).concat(triangleOcclusionMacro, circleCacheMacros, rangeFamilies.map(rangeMacro), ['GEA_UI_CLASS_INLINE_TOKENS', 'GEA_UI_CLASS_OVERFLOW']))
104
107
  generatedNames.add('GEA_RUNTIME_REALMS')
108
+ generatedNames.add(videoNodeMacro)
105
109
  const result = defines.split(';').filter((define) => define && !generatedNames.has(define.split('=')[0]))
106
110
  if (features.includes('worker-realms')) result.push('GEA_RUNTIME_REALMS=1')
107
111
  if (features.includes('node-analysis-v1')) {
108
112
  for (const [feature, name] of nodeFeatureDefines) result.push(`${name}=${features.includes(feature) ? 1 : 0}`)
109
113
  }
114
+ if (features.includes(videoNodeAnalysis)) result.push(`${videoNodeMacro}=${features.includes('node-videos') ? 1 : 0}`)
110
115
  const storageProofs = features.filter(feature => feature.startsWith('css-storage-'))
111
116
  if (storageProofs.length && storageProofs.every(proof => proof === 'css-storage-v1')) {
112
117
  for (const [feature, name] of compactStyleDefines)
@@ -29,13 +29,14 @@ export function nativeCircleSourceNeedsSupport(text) {
29
29
  }
30
30
 
31
31
  export function withNativeCssFeatures(app, features) {
32
- if (!features.includes('renderer-occlusion-v1') && !features.includes('node-analysis-v1') && !features.includes('node-aux-v1') && !features.includes('css-storage-v1') && !features.some(feature => /^node-class-capacity-v1-[123]$/.test(feature)) && !features.some(feature => /^css-analysis-v(?:[1-9]|1[0123456789])$/.test(feature))) return features
32
+ if (!features.includes('renderer-occlusion-v1') && !features.includes('node-analysis-v1') && !features.includes('node-video-analysis-v1') && !features.includes('node-aux-v1') && !features.includes('css-storage-v1') && !features.some(feature => /^node-class-capacity-v1-[123]$/.test(feature)) && !features.some(feature => /^css-analysis-v(?:[1-9]|1[0123456789])$/.test(feature))) return features
33
33
  const sources = app.nativeSources || []
34
34
  const components = app.targetConfig?.esp32?.componentDirs || []
35
35
  if (!sources.length && !components.length) return features
36
36
  // The TS proof cannot bound custom native triangle producers, including
37
- // rendering hidden behind external headers or callback registration.
38
- features = [...new Set([...features, 'renderer-occlusion-triangles', 'node-listeners', 'node-attributes', 'node-default-styles'])]
37
+ // rendering hidden behind external headers or callback registration. Native
38
+ // code can also drive the video host directly.
39
+ features = [...new Set([...features, 'renderer-occlusion-triangles', 'node-listeners', 'node-attributes', 'node-default-styles', 'node-videos'])]
39
40
  // Opaque native CSS writes can supply gradient/transform values even when
40
41
  // every source-visible custom property is a literal colour. Keep their
41
42
  // renderer caches as well as semantic fields.
package/src/manifest.mjs CHANGED
@@ -90,6 +90,14 @@ export function validateApp(app) {
90
90
  }
91
91
  for (const [target, config] of Object.entries(app.targetConfig)) {
92
92
  const where = (field) => `gea.targets.${target}.${field}`
93
+ if (config.nativeSources.length && !TARGET_NATIVE_SOURCE_TARGETS.includes(target)) errors.push(`${where('nativeSources')} is supported only by ${TARGET_NATIVE_SOURCE_TARGETS.join(', ')}; use gea.nativeSources for every target`)
94
+ for (const source of config.nativeSources) {
95
+ if (!resolveAppSourcePath(app.root, source)) errors.push(`${where('nativeSources')} entry does not exist: ${source}`)
96
+ }
97
+ if (config.providers !== null && (typeof config.providers !== 'object' || Array.isArray(config.providers))) errors.push(`${where('providers')} must be an object keyed by capability`)
98
+ else if (Object.keys(config.providers).length && !TARGET_PROVIDER_TARGETS.includes(target)) errors.push(`${where('providers')} is supported only by ${TARGET_PROVIDER_TARGETS.join(', ')}`)
99
+ if (config.tsconfig && !TARGET_NATIVE_SOURCE_TARGETS.includes(target)) errors.push(`${where('tsconfig')} is supported only by ${TARGET_NATIVE_SOURCE_TARGETS.join(', ')}`)
100
+ else if (config.tsconfig && !exists(path.join(app.root, config.tsconfig))) errors.push(`${where('tsconfig')} does not exist: ${config.tsconfig}`)
93
101
  try { resolveNativeResources(app.root, target, config.nativeResources); resolveNativeLink(app.root, target, config) } catch (error) { errors.push(`${where('nativeLibraries/frameworks')}: ${error.message}`) }
94
102
  for (const fragment of config.ldFragments) {
95
103
  if (!exists(path.join(app.root, fragment))) errors.push(`${where('ldFragments')} entry does not exist: ${fragment}`)
@@ -235,6 +243,8 @@ export function appSummary(ctx, app) {
235
243
  // Absolute, already resolved: a target consuming these must not re-join
236
244
  // them to the app root, because a package entry does not live there.
237
245
  nativeSourcePaths: app.nativeSources.map((source) => resolveAppSourcePath(app.root, source)).filter((resolved) => resolved !== null),
246
+ // The same for gea.targets.<target>.nativeSources, keyed by target.
247
+ targetNativeSourcePaths: Object.fromEntries(Object.entries(app.targetConfig).map(([target, config]) => [target, config.nativeSources.map((source) => resolveAppSourcePath(app.root, source)).filter((resolved) => resolved !== null)])),
238
248
  compilerPlugins: app.compilerPlugins,
239
249
  defines: app.defines,
240
250
  cssDevicePixelRatio: app.cssDevicePixelRatio,
@@ -350,6 +360,14 @@ export function resolveAppSourcePath(root, source) {
350
360
  }
351
361
  }
352
362
 
363
+ // Targets whose build consumes per-target gea.targets.<target>.nativeSources,
364
+ // gea.targets.<target>.providers (runtime implementations a package requires,
365
+ // staged with the executable) and gea.targets.<target>.tsconfig (the
366
+ // TypeScript project the compiler reads the program under). The other targets
367
+ // take gea.nativeSources only.
368
+ const TARGET_NATIVE_SOURCE_TARGETS = ['windows']
369
+ const TARGET_PROVIDER_TARGETS = ['windows']
370
+
353
371
  export function normalizeNativeSources(raw) {
354
372
  if (!Array.isArray(raw)) return []
355
373
  // Shared native code can live beside an app's directory. These are explicit
@@ -398,7 +416,7 @@ export function normalizeDefines(raw) {
398
416
 
399
417
 
400
418
  function emptyTargetConfig() {
401
- return { nativeIncludeDirectories: [], nativeSystemLibraries: [], nativeResources: {}, nativeLibraries: [], frameworks: [], ldFragments: [], componentDirs: [], componentRequires: [], linkOptions: [], embedFiles: {}, partitions: null, partitionsByTarget: {}, sdkconfig: '', prebuild: '', output: '' }
419
+ return { nativeSources: [], providers: {}, tsconfig: '', nativeIncludeDirectories: [], nativeSystemLibraries: [], nativeResources: {}, nativeLibraries: [], frameworks: [], ldFragments: [], componentDirs: [], componentRequires: [], linkOptions: [], embedFiles: {}, partitions: null, partitionsByTarget: {}, sdkconfig: '', prebuild: '', output: '' }
402
420
  }
403
421
 
404
422
  function normalizeStringList(raw) {
@@ -465,6 +483,9 @@ function normalizeTargetConfig(raw) {
465
483
  for (const [name, value] of Object.entries(raw)) {
466
484
  if (!name || !value || typeof value !== 'object' || value.enabled === false) continue
467
485
  configs[name] = {
486
+ nativeSources: normalizeNativeSources(value.nativeSources),
487
+ providers: value.providers ?? {},
488
+ tsconfig: typeof value.tsconfig === 'string' && value.tsconfig.trim() ? normalizeManifestRelativePath(value.tsconfig) : '',
468
489
  nativeIncludeDirectories: value.nativeIncludeDirectories ?? [],
469
490
  nativeSystemLibraries: value.nativeSystemLibraries ?? [],
470
491
  nativeResources: value.nativeResources ?? {},
@@ -12,7 +12,7 @@ export function resolveNativeLink(root, target, config = {}) {
12
12
  }
13
13
  if (libraries.length && !['macos', 'raspberry-pi-os'].includes(target)) throw new Error(`nativeLibraries are not supported by ${target}`)
14
14
  if (frameworks.length && target !== 'macos') throw new Error('frameworks are supported only by macos')
15
- if ((includeDirectories.length || systemLibraries.length) && target !== 'raspberry-pi-os') throw new Error('Native include/system library extensions are supported only by raspberry-pi-os')
15
+ if ((includeDirectories.length || systemLibraries.length) && !['raspberry-pi-os', 'windows'].includes(target)) throw new Error('Native include/system library extensions are supported only by raspberry-pi-os and windows')
16
16
  const includes = includeDirectories.map(value => {
17
17
  if (path.isAbsolute(value) || value.split(/[\\/]/).includes('..') || /[\x00-\x1f\x7f]/.test(value)) throw new Error('Invalid nativeIncludeDirectories entry')
18
18
  const directory = fs.realpathSync(path.join(realRoot,value)), relative=path.relative(realRoot,directory)
@@ -6,7 +6,7 @@ function fileHash(file){const fd=fs.openSync(file,'r'),hash=crypto.createHash('s
6
6
  const safeName=value=>typeof value==='string' && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value) && !['Fonts','FontLicenses','Frameworks','MacOS'].includes(value)
7
7
  export function resolveNativeResources(root, target, raw = {}) {
8
8
  if(!raw||typeof raw!=='object'||Array.isArray(raw))throw Error('nativeResources must be a destination-to-directory object')
9
- if(Object.keys(raw).length && !['macos','raspberry-pi-os'].includes(target))throw Error(`nativeResources are not supported by ${target}`)
9
+ if(Object.keys(raw).length && !['macos','raspberry-pi-os','windows'].includes(target))throw Error(`nativeResources are not supported by ${target}`)
10
10
  const base=fs.realpathSync(root),result={};let count=0,total=0
11
11
  for(const [name,value]of Object.entries(raw)){
12
12
  if(!safeName(name)||typeof value!=='string'||!value||path.isAbsolute(value)||value.split(/[\\/]/).includes('..')||/[\x00-\x1f\x7f]/.test(value))throw Error('Invalid nativeResources destination or source')
@@ -32,28 +32,39 @@ export function runWindows({ app, env, dryRun = false, stdout, run = false }) {
32
32
  const plugins = geatscPluginsOf(app, require)
33
33
  if (plugins.length > 0) childEnv.GEA_EXTRA_GEATSC_PLUGINS = plugins.join(path.delimiter)
34
34
  const scriptArgs = [script, app.id, ...(run ? ['--run'] : [])]
35
+ // gea.targets.windows.prebuild: a command run in the app folder before the
36
+ // build reads anything, e.g. one generating assets the build stages or
37
+ // sources it compiles (the manifest is validated after it).
38
+ const prebuild = app.targetConfig?.windows?.prebuild ?? ''
35
39
  if (dryRun) {
40
+ if (prebuild) stdout(prebuild)
36
41
  stdout(formatCommand(['node', ...scriptArgs]))
37
42
  return 0
38
43
  }
44
+ if (prebuild) {
45
+ stdout(`App prebuild: ${prebuild}`)
46
+ const step = spawnSync(prebuild, { cwd: app.root, env, shell: true, stdio: 'inherit' })
47
+ if (step.error) throw new CliError(`App prebuild failed to start: ${step.error.message}`, ExitCode.deployFailed)
48
+ if (step.status !== 0) throw new CliError(`App prebuild exited ${step.status ?? 1}: ${prebuild}`, ExitCode.deployFailed)
49
+ }
39
50
  const result = spawnSync(process.execPath, scriptArgs, { cwd: app.root, env: childEnv, stdio: 'inherit' })
40
51
  if (result.error) throw result.error
41
52
  if (result.status !== 0) throw new CliError(`Windows build failed (${result.status ?? 1}).`, ExitCode.deployFailed)
42
53
  return 0
43
54
  }
44
55
 
45
- // Compiler plugins come from the packages the app depends on, exactly as the
46
- // macOS adapter collects them: each ships its own `./geatsc-plugin` export,
47
- // and an app-owned geatsc-plugin.mjs is the whole list when present.
48
- function geatscPluginsOf(app, require) {
49
- const own = path.join(app.root, 'geatsc-plugin.mjs')
50
- if (existsSync(own)) return [own]
56
+ // Compiler plugins: every package the app depends on that ships a
57
+ // `./geatsc-plugin` export, then the app's own geatsc-plugin.mjs, then its
58
+ // gea.compilerPlugins (as on every native target). They compose: an app plugin
59
+ // declaring the app's own host functions does not displace the plugins of the
60
+ // packages the program uses, whose host functions it calls as well.
61
+ export function geatscPluginsOf(app, require) {
51
62
  const plugins = []
52
63
  let manifest = {}
53
64
  try {
54
65
  manifest = JSON.parse(readFileSync(path.join(app.root, 'package.json'), 'utf8'))
55
66
  } catch {
56
- return plugins
67
+ manifest = {}
57
68
  }
58
69
  for (const name of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {
59
70
  try {
@@ -62,5 +73,8 @@ function geatscPluginsOf(app, require) {
62
73
  // The package ships no plugin, which is the normal case.
63
74
  }
64
75
  }
65
- return plugins
76
+ const own = path.join(app.root, 'geatsc-plugin.mjs')
77
+ if (existsSync(own)) plugins.push(own)
78
+ plugins.push(...(app.compilerPlugins ?? []).map((plugin) => path.join(app.root, plugin)))
79
+ return [...new Set(plugins)]
66
80
  }