stac-custom-extensions

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Stac Custom Extensions

Stac 自定义扩展

Overview

概述

Use this skill to add custom widgets/actions that serialize cleanly and register correctly in a Stac app.
使用此技能可添加能在Stac应用中正确序列化和注册的自定义组件/动作。

Workflow

工作流程

  1. Choose extension type: widget or action.
  2. Scaffold model and parser files with scripts.
  3. Add generated files to app codebase and run codegen.
  4. Verify parser registration in
    main.dart
    .
  5. Validate runtime wiring with a minimal usage example.
  1. 选择扩展类型:组件(Widget)或动作(Action)。
  2. 使用脚本搭建模型和解析器文件。
  3. 将生成的文件添加到应用代码库并运行代码生成工具。
  4. main.dart
    中验证解析器注册。
  5. 通过最小化使用示例验证运行时连接。

Required Inputs

必要输入

  • PascalCase extension name.
  • Runtime type id (
    type
    or
    actionType
    ).
  • Output directory for generated files.
  • Path to
    main.dart
    for registration check.
  • 采用帕斯卡命名法(PascalCase)的扩展名称。
  • 运行时类型ID(
    type
    actionType
    )。
  • 生成文件的输出目录。
  • 用于注册检查的
    main.dart
    路径。

Output Contract

输出约定

  • Produce model + parser pair with consistent type ids.
  • Include registration snippet for
    Stac.initialize
    .
  • Include
    build_runner
    command when json serialization is used.
  • 生成具有一致类型ID的模型+解析器对。
  • 包含用于
    Stac.initialize
    的注册代码片段。
  • 当使用JSON序列化时,包含
    build_runner
    命令。

References

参考资料

  • Read
    references/custom-widget-checklist.md
    for widget model/parser flow.
  • Read
    references/custom-action-checklist.md
    for action model/parser flow.
  • Read
    references/parser-registration.md
    for initialization wiring.
  • Read
    references/converters-guide.md
    for converter usage patterns.
  • 阅读
    references/custom-widget-checklist.md
    了解组件模型/解析器流程。
  • 阅读
    references/custom-action-checklist.md
    了解动作模型/解析器流程。
  • 阅读
    references/parser-registration.md
    了解初始化连接方式。
  • 阅读
    references/converters-guide.md
    了解转换器使用模式。

Scripts

脚本

  • scripts/scaffold_custom_widget.py --name <Name> --type <widgetType> --out-dir <path>
  • scripts/scaffold_custom_action.py --name <Name> --action-type <actionType> --out-dir <path>
  • scripts/check_parser_registration.py --main-dart <path> --parser-class <ClassName>
  • scripts/scaffold_custom_widget.py --name <Name> --type <widgetType> --out-dir <path>
  • scripts/scaffold_custom_action.py --name <Name> --action-type <actionType> --out-dir <path>
  • scripts/check_parser_registration.py --main-dart <path> --parser-class <ClassName>

Templates

模板

  • assets/templates/custom_widget.dart.tmpl
  • assets/templates/custom_widget_parser.dart.tmpl
  • assets/templates/custom_action.dart.tmpl
  • assets/templates/custom_action_parser.dart.tmpl
  • assets/templates/custom_widget.dart.tmpl
  • assets/templates/custom_widget_parser.dart.tmpl
  • assets/templates/custom_action.dart.tmpl
  • assets/templates/custom_action_parser.dart.tmpl