커밋 d894fc0의 AUTHORING.md를 그대로 옮긴 것으로, 본문은 아직 영어입니다. 패키지는 0.1.0에서 쓸 typeshade라는 이름으로 가져옵니다.
전과 후
Declaring an output struct and field access
// BEFORE — hand-synced struct string + manual field access + imperative buildconst VsOut: StructDecl = { name: 'VsOut', fields: [ … ] }const uv = node.field('uv', vec2fT)const out = b.var('out', structT('VsOut'))b.assign(out.field('uv', vec2fT), someUv)b.ret(out)
// AFTER — one declaration; typed read; one-expression buildconst VsOut = ioStruct('VsOut', { pos: builtin('position', vec4fT), uv: location(0, vec2fT), … })const uv = VsOut.of(node).uvreturn VsOut.construct({ pos, uv: someUv, … })Calling another function
// BEFORE — string name + explicit return type, no name checkingconst ecef = callFn('lonlat_to_ecef', vec3fT, lonRad, latRad, f32(0))
// AFTER — import the handle, call directly (object form checks names/types)const ecef = lonlatToEcef(lonRad, latRad, f32(0))A bound array element
// BEFORE — arrayT element + manual element type + per-field accessorconst seg = segments.at(i, structT('ShapeSegment'))const p0 = seg.field('p0', vec2fT)
// AFTER — element handle; typed field proxyconst segmentsB = storageBuffer('segments', ShapeSegment, { group: 0, binding: 9, access: 'read' })const p0 = segmentsB.at(i).p0A mutable accumulator
// BEFORE — explicit Var with name + type, free assign functionconst min_dist = b.var('min_dist', f32T, f32(1e10))b.assign(min_dist, min(min_dist, d))
// AFTER — plain const (auto-materialises as var), method assignconst min_dist = f32(1e10)min_dist.assign(min(min_dist, d))Literals and degree conversion
// BEFORE — f32()/u32() wrappers, multiply by a rounded constantmode.eq(u32(2))x.add(f32(1))vec4(pos, f32(0), f32(1))const lonRad = lon.mul(DEG2RAD)
// AFTER — contextual literal lift + radians()mode.eq(2)x.add(1)vec4(pos, 0, 1)const lonRad = radians(lon)Value dispatch
// BEFORE — named, typed, tuple-array switch / equality condExprconst v = condExpr( f32T, 'v', [ [mode.eq(0), e0], [mode.eq(1), e1], ], elseVal,)
// AFTER — familiar Switch with Var + assign, OR condExpr taking only valuesconst v = Var(elseVal)Switch(mode) .case(0, () => v.assign(e0)) .case(1, () => v.assign(e1)) .default(() => {})// or, for condition/range dispatch:const clip = condExpr( [ [c0, () => e0], [c1, () => e1], ], () => elseVal,)