Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-application

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Configure createAirApp options, canvas, lifecycle, screen sizing and context health. Use for WEBGL2_REQUIRED startup errors, scene replacement, session cleanup or lost contexts.

  • 10 files
  • 88.2 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-application

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontracts.md

≈986 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-application skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Contracts

  • Canvas admission: the browser main entry may be imported before canvas creation. Pass a selected attached canvas to createAirApp; parameter admission precedes PAL screen/input binding. Custom IDs are retained; do not assign pre-import globals or use removed light package entries.
  • One runtime per document: admission state lives in globalThis[Symbol.for('cocosair.bootstrap.v1')] with status idle | initializing | ready | failed | closed (src/air/app-config.ts:16-30). Identical normalized options share the init Promise and the app; any difference in the compared fields rejects AIR_E_APP_CONFLICT; closed rejects AIR_E_APP_CLOSED; failed rejects AIR_E_APP_RELOAD_REQUIRED (:149-157). equalAirOptions (:114-121) compares the canvas/container elements and the contextLoss.reload/contextLoss.onEvent callbacks by identity, the remaining scalars and the three designResolution numbers by value, so a fresh inline arrow in a second createAirApp call rejects AIR_E_APP_CONFLICT - pass a stable options object. Rebuilding the low-level runtime requires a whole-page reload.
  • Option ranges are hard, not advisory: renderMode must be an integer 0..3 (engine WEBGPU = 4 is rejected at the AIR surface, and 1/CANVAS passes validation but starts no device - see the renderMode rows in app-options.md and startup-errors.md), pixelRatioCap a finite positive number (default 2, or a usable __CCDPR_CAP__), designResolution.policy one of 0..4 with finite positive width/height (src/air/app-config.ts:63-75). Out of range throws; nothing is clamped or ignored.
  • Startup is a fixed pipeline, and the DPR cap only counts when it lands before the PAL evaluates: context-health attach -> diagnostics channel -> physics selector -> game.init -> view.setDesignResolutionSize -> the caller's first run(), with teardown before rethrow on init failure, the AIR_E_PIXEL_RATIO_IMPORT_ORDER / AIR_E_CANVAS_IMPORT_ORDER checks and the round(CSS size * min(devicePixelRatio, cap)) buffer formula all line-cited in app-options.md (Startup order).
  • Lifecycle gates in run() fire in this code order (src/air/app.ts:135-159): closed -> AIR_E_APP_CLOSED; release in flight -> AIR_E_SCENE_RELEASING; previous release failed -> AIR_E_SCENE_RELEASE_FAILED; not a valid native Scene -> AIR_E_SCENE; re-running the current scene -> silent no-op (:140), checked before the ownership gate; only a replacement scene then meets AIR_E_SCENE_RELEASE_REQUIRED while the current scope owns cleanup callbacks (:141-143). close() pauses the loop, releases the scene, destroys context-health and diagnostics listeners and marks the registry closed only when this app is the registry's app (src/air/app.ts:202-203); it does not restore a lost GL context and does not make the document reusable. Tables: app-options.md and startup-errors.md.
  • Cleanup is cooperative with a hard deadline and context health never self-heals: session.dispose() defaults to 5000 ms and accepts only (0, 5000], and own() returns a function that unregisters the callback and never runs it (src/air/session-scope.ts:50-55, :66-71; session-scope.md); webglcontextrestored transitions restoring then immediately failed, because no GPU resource is rebuilt (src/air/context-health.ts:171-177; context-health.md).
  • Capability layers stay separate: consult build/cocosair.module.d.ts and the installed main exports for API shape; source/bundle presence does not establish current browser verification. There are no separate startup declarations.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "createAirApp rejects options or fails startup",
  "replace or release the running scene",
  "app closed and will not restart",
  "fit a container or set design resolution",
  "lost context or scene cleanup stalls"
]
owns
[
  "startup-admission",
  "app-lifecycle",
  "screen-sizing",
  "context-health",
  "session-cleanup"
]
not_for
[
  "package imports or page shell -> cocosair-project-setup",
  "persistent SceneStack pages -> cocosair-input-action",
  "live-session inspection -> cocosair-agent-session"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置 createAirApp 和应用生命周期、屏幕尺寸、会话清理及 WebGL 上下文健康。用于启动错误、场景替换、关闭和自定义 canvas。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-application