feat: add @hikkaku/gobox#142
Conversation
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 78.68% 80.72% +2.03%
==========================================
Files 46 50 +4
Lines 3542 4098 +556
Branches 499 595 +96
==========================================
+ Hits 2787 3308 +521
- Misses 534 548 +14
- Partials 221 242 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new @hikkaku/gobox package that provides higher-level typed value, signal, and function abstractions on top of the core hikkaku library. The PR adds scoped memory management using list-backed runtime, reactive signals with procedure-based effects, struct/trait systems, and custom function definitions with return values.
Changes:
- Adds
@hikkaku/goboxpackage with value, types, and functions modules implementing a type system, scoped memory management, signals/effects, and custom functions - Introduces unstable build-scope APIs in hikkaku core (
__unstable_getBuildTarget,__unstable_getBuildScopeFrame,__unstable_onBuildScopeExit,__unstable_forbidStopInCurrentScope) to support gobox's scope management - Adds
examples/gobox-counterdemonstrating struct, trait, useImpl, useSignal, and useEffect usage - Updates publish workflow to support gobox package releases and enforce non-empty repository field validation
Reviewed changes
Copilot reviewed 26 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hikkaku/src/core/project.ts | Adds build target stack to track current target during run() |
| packages/hikkaku/src/core/composer.ts | Implements build scope tracking with exit callbacks and stop restrictions |
| packages/hikkaku/src/core/project.test.ts | Tests for build target exposure |
| packages/hikkaku/src/core/composer.test.ts | Tests for build scope frame APIs |
| packages/gobox/src/types.ts | Type system for number, string, boolean, vector, struct, and trait |
| packages/gobox/src/value.ts | Scoped values, signals, and effects implementation |
| packages/gobox/src/functions.ts | Custom function definitions with return values |
| packages/gobox/src/internal/runtime.ts | Memory management with static and dynamic allocation |
| packages/gobox/src/index.ts | Package entry point and exports |
| packages/gobox/package.json | Package configuration |
| packages/gobox/vite.config.ts | Build configuration |
| packages/gobox/tsconfig.json | TypeScript configuration |
| examples/gobox-counter/src/main.ts | Example counter application using gobox |
| examples/gobox-counter/package.json | Example package configuration |
| .github/workflows/publish.yml | Publish workflow updates for gobox |
| bun.lock | Dependency lock updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function useImpl< | ||
| TStruct extends GoboxStructLike, | ||
| TMethods extends Record<string, unknown>, | ||
| >(type: TStruct, methods: TMethods): TStruct & { methods: TMethods } | ||
| export function useImpl< | ||
| TStruct extends GoboxStructLike, | ||
| TTraitMethods extends Record<string, unknown>, | ||
| TMethods extends TTraitMethods & Record<string, unknown>, | ||
| >( | ||
| type: TStruct, | ||
| traitDef: GoboxTrait<TTraitMethods>, | ||
| methods: TMethods, | ||
| ): TStruct & { methods: TMethods } | ||
| export function useImpl< | ||
| TStruct extends GoboxStructLike, | ||
| TMethods extends Record<string, unknown>, | ||
| >( | ||
| type: TStruct, | ||
| methodsOrTrait: TMethods | GoboxTraitLike, | ||
| maybeMethods?: TMethods, | ||
| ): TStruct & { methods: TMethods } { | ||
| let methods: TMethods | ||
| if (maybeMethods !== undefined) { | ||
| const traitDef = methodsOrTrait as GoboxTraitLike | ||
| methods = maybeMethods | ||
| for (const methodName of traitDef.methodNames) { | ||
| if (!(methodName in methods)) { | ||
| throw new Error(`Missing trait method: ${String(methodName)}`) | ||
| } | ||
| } | ||
| } else { | ||
| methods = methodsOrTrait as TMethods | ||
| } | ||
|
|
||
| return { | ||
| ...type, | ||
| methods, | ||
| } | ||
| } |
There was a problem hiding this comment.
There is a naming conflict: useImpl is exported from both types.ts and functions.ts. Since index.ts does export * from './functions' before export * from './value', the functions.ts version will take precedence, but this creates ambiguity. The functions.ts version calls normalizeImplMethods while this version doesn't, making them functionally different.
Consider renaming the types.ts version to something like implWithMethods or removing it entirely if the functions.ts version is meant to be the canonical implementation.
| has_repository="$(node -e "const fs=require('fs');const pkg=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));const repo=pkg.repository;const ok=(typeof repo==='string'&&repo.trim()!=='')||(repo&&typeof repo==='object'&&typeof repo.url==='string'&&repo.url.trim()!=='');process.stdout.write(ok?'yes':'no')" "$package_json_path")" | ||
| if [ "$has_repository" != "yes" ]; then | ||
| echo "package.json must contain a non-empty repository field: $package_json_path" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
The repository field validation logic uses complex inline Node.js code that could be more maintainable. The logic checks if repository is either a non-empty string or an object with a non-empty url string. Consider extracting this into a separate script file for better readability and testability, similar to how version bumping might be handled.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan * fix(gobox): add "files" field to package.json for publish Co-authored-by: nakasyou <79000684+nakasyou@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nakasyou <79000684+nakasyou@users.noreply.github.com>
Summary
@hikkaku/goboxpackage (value,types,functions) with scoped list-backed memory runtimehikkakucore for scope-exit/stop restrictions used by goboxexamples/gobox-counterusingstruct,trait,useImpl,useSignal,useEffectgoboxin.github/workflows/publish.ymlrepositoryin package metadata during publish flowAPI updates
defineFunction->useFunctioncallFunction; usefn.call(...)impl->useImpluseImplcan accept function option objects directly (no explicituseFunction(...)wrapper required)Verification
bun run --cwd packages/gobox testbun run --cwd examples/gobox-counter buildbun run typecheck