@geastack/apple 0.2.28 → 0.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/apple",
3
- "version": "0.2.28",
3
+ "version": "0.2.29",
4
4
  "description": "Generated Apple SDK bindings plus the macOS, iOS and tvOS native build targets for Gea apps.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -116,9 +116,9 @@
116
116
  },
117
117
  "dependencies": {
118
118
  "@geastack/compiler": "^1.0.34",
119
- "@geastack/core": "^0.1.57",
119
+ "@geastack/core": "^0.1.59",
120
120
  "@geastack/elements": "^0.1.7",
121
- "@geastack/engine": "^0.1.23",
121
+ "@geastack/engine": "^0.1.28",
122
122
  "@geastack/geaos": "^0.1.3",
123
123
  "@geastack/geatsc-plugin-apple-native": "^0.1.4",
124
124
  "@geastack/geatsc-plugin-gea": "^0.1.28",
@@ -907,6 +907,10 @@ CXX_DEFINES=(
907
907
  # builds keep their baked atlas: the runtime path tries first, finds no
908
908
  # registered TTF bytes there, and falls through.
909
909
  -DGEA_EMBEDDED_TTF_RUNTIME_FONTS=1
910
+ # Runtime TTF slots cover the glyphs the generated font TU declares
911
+ # (runtimeTtfDeclaredCodepoints: the baseline plus the app's
912
+ # --gea-font-charset names), not just ASCII and two extras.
913
+ -DGEA_EMBEDDED_TTF_RUNTIME_DECLARED_GLYPHS=128
910
914
  )
911
915
  if [[ "${GEA_NATIVE_DEBUGGER:-0}" == "1" ]]; then
912
916
  [[ -f "${GEA_DEBUGGER_NATIVE_SOURCE:-}" ]] || { echo "GEA_DEBUGGER_NATIVE_SOURCE must name debugger/native/macos.mm" >&2; exit 2; }
@@ -1069,6 +1073,11 @@ if [[ ${#RESIDENT_IDS[@]} -eq 0 ]]; then
1069
1073
  # apple-native mode — generated app modules may be Objective-C++, this never is.
1070
1074
  if [[ "$THERMALRIGHT_DISPLAY_TARGET" == "1" && -f "$GENERATED_FONT_CPP" ]]; then
1071
1075
  CXX_SOURCES+=("$GENERATED_FONT_CPP")
1076
+ elif [[ -f "$GENERATED_FONT_CPP" ]]; then
1077
+ # The windowed build skips the font TU, so carry its declared glyph set
1078
+ # (baseline + --gea-font-charset) to the runtime TTF slots on its own.
1079
+ node "$ROOT_DIR/targets/macos/runtime-glyphs.mjs" --out "$GENERATED_DIR/gea_runtime_glyphs_generated.cpp" "$GENERATED_FONT_CPP"
1080
+ CXX_SOURCES+=("$GENERATED_DIR/gea_runtime_glyphs_generated.cpp")
1072
1081
  fi
1073
1082
  [[ -f "$GENERATED_ASSETS_CPP" ]] && CXX_SOURCES+=("$GENERATED_ASSETS_CPP")
1074
1083
  else
@@ -1079,6 +1088,12 @@ else
1079
1088
  CXX_SOURCES+=("$RESIDENT_REGISTRY_CPP")
1080
1089
  for f in "${RESIDENT_GEATSC_SOURCES[@]}"; do CXX_SOURCES+=("$f"); done
1081
1090
  for f in "${RESIDENT_FONT_CPPS[@]}"; do CXX_SOURCES+=("$f"); done
1091
+ # Resident font TUs prefix their symbols; the runtime TTF slots read the
1092
+ # union of every resident's declared glyph set through the unprefixed hook.
1093
+ if [[ ${#RESIDENT_FONT_CPPS[@]} -gt 0 ]]; then
1094
+ node "$ROOT_DIR/targets/macos/runtime-glyphs.mjs" --out "$GENERATED_DIR/gea_runtime_glyphs_generated.cpp" "${RESIDENT_FONT_CPPS[@]}"
1095
+ CXX_SOURCES+=("$GENERATED_DIR/gea_runtime_glyphs_generated.cpp")
1096
+ fi
1082
1097
  for f in "${RESIDENT_ASSET_CPPS[@]}"; do CXX_SOURCES+=("$f"); done
1083
1098
  for f in "${RESIDENT_ENTRY_CPPS[@]}"; do CXX_SOURCES+=("$f"); done
1084
1099
  fi
@@ -2096,6 +2111,7 @@ else
2096
2111
  done
2097
2112
  fi
2098
2113
  for d in "${APP_DIRS_FOR_FONTS[@]}"; do
2114
+ GEA_FONT_MODULE_GRAPH="$GENERATED_DIR/module-graph/gea-module-graph.json" \
2099
2115
  node -e "
2100
2116
  const fs = require('fs');
2101
2117
  const path = require('path');
@@ -2110,6 +2126,11 @@ for d in "${APP_DIRS_FOR_FONTS[@]}"; do
2110
2126
  if (entry.name === 'node_modules' || entry.name === 'dist') continue;
2111
2127
  walk(full);
2112
2128
  } else if (entry.isFile() && entry.name.endsWith('.css')) {
2129
+ visit(full);
2130
+ }
2131
+ }
2132
+ }
2133
+ function visit(full) {
2113
2134
  const css = fs.readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
2114
2135
  const re = /@font-face\s*\{([^}]+)\}/gi;
2115
2136
  let m;
@@ -2128,6 +2149,19 @@ for d in "${APP_DIRS_FOR_FONTS[@]}"; do
2128
2149
  fs.copyFileSync(resolved, dest);
2129
2150
  console.log(' copied font:', base);
2130
2151
  }
2152
+ }
2153
+ // CSS the app imports from workspace packages lives outside its own dir;
2154
+ // the module graph names every stylesheet the bundle actually pulled in.
2155
+ const graph = process.env.GEA_FONT_MODULE_GRAPH;
2156
+ if (graph && fs.existsSync(graph)) {
2157
+ const seen = new Set();
2158
+ const modules = JSON.parse(fs.readFileSync(graph, 'utf8')).modules || [];
2159
+ const list = Array.isArray(modules) ? modules : Object.values(modules);
2160
+ for (const m of list) {
2161
+ for (const p of [m.file, m.id, ...((m.imports || []).map((i) => i && i.resolvedId))]) {
2162
+ if (typeof p !== 'string' || !p.endsWith('.css') || seen.has(p) || !fs.existsSync(p)) continue;
2163
+ seen.add(p);
2164
+ visit(p);
2131
2165
  }
2132
2166
  }
2133
2167
  }
@@ -2167,6 +2201,12 @@ else
2167
2201
  for d in ${APP_DIRS_FOR_FONTS[@]+"${APP_DIRS_FOR_FONTS[@]}"}; do
2168
2202
  RESOURCE_SYNC_ARGS+=(--app-dir "$d")
2169
2203
  done
2204
+ # Stylesheets imported from workspace packages sit outside every app dir;
2205
+ # the module graph lists each one the bundle pulled in.
2206
+ for graph in "$GENERATED_DIR/module-graph/gea-module-graph.json" \
2207
+ "$GENERATED_DIR"/residents/*/module-graph/gea-module-graph.json; do
2208
+ [[ -f "$graph" ]] && RESOURCE_SYNC_ARGS+=(--module-graph "$graph")
2209
+ done
2170
2210
  RESOURCE_SYNC_RESULT="$(node "$ROOT_DIR/targets/macos/sync-resources.mjs" "${RESOURCE_SYNC_ARGS[@]}")"
2171
2211
  if [[ "$RESOURCE_SYNC_RESULT" == *'changed=1'* ]]; then BUNDLE_CONTENT_CHANGED=1; fi
2172
2212
  fi
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ // Writes the TU that tells the engine's runtime TTF slots which glyphs beyond
3
+ // printable ASCII to cover (generated::runtimeTtfDeclaredCodepoints).
4
+ //
5
+ // The font generator puts that set -- its raster baseline plus every
6
+ // `--gea-font-charset` the app's CSS names -- into gea_embedded_font_generated.cpp,
7
+ // but a windowed macOS build does not link that TU (it carries baked atlases the
8
+ // window never uses), and resident builds prefix its symbols. Without this file
9
+ // the engine's weak default applies and `·`, `€`, `–` render as `?`.
10
+ //
11
+ // usage: runtime-glyphs.mjs --out <file.cpp> <gea_embedded_font_generated.cpp>...
12
+ import fs from 'node:fs'
13
+
14
+ const args = process.argv.slice(2)
15
+ const outIndex = args.indexOf('--out')
16
+ if (outIndex < 0 || !args[outIndex + 1]) {
17
+ console.error('usage: runtime-glyphs.mjs --out <file.cpp> <font-generated.cpp>...')
18
+ process.exit(2)
19
+ }
20
+ const out = args[outIndex + 1]
21
+ const inputs = args.filter((_, i) => i !== outIndex && i !== outIndex + 1)
22
+
23
+ const codepoints = new Set()
24
+ for (const input of inputs) {
25
+ if (!fs.existsSync(input)) continue
26
+ const match = fs.readFileSync(input, 'utf8').match(/kRuntimeTtfDeclaredCodepoints\[\]\s*=\s*\{([^}]*)\}/)
27
+ if (!match) continue
28
+ for (const token of match[1].split(',')) {
29
+ const value = Number(token.trim())
30
+ if (Number.isInteger(value) && value > 0x7e) codepoints.add(value)
31
+ }
32
+ }
33
+ const list = [...codepoints].sort((a, b) => a - b)
34
+ const source = [
35
+ '// Generated by @geastack/apple targets/macos/runtime-glyphs.mjs. Do not edit.',
36
+ 'namespace gea::framework::graphics::generated {',
37
+ '',
38
+ `static const int kDeclared[] = {${list.length > 0 ? list.map((cp) => `0x${cp.toString(16)}`).join(', ') : '0'}};`,
39
+ '',
40
+ 'const int *runtimeTtfDeclaredCodepoints(int *count)',
41
+ '{',
42
+ ` if (count) *count = ${list.length};`,
43
+ ' return kDeclared;',
44
+ '}',
45
+ '',
46
+ '} // namespace gea::framework::graphics::generated',
47
+ '',
48
+ ].join('\n')
49
+ if (!fs.existsSync(out) || fs.readFileSync(out, 'utf8') !== source) fs.writeFileSync(out, source)
@@ -30,9 +30,10 @@ const manifestPath = path.resolve(value('--manifest') || '')
30
30
  const configDir = value('--config-dir') ? path.resolve(value('--config-dir')) : ''
31
31
  const appDirs = values('--app-dir').map((item) => path.resolve(item))
32
32
  const sharedCssDirs = values('--shared-css-dir').map((item) => path.resolve(item))
33
+ const moduleGraphs = values('--module-graph').map((item) => path.resolve(item))
33
34
 
34
35
  if (!value('--resources-dir') || !value('--manifest')) {
35
- fail('usage: sync-resources.mjs --resources-dir <dir> --manifest <file> [--config-dir <dir>] [--app-dir <dir> ...] [--shared-css-dir <dir> ...]')
36
+ fail('usage: sync-resources.mjs --resources-dir <dir> --manifest <file> [--config-dir <dir>] [--app-dir <dir> ...] [--shared-css-dir <dir> ...] [--module-graph <gea-module-graph.json> ...]')
36
37
  }
37
38
 
38
39
  fs.mkdirSync(resourcesDir, { recursive: true })
@@ -71,6 +72,28 @@ function isSafeBasename(value) {
71
72
  return value !== '.' && value !== '..' && path.basename(value) === value && !value.includes('/') && !value.includes('\\')
72
73
  }
73
74
 
75
+ // Every stylesheet the compiled app imports, from the module graph its build
76
+ // wrote. This is the authority on which @font-face rules the app uses:
77
+ // walking the app's own folder misses CSS reached through imports, such as a
78
+ // workspace package of shared styles (import "../../shared").
79
+ function moduleGraphCss(graphPath) {
80
+ let graph
81
+ try {
82
+ graph = JSON.parse(fs.readFileSync(graphPath, 'utf8'))
83
+ } catch {
84
+ return []
85
+ }
86
+ const files = new Set()
87
+ for (const module of Array.isArray(graph?.modules) ? graph.modules : []) {
88
+ for (const id of [module?.file, module?.id, ...(Array.isArray(module?.imports) ? module.imports.map((item) => item?.resolvedId) : [])]) {
89
+ if (typeof id !== 'string') continue
90
+ const file = id.split(/[?#]/, 1)[0]
91
+ if (file.endsWith('.css') && fs.existsSync(file) && fs.statSync(file).isFile()) files.add(file)
92
+ }
93
+ }
94
+ return [...files]
95
+ }
96
+
74
97
  function walkCss(root, visit) {
75
98
  if (!root || !fs.existsSync(root)) return
76
99
  for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
@@ -87,8 +110,7 @@ function walkCss(root, visit) {
87
110
  const desiredFonts = new Map()
88
111
  const desiredFontLicenses = new Map()
89
112
  const fontAliases = new Map()
90
- for (const root of [...appDirs, ...sharedCssDirs]) {
91
- walkCss(root, (cssPath) => {
113
+ function visitCss(cssPath) {
92
114
  const css = fs.readFileSync(cssPath, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '')
93
115
  const facePattern = /@font-face\s*\{([^}]+)\}/gi
94
116
  let face
@@ -119,9 +141,11 @@ for (const root of [...appDirs, ...sharedCssDirs]) {
119
141
  }
120
142
  }
121
143
  }
122
- })
123
144
  }
124
145
 
146
+ for (const graph of moduleGraphs) for (const cssPath of moduleGraphCss(graph)) visitCss(cssPath)
147
+ for (const root of [...appDirs, ...sharedCssDirs]) walkCss(root, visitCss)
148
+
125
149
  let previousFonts = []
126
150
  try {
127
151
  const previous = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))