算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
stackblitz-sdk-patterns【设计与创意】Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: stackblitz-sdk-patterns description: >- Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter". argument-hint: "[project-path] [runtime-module]" allowed-tools: Read, Glob, Grep, WebFetch, Write, Edit version: 1.7.0 author: Jeremy Longshore jeremy@intentsolutions.io license: MIT tags:
This skill creates or reviews one application-owned boundary around WebContainer startup and capabilities. The adapter makes boot idempotent, exposes explicit runtime states, tracks event unsubscriptions and processes, and prevents UI components from independently manipulating a shared instance.
@webcontainer/api type definitions as the local API authorityUse Read, Glob, and Grep to map imports, boot calls, process ownership, filesystem mutations, event subscriptions, and teardown paths. Use WebFetch only for current official StackBlitz or WebContainers documentation. Use Write or Edit after proposing the adapter boundary and compatibility impact.
on() and the handles returned by spawn().export() as explicit data operations with caller-owned paths and size bounds.teardown() invalidates the instance, processes, and filesystem; call it only at the permanent owner boundary.setPreviewScript only after reviewing its advanced-feature warning and compatibility risk.The adapter may accept already-resolved configuration but must not expose secret values through state, logs, errors, or browser storage. Initialize commercial keys and organization auth before adapter boot through the dedicated preflight layer.
Do not migrate all consumers, change persistent/export behavior, terminate active processes, or alter production preview instrumentation without explicit scope. Show the compatibility plan and rollback before replacing an existing runtime singleton.
Return the lifecycle inventory, proposed state machine and API, migrated call sites, concurrency and cleanup evidence, authentication boundary, compatibility risks, and rollback procedure.
| Condition | Response |
|---|---|
| Concurrent callers race | Share one boot promise and test simultaneous acquisition. |
| Process output never closes | Apply cancellation and output bounds; retain the process handle. |
| A consumer tears down globally | Move teardown to the permanent owner and give consumers scoped unsubscribe methods. |
| Installed types differ from docs | Follow the pinned local types and record the planned version review. |
Given three React components that each call boot(), replace them with one tested adapter whose cached promise owns the runtime while components receive scoped filesystem, process, and subscription capabilities.