Skip to content

交付可运行的首个组件示例 / Ship a runnable first-component example #24

Description

@tiye

中文

用户问题

当前 quick start 的代码块容易阅读,但用户不能直接运行它,也无法确认复制后的模块是否真的只依赖公共 author API。第一次成功体验仍然需要理解 demo、runtime frame 和浏览器 bridge,反馈周期太长。

目标

提供一个仓库内可直接执行、持续编译验证的 first-component 示例,让新用户在几分钟内看到一个带 typed store/action 的组件完成 render 与状态 transition,再按链接进入完整浏览器 demo。

范围

  • 增加独立 examples/first-component component module,只使用公共 component-author import。
  • 增加最小 host/entry,运行初始 render 和一个 typed action transition,并输出可读结果。
  • 提供稳定的 yarn example:first-component 命令。
  • quick start 直接引用经过编译的示例,而不是维护第二份容易漂移的代码。
  • CI/check 覆盖示例编译与执行。

验收标准

  • clean checkout 后运行 yarn example:first-component 即可成功。
  • 输出能清楚显示初始 UI、typed action 和更新后的 UI/state。
  • component module 不导入 runtime、inspection 或 renderer。
  • 文档代码与可运行源码只有一个事实来源。
  • yarn test:koka 与 yarn check 通过。

非目标

  • 新建完整脚手架 CLI。
  • 在本 issue 中发布 npm/Koka package。
  • 复制现有完整 Todo/Lab demo。
  • 把浏览器 DOM bridge 塞进 component example。

English

User problem

The current quick-start snippets are readable but cannot be executed directly, and users cannot tell whether a copied module truly depends only on the public author API. The first successful experience still requires understanding the demo, runtime frame, and browser bridge, which makes the feedback loop too long.

Goal

Provide an immediately runnable and continuously compiled first-component example in the repository. A new user should see a component with a typed store/action render and complete one state transition within minutes, then follow a link to the full browser demo.

Scope

  • Add an independent examples/first-component component module using only the public component-author import.
  • Add a minimal host/entry that runs the initial render and one typed action transition and prints readable results.
  • Provide a stable yarn example:first-component command.
  • Make the quick start reference compiled example source instead of maintaining a second drifting copy.
  • Cover example compilation and execution in CI/check.

Acceptance criteria

  • yarn example:first-component succeeds from a clean checkout.
  • Output clearly shows the initial UI, typed action, and updated UI/state.
  • The component module imports no runtime, inspection, or renderer module.
  • Documentation and runnable source have one source of truth.
  • yarn test:koka and yarn check pass.

Non-goals

  • Building a complete scaffolding CLI.
  • Publishing an npm or Koka package in this issue.
  • Copying the full Todo or Lab demo.
  • Putting the browser DOM bridge inside the component example.

Activity

  1. added
    documentationImprovements or additions to documentation
    enhancementNew feature or request
    area: authoring组件作者 API / Component authoring API
    experience: onboarding首次运行与学习路径 / First-run and learning path
    priority: now当前开发批次 / Current development batch
    status: in progress当前正在推进 / Active implementation
    and removed on Aug 31, 2026
  2. tiye commented on Aug 31, 2026

    @tiye
    MemberAuthor

    中文

    当前实施计划

    本轮把 #24 作为当前 onboarding 工作。目标不是再写一份教程代码,而是建立一条“公共组件模块 → 极小执行 host → 稳定命令 → 文档链接”的单一事实来源。

    1. 新增 examples/first-component/component.kk:只 import explore/react,包含一个 FAQ/disclosure 的 typed store、serializable action 和带 keyed boundary 的 view;它不依赖 runtime、inspection 或 renderer。
    2. 新增 examples/first-component/main.kk:作为明确的 advanced host,负责在内存中运行初始 render、发送一次 Toggle typed action、再次 render,并输出初始 HTML、action 与更新后的 HTML/state。
    3. 新增 yarn example:first-component:使用独立 .koka-example build directory 执行该 entry;再由 yarn check 调用,保证 clean checkout 的命令路径持续可用。
    4. 将 quick start 从重复的 FAQ 代码块改为概念说明、运行命令、预期输出和指向已编译源码的链接;README/component authoring guide 只链接该路径,不复制第二份实现。
    5. 添加一个轻量 Koka assertion 或命令级 check,验证公共 import 边界、初始 render、action observation 和 transition 后的 render;随后运行 yarn example:first-component、yarn test:koka、yarn check 与浏览器回归。

    设计边界

    完成信号

    命令输出应能在一屏内读出:初始 closed UI、Toggle_disclosure intent、以及 updated open UI。完成后将创建双语 PR,并把 #24 更新为 status: shipped;#25 再成为 priority: now。

    English

    Current implementation plan

    This round makes #24 the active onboarding work. The goal is not another copy of tutorial code; it is one source of truth through a “public component module → tiny executable host → stable command → documentation links” path.

    1. Add examples/first-component/component.kk: it uses only import explore/react and contains a FAQ/disclosure typed store, serializable action, and keyed-boundary view. It imports no runtime, inspection, or renderer module.
    2. Add examples/first-component/main.kk: this explicit advanced host runs an in-memory initial render, sends one typed Toggle action, renders again, and prints initial HTML, the action, and updated HTML/state.
    3. Add yarn example:first-component: it executes the entry with a separate .koka-example build directory; yarn check will invoke it so the clean-checkout command path remains continuously valid.
    4. Change the quick start from duplicate FAQ code blocks to concept guidance, the run command, expected output, and links to the compiled source. README/component-authoring guidance will link this path instead of copying a second implementation.
    5. Add a lightweight Koka assertion or command-level check for the public-import boundary, initial render, action observation, and post-transition render; then run yarn example:first-component, yarn test:koka, yarn check, and browser regression.

    Design boundaries

    Completion signal

    The command output should fit on one screen and show an initial closed UI, the Toggle_disclosure intent, and an updated open UI. Completion creates a bilingual PR and moves #24 to status: shipped; #25 then becomes priority: now.

  3. tiye commented on Aug 31, 2026

    @tiye
    MemberAuthor

    中文

    首个实现批次已提交为 PR #28:

    • examples/first_component/component.kk 只使用公共 import explore/react,演示 typed store、serializable action、use_store、feature_root 与 on_store_click;
    • examples/first_component/main.kk 明确作为 advanced host,在内存中完成 initial render、registered click、action observation 和 updated render;
    • yarn example:first-component 会编译、执行并校验 closed → Toggle_disclosure → open 输出,yarn check 也会持续运行它;
    • quick start 改为链接真实源码,README、authoring guide、开发指南与路线图已同步;
    • 已通过 Koka tests、完整 check 和浏览器 Todo/route 回归。

    等待 PR review;合并后将关闭 #24、标记 shipped,并把 #25 提升为当前 onboarding/debugging 批次。

    English

    The first implementation batch is available in PR #28:

    • examples/first_component/component.kk uses only the public import explore/react and demonstrates a typed store, serializable action, use_store, feature_root, and on_store_click;
    • examples/first_component/main.kk is explicitly the advanced host, completing an in-memory initial render, registered click, action observation, and updated render;
    • yarn example:first-component compiles, executes, and validates the closed → Toggle_disclosure → open output, and yarn check now runs it continuously;
    • the quick start links to real source, while the README, authoring guide, developer guide, and roadmap are synchronized;
    • Koka tests, the full check, and browser Todo/routing regression all pass.

    The work awaits PR review. After merge, #24 will close and be marked shipped; #25 becomes the active onboarding/debugging batch.

  4. added and removed
    priority: now当前开发批次 / Current development batch
    status: in progress当前正在推进 / Active implementation
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: authoring组件作者 API / Component authoring APIdocumentationImprovements or additions to documentationenhancementNew feature or requestexperience: onboarding首次运行与学习路径 / First-run and learning pathstatus: shipped已经合并 / Already merged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions