From 578c533bbc8a2fd545b17077d22e8ae59ed143f4 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:00:15 +0100 Subject: [PATCH 1/9] Rationalize @glint/template modules --- packages/template/-private/attributes.d.ts | 32 ------ packages/template/-private/blocks.d.ts | 54 ---------- packages/template/-private/dsl.d.ts | 7 ++ packages/template/-private/dsl/invoke.d.ts | 101 ++++++++++++++++++ .../{resolution.d.ts => dsl/resolve.d.ts} | 23 +--- packages/template/-private/dsl/types.d.ts | 21 ++++ packages/template/-private/index.d.ts | 3 - packages/template/-private/integration.d.ts | 56 ++++++++++ packages/template/-private/invoke.d.ts | 33 ------ packages/template/-private/keywords.d.ts | 8 ++ .../template/-private/keywords/component.d.ts | 3 +- .../template/-private/keywords/debugger.d.ts | 5 +- packages/template/-private/keywords/each.d.ts | 3 +- .../-private/keywords/has-block-params.d.ts | 5 +- .../template/-private/keywords/has-block.d.ts | 5 +- .../-private/keywords/in-element.d.ts | 3 +- .../template/-private/keywords/index.d.ts | 8 -- packages/template/-private/keywords/let.d.ts | 5 +- packages/template/-private/keywords/with.d.ts | 5 +- packages/template/-private/signature.d.ts | 28 ----- packages/template/-private/template.d.ts | 32 ------ packages/template/index.d.ts | 11 -- 22 files changed, 208 insertions(+), 243 deletions(-) delete mode 100644 packages/template/-private/attributes.d.ts delete mode 100644 packages/template/-private/blocks.d.ts create mode 100644 packages/template/-private/dsl.d.ts create mode 100644 packages/template/-private/dsl/invoke.d.ts rename packages/template/-private/{resolution.d.ts => dsl/resolve.d.ts} (75%) create mode 100644 packages/template/-private/dsl/types.d.ts delete mode 100644 packages/template/-private/index.d.ts create mode 100644 packages/template/-private/integration.d.ts delete mode 100644 packages/template/-private/invoke.d.ts create mode 100644 packages/template/-private/keywords.d.ts delete mode 100644 packages/template/-private/keywords/index.d.ts delete mode 100644 packages/template/-private/signature.d.ts delete mode 100644 packages/template/-private/template.d.ts delete mode 100644 packages/template/index.d.ts diff --git a/packages/template/-private/attributes.d.ts b/packages/template/-private/attributes.d.ts deleted file mode 100644 index acb293068..000000000 --- a/packages/template/-private/attributes.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { CreatesModifier } from './signature'; - -declare const Element: unique symbol; -export type HasElement = { [Element]: El }; - -export type ElementForTagName = Name extends keyof HTMLElementTagNameMap - ? HTMLElementTagNameMap[Name] - : Element; - -export type ElementForComponent>> = T extends Constructor< - HasElement -> - ? El - : null; - -type Constructor = new (...args: any) => T; - -//
-export declare function applySplattributes< - SourceElement extends Element, - _TargetElement extends SourceElement ->(): void; - -//
-export declare function applyAttributes<_TargetElement extends Element>( - attrs: Record -): void; - -//
-export declare function applyModifier( - modifier: CreatesModifier -): void; diff --git a/packages/template/-private/blocks.d.ts b/packages/template/-private/blocks.d.ts deleted file mode 100644 index cd97685bf..000000000 --- a/packages/template/-private/blocks.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This module contains types pertaining to defining and working with - * yields and blocks in templates. Components define the names of the - * blocks they intend to yield to, as well as the types of their block - * parameters, as string => tuple record: - * - * interface MyComponentYields { - * header?: []; - * body: [message: string]; - * } - * - * In general, a block body is represented as a callback passed in to - * an `invokeBlock` call. For example, in an invocation like this: - * - * invokeBlock(resolve(Globals['each'])({}, ['a', 'b', 'c']), { - * default(letter, index) { - * yieldToBlock(𝚪, 'body', `Letter #${index}: ${letter}`); - * } - * }) - * - * A `default` block is being passed to the `each` helper, which determines - * that the types of the params it receives are a `string` and a `number`. - * - * The caller then uses those parameters to yield out to its own `body` block, - * which is validated against the declared blocks and their parameter types - * defined in the context for the containing component, `𝚪`. - */ - -import { AnyContext } from './resolution'; -import { AnyBlocks } from './signature'; - -/** - * Given a mapping from block names to the parameters they'll receive, produces - * the corresponding type for the blocks hash that may be passed to the component - * in question. - */ -export type BlockBodies = { - [BlockName in keyof Yields]: (...params: NonNullable) => void; -}; - -/** - * Used in template bodies to encode a `{{yield}}` statement. - * - * {{yield foo bar to='name'}} - * - * Is equivalent to: - * - * yieldToBlock(𝚪, 'name', foo, bar); - */ -export declare function yieldToBlock( - 𝚪: Context, - to: K, - ...values: NonNullable -): void; diff --git a/packages/template/-private/dsl.d.ts b/packages/template/-private/dsl.d.ts new file mode 100644 index 000000000..6e0fc882e --- /dev/null +++ b/packages/template/-private/dsl.d.ts @@ -0,0 +1,7 @@ +// This module exports functions and types directly referenced by +// the output of `@glint/transform`. It comprises the basis from +// which environments construct their exports. + +export * from './dsl/resolve'; +export * from './dsl/invoke'; +export * from './dsl/types'; diff --git a/packages/template/-private/dsl/invoke.d.ts b/packages/template/-private/dsl/invoke.d.ts new file mode 100644 index 000000000..16b5e5c0f --- /dev/null +++ b/packages/template/-private/dsl/invoke.d.ts @@ -0,0 +1,101 @@ +import { AcceptsBlocks, AnyBlocks, AnyContext, BoundModifier } from '../integration'; + +/* + * Invokes the given value as an inline expression to be emitted to the DOM. + * This corresponds to a mustache statement either at the top level or being + * passed as an attribute or concatenated into a string: + * + * {{value}} + * {{value foo=bar}} + *
+ *
+ */ +export declare function invokeEmit< + T extends AcceptsBlocks<{}> | string | number | boolean | null | void +>(value: T): void; + +/* + * Invokes the given value as an entity that expects to receive blocks + * rather than return a value. This corresponds to a block-form mustache + * statement or any angle-bracket component invocation, i.e.: + * + * {{#value foo=bar}}{{/value}} + * + * + * + * This form of invocation is the only one in a template that accepts + * blocks. + */ +export declare function invokeBlock( + value: AcceptsBlocks, + blocks: { + [Block in keyof Yields]: (...params: NonNullable) => void; + } +): void; + +/** + * Acts as a top-level wrapper for translated template bodies. + */ +export declare function template(f: (𝚪: AnyContext) => void): void; + +/* + * Used in template bodies to encode a `{{yield}}` statement. + * + * {{yield foo bar to='name'}} + * + * Is equivalent to: + * + * yieldToBlock(𝚪, 'name', foo, bar); + */ +export declare function yieldToBlock( + 𝚪: Context, + to: K, + ...values: NonNullable +): void; + +/* + * Applies `...attributes` that were passed to a component down + * to an element or child component invocation in its template. + * + *
+ * + * + * Would produce: + * + * applySplattributes>(); + * applySplattributes>(); + */ +export declare function applySplattributes< + SourceElement extends Element, + _TargetElement extends SourceElement +>(): void; + +/* + * Applies named attributes to an element or component. + * + *
+ * + * + * Would produce: + * + * applyAttributes>({ foo: ... }); + * applyAttributes>({ foo: ... }); + */ +export declare function applyAttributes<_TargetElement extends Element>( + attrs: Record +): void; + +/* + * Applies a modifier to an element or component. + * + *
+ * + * + * Would produce: + * + * applyModifier>(resolve(someModifier)({})); + * applyModifier>(resolve(someModifier)({})); + */ +export declare function applyModifier( + modifier: BoundModifier +): void; diff --git a/packages/template/-private/resolution.d.ts b/packages/template/-private/dsl/resolve.d.ts similarity index 75% rename from packages/template/-private/resolution.d.ts rename to packages/template/-private/dsl/resolve.d.ts index 03eff8c57..99ebd7a5d 100644 --- a/packages/template/-private/resolution.d.ts +++ b/packages/template/-private/dsl/resolve.d.ts @@ -1,23 +1,4 @@ -/* - * This module contains types and functions related to resolving the - * _template signature_ and _template context_ for various values. - */ - -import { NoNamedArgs } from './signature'; -import { TemplateContext } from './template'; - -declare const InvokeDirect: unique symbol; -export type DirectInvokable = { [InvokeDirect]: T }; - -declare const Invoke: unique symbol; -export type Invokable = { [Invoke]: T }; - -declare const ContextType: unique symbol; -export type HasContext = { [ContextType]: T }; - -export type AnySignature = (...args: any) => any; -export type AnyContext = TemplateContext; -export type ResolveContext = T extends HasContext ? Context : unknown; +import { DirectInvokable, EmptyObject, Invokable, Invoke, InvokeDirect } from '../integration'; /* * We have multiple ways of representing invokable values, dictated by certain constraints @@ -68,4 +49,4 @@ export declare function resolveOrReturn(item: T): T[t export declare function resolveOrReturn( item: new (...args: Args) => Instance ): (...args: Parameters) => ReturnType; -export declare function resolveOrReturn(item: T): (args: NoNamedArgs) => T; +export declare function resolveOrReturn(item: T): (args: EmptyObject) => T; diff --git a/packages/template/-private/dsl/types.d.ts b/packages/template/-private/dsl/types.d.ts new file mode 100644 index 000000000..cc61392e1 --- /dev/null +++ b/packages/template/-private/dsl/types.d.ts @@ -0,0 +1,21 @@ +import { HasContext, HasElement } from '@glint/template/-private/integration'; + +type Constructor = new (...args: any) => T; + +/** Given a tag name, returns an appropriate `Element` subtype. */ +export type ElementForTagName = Name extends keyof HTMLElementTagNameMap + ? HTMLElementTagNameMap[Name] + : Element; + +/** Given a component class, returns its `[Element]` type or `null` if it has none. */ +export type ElementForComponent>> = T extends Constructor< + HasElement +> + ? El + : null; + +/** + * Given the instance type of a component backing class, produces the appropriate + * `TemplateContext` type for its template. + */ +export type ResolveContext = T extends HasContext ? Context : unknown; diff --git a/packages/template/-private/index.d.ts b/packages/template/-private/index.d.ts deleted file mode 100644 index 357530767..000000000 --- a/packages/template/-private/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { AcceptsBlocks, CreatesModifier, NoNamedArgs, NoYields } from './signature'; -export { Invoke, ContextType } from './resolution'; -export { TemplateContext } from './template'; diff --git a/packages/template/-private/integration.d.ts b/packages/template/-private/integration.d.ts new file mode 100644 index 000000000..0f8447375 --- /dev/null +++ b/packages/template/-private/integration.d.ts @@ -0,0 +1,56 @@ +// While the entire `@glint/template` package is currently private, this +// module exports the symbols and types necessary to declare a class or +// other entity as integrating with Glint's template system. + +/** Any function, which is the tighest bound we can put on an object's `[Invoke]` field. */ +export type AnyFunction = (...params: any) => any; + +/** Any type loosely fitting the shape of a template context */ +export type AnyContext = TemplateContext; + +/** The loosest shape of a "blocks hash" */ +export type AnyBlocks = Partial>; + +export declare const InvokeDirect: unique symbol; +export type DirectInvokable = { [InvokeDirect]: T }; + +export declare const Invoke: unique symbol; +export type Invokable = { [Invoke]: T }; + +export declare const Context: unique symbol; +export type HasContext = { [Context]: T }; + +// These shenanigans are necessary to get TS to report when named args +// are passed to a signature that doesn't expect any, because `{}` is +// special-cased in the type system not to trigger EPC. +declare const EmptyObject: unique symbol; +export type EmptyObject = { [EmptyObject]?: void }; + +declare const Element: unique symbol; +declare const Modifier: unique symbol; +declare const Blocks: unique symbol; + +/** Denotes an invokable entity that may accept attributes and modifiers for HTML element(s) */ +export type HasElement = { [Element]: El }; + +/** Denotes a modifier whose arguments have been bound and is ready to be attached to an element. */ +export type BoundModifier = { [Modifier]: (el: El) => void }; + +/** + * Denotes that the associated entity may be invoked with the given + * blocks, yielding params of the appropriate type. + */ +export type AcceptsBlocks = ( + blocks: BlockImpls +) => { [Blocks]: true }; + +/** + * Determines the type of `this` and any `@arg`s used in a template, + * as well as valid `{{yield}}` invocations and `...attributes` usage. + */ +export type TemplateContext = { + this: This; + args: Args; + yields: Yields; + element: Element; +}; diff --git a/packages/template/-private/invoke.d.ts b/packages/template/-private/invoke.d.ts deleted file mode 100644 index d968c6e08..000000000 --- a/packages/template/-private/invoke.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { AcceptsBlocks } from './signature'; -import { BlockBodies } from './blocks'; - -/** - * Invokes the given value as an inline expression to be emitted to the DOM. - * This corresponds to a mustache statement either at the top level or being - * passed as an attribute or concatenated into a string: - * - * {{value}} - * {{value foo=bar}} - *
- *
- */ -export declare function invokeEmit< - T extends AcceptsBlocks<{}> | string | number | boolean | null | void ->(value: T): void; - -/** - * Invokes the given value as an entity that expects to receive blocks - * rather than return a value. This corresponds to a block-form mustache - * statement or any angle-bracket component invocation, i.e.: - * - * {{#value foo=bar}}{{/value}} - * - * - * - * This form of invocation is the only one in a template that accepts - * blocks. - */ -export declare function invokeBlock( - value: AcceptsBlocks, - blocks: BlockBodies -): void; diff --git a/packages/template/-private/keywords.d.ts b/packages/template/-private/keywords.d.ts new file mode 100644 index 000000000..1e22cd734 --- /dev/null +++ b/packages/template/-private/keywords.d.ts @@ -0,0 +1,8 @@ +export { ComponentKeyword } from './keywords/component'; +export { DebuggerKeyword } from './keywords/debugger'; +export { EachKeyword } from './keywords/each'; +export { HasBlockKeyword } from './keywords/has-block'; +export { HasBlockParamsKeyword } from './keywords/has-block-params'; +export { InElementKeyword } from './keywords/in-element'; +export { LetKeyword } from './keywords/let'; +export { WithKeyword } from './keywords/with'; diff --git a/packages/template/-private/keywords/component.d.ts b/packages/template/-private/keywords/component.d.ts index 75e7bac3c..33fbdacd6 100644 --- a/packages/template/-private/keywords/component.d.ts +++ b/packages/template/-private/keywords/component.d.ts @@ -1,5 +1,4 @@ -import { AcceptsBlocks, AnyBlocks } from '../signature'; -import { DirectInvokable, Invokable } from '../resolution'; +import { AcceptsBlocks, AnyBlocks, DirectInvokable, Invokable } from '../integration'; export type ComponentKeyword = DirectInvokable<{ < diff --git a/packages/template/-private/keywords/debugger.d.ts b/packages/template/-private/keywords/debugger.d.ts index f0d19ce21..767a6d1e7 100644 --- a/packages/template/-private/keywords/debugger.d.ts +++ b/packages/template/-private/keywords/debugger.d.ts @@ -1,6 +1,5 @@ -import { DirectInvokable } from '../resolution'; -import { NoNamedArgs } from '../signature'; +import { DirectInvokable, EmptyObject } from '../integration'; export type DebuggerKeyword = DirectInvokable<{ - (args: NoNamedArgs): void; + (args: EmptyObject): void; }>; diff --git a/packages/template/-private/keywords/each.d.ts b/packages/template/-private/keywords/each.d.ts index 841919ef7..1a86264db 100644 --- a/packages/template/-private/keywords/each.d.ts +++ b/packages/template/-private/keywords/each.d.ts @@ -1,5 +1,4 @@ -import { DirectInvokable } from '../resolution'; -import { AcceptsBlocks } from '../signature'; +import { AcceptsBlocks, DirectInvokable } from '../integration'; export type EachKeyword = DirectInvokable<{ (args: { key?: string }, items: T[]): AcceptsBlocks<{ diff --git a/packages/template/-private/keywords/has-block-params.d.ts b/packages/template/-private/keywords/has-block-params.d.ts index 46e215c12..519f506e2 100644 --- a/packages/template/-private/keywords/has-block-params.d.ts +++ b/packages/template/-private/keywords/has-block-params.d.ts @@ -1,6 +1,5 @@ -import { DirectInvokable } from '../resolution'; -import { NoNamedArgs } from '../signature'; +import { DirectInvokable, EmptyObject } from '../integration'; export type HasBlockParamsKeyword = DirectInvokable<{ - (args: NoNamedArgs, blockName?: string): boolean; + (args: EmptyObject, blockName?: string): boolean; }>; diff --git a/packages/template/-private/keywords/has-block.d.ts b/packages/template/-private/keywords/has-block.d.ts index 78d253a5c..3f275b5f2 100644 --- a/packages/template/-private/keywords/has-block.d.ts +++ b/packages/template/-private/keywords/has-block.d.ts @@ -1,6 +1,5 @@ -import { DirectInvokable } from '../resolution'; -import { NoNamedArgs } from '../signature'; +import { DirectInvokable, EmptyObject } from '../integration'; export type HasBlockKeyword = DirectInvokable<{ - (args: NoNamedArgs, blockName?: string): boolean; + (args: EmptyObject, blockName?: string): boolean; }>; diff --git a/packages/template/-private/keywords/in-element.d.ts b/packages/template/-private/keywords/in-element.d.ts index c36f7a236..93d305fc0 100644 --- a/packages/template/-private/keywords/in-element.d.ts +++ b/packages/template/-private/keywords/in-element.d.ts @@ -1,5 +1,4 @@ -import { DirectInvokable } from '../resolution'; -import { AcceptsBlocks } from '../signature'; +import { AcceptsBlocks, DirectInvokable } from '../integration'; export type InElementKeyword = DirectInvokable<{ (args: { insertBefore?: null }, element: Element): AcceptsBlocks<{ default: [] }>; diff --git a/packages/template/-private/keywords/index.d.ts b/packages/template/-private/keywords/index.d.ts deleted file mode 100644 index 7d95c350f..000000000 --- a/packages/template/-private/keywords/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { ComponentKeyword } from './component'; -export { DebuggerKeyword } from './debugger'; -export { EachKeyword } from './each'; -export { HasBlockKeyword } from './has-block'; -export { HasBlockParamsKeyword } from './has-block-params'; -export { InElementKeyword } from './in-element'; -export { LetKeyword } from './let'; -export { WithKeyword } from './with'; diff --git a/packages/template/-private/keywords/let.d.ts b/packages/template/-private/keywords/let.d.ts index a90f5be05..8517914e9 100644 --- a/packages/template/-private/keywords/let.d.ts +++ b/packages/template/-private/keywords/let.d.ts @@ -1,8 +1,7 @@ -import { DirectInvokable } from '../resolution'; -import { NoNamedArgs, AcceptsBlocks } from '../signature'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '../integration'; export type LetKeyword = DirectInvokable<{ - (args: NoNamedArgs, ...values: T): AcceptsBlocks<{ + (args: EmptyObject, ...values: T): AcceptsBlocks<{ default: T; }>; }>; diff --git a/packages/template/-private/keywords/with.d.ts b/packages/template/-private/keywords/with.d.ts index 9fb37efea..3486e754f 100644 --- a/packages/template/-private/keywords/with.d.ts +++ b/packages/template/-private/keywords/with.d.ts @@ -1,8 +1,7 @@ -import { DirectInvokable } from '../resolution'; -import { NoNamedArgs, AcceptsBlocks } from '../signature'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '../integration'; export type WithKeyword = DirectInvokable<{ - (args: NoNamedArgs, value: T): AcceptsBlocks<{ + (args: EmptyObject, value: T): AcceptsBlocks<{ default: [T]; inverse?: []; }>; diff --git a/packages/template/-private/signature.d.ts b/packages/template/-private/signature.d.ts deleted file mode 100644 index 07548072a..000000000 --- a/packages/template/-private/signature.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -declare const Modifier: unique symbol; -declare const Blocks: unique symbol; - -/** The loosest shape of a "blocks hash" */ -export type AnyBlocks = Partial>; - -/** Denotes that the associated entity should be invoked as a modifier */ -export type CreatesModifier = { [Modifier]: (el: El) => void }; - -// These shenanigans are necessary to get TS to report when named args -// are passed to a signature that doesn't expect any, because `{}` is -// special-cased in the type system not to trigger EPC. -export const EmptyObject: unique symbol; -export type EmptyObject = { [EmptyObject]?: void }; - -/** Indicates that a signature expects no named arguments. */ -export type NoNamedArgs = EmptyObject; - -/** Indicates that a signature never yields to blocks. */ -export type NoYields = EmptyObject; - -/** - * Denotes that the associated entity may be invoked with the given - * blocks, yielding params of the appropriate type. - */ -export type AcceptsBlocks = ( - blocks: BlockImpls -) => { [Blocks]: true }; diff --git a/packages/template/-private/template.d.ts b/packages/template/-private/template.d.ts deleted file mode 100644 index 758058059..000000000 --- a/packages/template/-private/template.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This module contains types and functions used for defining - * the template value associated with a particular component - * class. - */ - -import { AnyContext } from './resolution'; - -declare const Template: unique symbol; -export type Template = { [Template]: true }; - -/** - * Determines the type of `this` and any `@arg`s used in a template, - * as well as any explicit types for yielded parameters. - * - * This type is typically the return type of an application of - * `ResolveContext` from `resolution.d.ts`. - */ -export type TemplateContext = { - this: This; - args: Args; - yields: Yields; - element: Element; -}; - -/** - * Accepts a generator function declaring an expected template context, - * and returns an appropriate invokable type that accepts the required - * named args and a set of blocks as determined by any `BlockYield`s - * included in the generators iterator type. - */ -export declare function template(f: (𝚪: AnyContext) => void): Template; diff --git a/packages/template/index.d.ts b/packages/template/index.d.ts deleted file mode 100644 index f5dd4fc65..000000000 --- a/packages/template/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export { resolve, resolveOrReturn, ResolveContext } from './-private/resolution'; -export { invokeEmit, invokeBlock } from './-private/invoke'; -export { yieldToBlock } from './-private/blocks'; -export { template, Template } from './-private/template'; -export { - applySplattributes, - applyAttributes, - applyModifier, - ElementForTagName, - ElementForComponent, -} from './-private/attributes'; From 44271b255536751c8ef792264afa59c8d5a366a7 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:02:42 +0100 Subject: [PATCH 2/9] Update @glint/template tests for new layout --- .../template/__tests__/attributes.test.ts | 21 +++++++------- .../__tests__/custom-invokable.test.ts | 10 +++---- packages/template/__tests__/invoke.test.ts | 19 ++++++------- .../__tests__/keywords/component.test.ts | 4 +-- .../__tests__/keywords/debugger.test.ts | 4 +-- .../template/__tests__/keywords/each.test.ts | 4 +-- .../template/__tests__/keywords/let.test.ts | 4 +-- .../template/__tests__/keywords/with.test.ts | 4 +-- .../template/__tests__/resolution.test.ts | 14 ++++++---- packages/template/__tests__/test-component.ts | 28 +++++++++---------- 10 files changed, 56 insertions(+), 56 deletions(-) diff --git a/packages/template/__tests__/attributes.test.ts b/packages/template/__tests__/attributes.test.ts index 28b0ce89a..b4921e76f 100644 --- a/packages/template/__tests__/attributes.test.ts +++ b/packages/template/__tests__/attributes.test.ts @@ -1,19 +1,20 @@ -import { template, resolve, invokeBlock, ResolveContext } from '@glint/template'; -import TestComponent from './test-component'; -import { DirectInvokable } from '../-private/resolution'; -import { CreatesModifier } from '../-private'; +import { expectTypeOf } from 'expect-type'; import { - applyAttributes, + template, + resolve, + invokeBlock, + ResolveContext, + ElementForTagName, applyModifier, applySplattributes, ElementForComponent, - ElementForTagName, -} from '../-private/attributes'; -import { EmptyObject } from '../-private/signature'; -import { expectTypeOf } from 'expect-type'; + applyAttributes, +} from '../-private/dsl'; +import { BoundModifier, DirectInvokable, EmptyObject } from '../-private/integration'; +import TestComponent from './test-component'; declare const imageModifier: DirectInvokable< - (args: EmptyObject) => CreatesModifier + (args: EmptyObject) => BoundModifier >; class GenericElementComponent extends TestComponent<{ Element: HTMLElement }> {} diff --git a/packages/template/__tests__/custom-invokable.test.ts b/packages/template/__tests__/custom-invokable.test.ts index 0f49e9e38..1f8ae0d37 100644 --- a/packages/template/__tests__/custom-invokable.test.ts +++ b/packages/template/__tests__/custom-invokable.test.ts @@ -1,9 +1,7 @@ import { expectTypeOf } from 'expect-type'; import SumType from 'sums-up'; -import { resolve, invokeBlock } from '@glint/template'; -import { AcceptsBlocks, NoNamedArgs } from '@glint/template/-private/signature'; -import { invokeEmit } from '../-private/invoke'; -import { DirectInvokable, resolveOrReturn } from '../-private/resolution'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '../-private/integration'; +import { invokeBlock, invokeEmit, resolve, resolveOrReturn } from '../-private/dsl'; /////////////////////////////////////////////////////////////////////////////// // This module exercises what's possible when declaring a signature for a @@ -24,13 +22,13 @@ type SumVariants> = T extends SumType ? V : ne // type parameters correctly declare const caseOf: DirectInvokable< >( - args: NoNamedArgs, + args: EmptyObject, value: T ) => AcceptsBlocks<{ default: [ DirectInvokable< >( - args: NoNamedArgs, + args: EmptyObject, key: K ) => AcceptsBlocks<{ default: SumVariants[K]; diff --git a/packages/template/__tests__/invoke.test.ts b/packages/template/__tests__/invoke.test.ts index 03d8d843f..77c4fbc09 100644 --- a/packages/template/__tests__/invoke.test.ts +++ b/packages/template/__tests__/invoke.test.ts @@ -1,16 +1,16 @@ +import { expectTypeOf } from 'expect-type'; import { - template, - resolve, - invokeBlock, - ResolveContext, applyModifier, + ElementForTagName, + invokeBlock, invokeEmit, + resolve, + ResolveContext, resolveOrReturn, -} from '@glint/template'; -import { expectTypeOf } from 'expect-type'; + template, + yieldToBlock, +} from '../-private/dsl'; import TestComponent, { globals } from './test-component'; -import { yieldToBlock } from '../-private/blocks'; -import { ElementForTagName } from '../-private/attributes'; type MyComponentSignature = { Args: { @@ -78,8 +78,6 @@ class MyComponent extends TestComponent> { * * <:body as |isReady value|> * Ready? {{value}}: {{isReady}} - *
- * {{yield value}} * *
*/ @@ -100,7 +98,6 @@ invokeBlock(resolve(MyComponent)({ value: 'hi' }), { * * <:body as |isReady value|> * Ready? {{value}}: {{isReady}} - * {{yield value}} * * */ diff --git a/packages/template/__tests__/keywords/component.test.ts b/packages/template/__tests__/keywords/component.test.ts index 88864cbdb..f0b90a1a3 100644 --- a/packages/template/__tests__/keywords/component.test.ts +++ b/packages/template/__tests__/keywords/component.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { resolve, invokeBlock } from '@glint/template'; -import { ComponentKeyword } from '@glint/template/-private/keywords'; +import { invokeBlock, resolve } from '../../-private/dsl'; +import { ComponentKeyword } from '../../-private/keywords'; import TestComponent from '../test-component'; const componentKeyword = resolve({} as ComponentKeyword); diff --git a/packages/template/__tests__/keywords/debugger.test.ts b/packages/template/__tests__/keywords/debugger.test.ts index 92651f45a..0c206e0bf 100644 --- a/packages/template/__tests__/keywords/debugger.test.ts +++ b/packages/template/__tests__/keywords/debugger.test.ts @@ -1,5 +1,5 @@ -import { resolve, invokeEmit } from '@glint/template'; -import { DebuggerKeyword } from '@glint/template/-private/keywords'; +import { invokeEmit, resolve } from '../../-private/dsl'; +import { DebuggerKeyword } from '../../-private/keywords'; const debuggerKeyword = resolve({} as DebuggerKeyword); diff --git a/packages/template/__tests__/keywords/each.test.ts b/packages/template/__tests__/keywords/each.test.ts index 31d12f079..440ddeabe 100644 --- a/packages/template/__tests__/keywords/each.test.ts +++ b/packages/template/__tests__/keywords/each.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { resolve, invokeBlock } from '@glint/template'; -import { EachKeyword } from '@glint/template/-private/keywords'; +import { invokeBlock, resolve } from '../../-private/dsl'; +import { EachKeyword } from '../../-private/keywords'; const eachKeyword = resolve({} as EachKeyword); diff --git a/packages/template/__tests__/keywords/let.test.ts b/packages/template/__tests__/keywords/let.test.ts index 9e74e2c2c..e868cb538 100644 --- a/packages/template/__tests__/keywords/let.test.ts +++ b/packages/template/__tests__/keywords/let.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { resolve, invokeBlock } from '@glint/template'; -import { LetKeyword } from '@glint/template/-private/keywords'; +import { invokeBlock, resolve } from '../../-private/dsl'; +import { LetKeyword } from '../../-private/keywords'; const letKeyword = resolve({} as LetKeyword); diff --git a/packages/template/__tests__/keywords/with.test.ts b/packages/template/__tests__/keywords/with.test.ts index af6e961c5..316ad8e36 100644 --- a/packages/template/__tests__/keywords/with.test.ts +++ b/packages/template/__tests__/keywords/with.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { resolve, invokeBlock } from '@glint/template'; -import { WithKeyword } from '@glint/template/-private/keywords'; +import { invokeBlock, resolve } from '../../-private/dsl'; +import { WithKeyword } from '../../-private/keywords'; const withKeyword = resolve({} as WithKeyword); diff --git a/packages/template/__tests__/resolution.test.ts b/packages/template/__tests__/resolution.test.ts index e2a39c0ae..6aca58077 100644 --- a/packages/template/__tests__/resolution.test.ts +++ b/packages/template/__tests__/resolution.test.ts @@ -1,10 +1,14 @@ import { expectTypeOf } from 'expect-type'; -import { DirectInvokable, resolveOrReturn } from '@glint/template/-private/resolution'; -import { TemplateContext } from '@glint/template/-private/template'; -import { template, invokeBlock, resolve, ResolveContext } from '@glint/template'; -import { AcceptsBlocks } from '../-private'; +import { AcceptsBlocks, DirectInvokable, TemplateContext } from '../-private/integration'; +import { + invokeBlock, + resolve, + ResolveContext, + resolveOrReturn, + template, + yieldToBlock, +} from '../-private/dsl'; import TestComponent, { globals } from './test-component'; -import { yieldToBlock } from '../-private/blocks'; declare function value(): T; diff --git a/packages/template/__tests__/test-component.ts b/packages/template/__tests__/test-component.ts index 2ce87274a..f05b4b0f0 100644 --- a/packages/template/__tests__/test-component.ts +++ b/packages/template/__tests__/test-component.ts @@ -1,19 +1,19 @@ -import { - TemplateContext, - AcceptsBlocks, - CreatesModifier, - Invoke, - ContextType, -} from '@glint/template/-private'; -import { LetKeyword } from '@glint/template/-private/keywords'; -import { Element } from '../-private/attributes'; -import { DirectInvokable } from '../-private/resolution'; -import { EmptyObject } from '../-private/signature'; - // This module contains a `@glimmer/component`-like base class and the // declarations necessary for it to be used as a component in glint, as // well as simple examples of a helper and modifier. +import { + AcceptsBlocks, + BoundModifier, + Context, + DirectInvokable, + Element, + EmptyObject, + Invoke, + TemplateContext, +} from '../-private/integration'; +import { LetKeyword } from '../-private/keywords'; + export default TestComponent; export declare const globals: { let: LetKeyword; @@ -22,7 +22,7 @@ export declare const globals: { args: EmptyObject, event: T, callback: (event: HTMLElementEventMap[T]) => void - ) => CreatesModifier + ) => BoundModifier >; }; @@ -38,5 +38,5 @@ declare class TestComponent { readonly args: Get; [Invoke]: (args: Get) => AcceptsBlocks>; [Element]: Get; - [ContextType]: TemplateContext, Get, Get>; + [Context]: TemplateContext, Get, Get>; } From 4474fbbc27c080bbfab41bd544516d6724d6a6d6 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:03:39 +0100 Subject: [PATCH 3/9] Rationalize @glint/environment-glimmerx modules --- .../{types => -private/dsl}/globals.d.ts | 8 +++----- .../{types => -private/dsl}/index.d.ts | 19 ++++++++++--------- .../{ => -private}/environment/index.ts | 4 ++-- packages/environment-glimmerx/.gitignore | 2 +- packages/environment-glimmerx/.prettierignore | 6 ++++-- .../environment-glimmerx/component/index.ts | 14 +++++++++----- packages/environment-glimmerx/helper/index.ts | 3 +-- .../environment-glimmerx/modifier/index.ts | 10 ++++++---- packages/environment-glimmerx/package.json | 4 ++-- 9 files changed, 38 insertions(+), 32 deletions(-) rename packages/environment-glimmerx/{types => -private/dsl}/globals.d.ts (74%) rename packages/environment-glimmerx/{types => -private/dsl}/index.d.ts (79%) rename packages/environment-glimmerx/{ => -private}/environment/index.ts (70%) diff --git a/packages/environment-glimmerx/types/globals.d.ts b/packages/environment-glimmerx/-private/dsl/globals.d.ts similarity index 74% rename from packages/environment-glimmerx/types/globals.d.ts rename to packages/environment-glimmerx/-private/dsl/globals.d.ts index 7fefbac84..1f58ce183 100644 --- a/packages/environment-glimmerx/types/globals.d.ts +++ b/packages/environment-glimmerx/-private/dsl/globals.d.ts @@ -9,16 +9,14 @@ interface Keywords { each: VM.EachKeyword; 'has-block': VM.HasBlockKeyword; 'has-block-params': VM.HasBlockParamsKeyword; - // the `if` keyword is implemented directly in @glint/transform + if: void; // the `if` keyword is implemented directly in @glint/transform 'in-element': VM.InElementKeyword; let: VM.LetKeyword; - unless: void; // TODO: should this be implemented as `if (!...)`? + unless: void; // the `unless` keyword is implemented directly in @glint/transform with: VM.WithKeyword; - // the `yield` keyword is implemented directly in @glint/transform + yield: void; // the `yield` keyword is implemented directly in @glint/transform } -declare const k: Keywords; - export interface Globals extends Keywords { // GlimmerX, by design, doesn't have any global values beyond // glimmer-vm keywords diff --git a/packages/environment-glimmerx/types/index.d.ts b/packages/environment-glimmerx/-private/dsl/index.d.ts similarity index 79% rename from packages/environment-glimmerx/types/index.d.ts rename to packages/environment-glimmerx/-private/dsl/index.d.ts index ec2f053fa..724667ae8 100644 --- a/packages/environment-glimmerx/types/index.d.ts +++ b/packages/environment-glimmerx/-private/dsl/index.d.ts @@ -1,4 +1,4 @@ -export * from '@glint/template'; +export * from '@glint/template/-private/dsl'; export { Globals } from './globals'; /* @@ -20,12 +20,13 @@ export { Globals } from './globals'; */ import { + BoundModifier, DirectInvokable, + EmptyObject, Invokable, Invoke, InvokeDirect, -} from '@glint/template/-private/resolution'; -import { CreatesModifier, NoNamedArgs } from '@glint/template/-private/signature'; +} from '@glint/template/-private/integration'; export declare function resolve(item: T): T[typeof InvokeDirect]; export declare function resolve( @@ -33,13 +34,13 @@ export declare function resolve) => ReturnType; export declare function resolve( item: (value: Value, ...args: Args) => value is T -): (named: NoNamedArgs, value: Value, ...args: Args) => value is T; +): (named: EmptyObject, value: Value, ...args: Args) => value is T; export declare function resolve( item: (element: El, ...args: Args) => void | (() => void) -): (named: NoNamedArgs, ...args: Args) => CreatesModifier; +): (named: EmptyObject, ...args: Args) => BoundModifier; export declare function resolve( item: (...args: Args) => T -): (named: NoNamedArgs, ...args: Args) => T; +): (named: EmptyObject, ...args: Args) => T; export declare function resolveOrReturn(item: T): T[typeof InvokeDirect]; export declare function resolveOrReturn( @@ -47,8 +48,8 @@ export declare function resolveOrReturn) => ReturnType; export declare function resolveOrReturn( item: (value: Value, ...args: Args) => value is T -): (named: NoNamedArgs, value: Value, ...args: Args) => value is T; +): (named: EmptyObject, value: Value, ...args: Args) => value is T; export declare function resolveOrReturn( item: (...args: Args) => T -): (named: NoNamedArgs, ...args: Args) => T; -export declare function resolveOrReturn(item: T): (args: NoNamedArgs) => T; +): (named: EmptyObject, ...args: Args) => T; +export declare function resolveOrReturn(item: T): (args: EmptyObject) => T; diff --git a/packages/environment-glimmerx/environment/index.ts b/packages/environment-glimmerx/-private/environment/index.ts similarity index 70% rename from packages/environment-glimmerx/environment/index.ts rename to packages/environment-glimmerx/-private/environment/index.ts index 64a8c081a..e3a8d8d6d 100644 --- a/packages/environment-glimmerx/environment/index.ts +++ b/packages/environment-glimmerx/-private/environment/index.ts @@ -5,12 +5,12 @@ export default function glimmerxEnvironment(): GlintEnvironmentConfig { tags: { '@glimmerx/component': { hbs: { - typesSource: '@glint/environment-glimmerx/types', + typesSource: '@glint/environment-glimmerx/-private/dsl', }, }, '@glint/environment-glimmerx/component': { hbs: { - typesSource: '@glint/environment-glimmerx/types', + typesSource: '@glint/environment-glimmerx/-private/dsl', }, }, }, diff --git a/packages/environment-glimmerx/.gitignore b/packages/environment-glimmerx/.gitignore index e0a250d7b..808f9ed8f 100644 --- a/packages/environment-glimmerx/.gitignore +++ b/packages/environment-glimmerx/.gitignore @@ -2,4 +2,4 @@ *.d.ts tsconfig.tsbuildinfo -!types/**/*.d.ts +!-private/dsl/**/*.d.ts diff --git a/packages/environment-glimmerx/.prettierignore b/packages/environment-glimmerx/.prettierignore index 1f57ba585..43f7d820f 100644 --- a/packages/environment-glimmerx/.prettierignore +++ b/packages/environment-glimmerx/.prettierignore @@ -1,2 +1,4 @@ -/*/*.js -/*/*.d.ts +/**/*.js +/**/*.d.ts + +!/-private/dsl/**/*.d.ts diff --git a/packages/environment-glimmerx/component/index.ts b/packages/environment-glimmerx/component/index.ts index ff883c83d..b38811aaa 100644 --- a/packages/environment-glimmerx/component/index.ts +++ b/packages/environment-glimmerx/component/index.ts @@ -2,10 +2,14 @@ import * as glimmerxComponent from '@glimmerx/component'; export * from '@glimmerx/component'; -import type { ContextType, Invoke } from '@glint/template/-private'; -import type { TemplateContext, AcceptsBlocks } from '@glint/template/-private'; -import type { Element } from '@glint/template/-private/attributes'; -import type { EmptyObject } from '@glint/template/-private/signature'; +import type { + AcceptsBlocks, + Context, + Element, + EmptyObject, + Invoke, + TemplateContext, +} from '@glint/template/-private/integration'; type Get = Key extends keyof T ? Exclude @@ -24,7 +28,7 @@ interface Component extends glimmerxComponent.default & {}> { [Invoke]: (args: Get) => AcceptsBlocks>; [Element]: Get; - [ContextType]: TemplateContext, Get, Get>; + [Context]: TemplateContext, Get, Get>; } export default Component; diff --git a/packages/environment-glimmerx/helper/index.ts b/packages/environment-glimmerx/helper/index.ts index 4fc395359..41a4cc4c3 100644 --- a/packages/environment-glimmerx/helper/index.ts +++ b/packages/environment-glimmerx/helper/index.ts @@ -2,8 +2,7 @@ import * as glimmerxHelper from '@glimmerx/helper'; export * from '@glimmerx/helper'; -import type { DirectInvokable, Invokable } from '@glint/template/-private/resolution'; -import type { EmptyObject } from '@glint/template/-private/signature'; +import type { DirectInvokable, EmptyObject, Invokable } from '@glint/template/-private/integration'; type HelperFactory = ( fn: (positional: Positional, named: Named) => Result diff --git a/packages/environment-glimmerx/modifier/index.ts b/packages/environment-glimmerx/modifier/index.ts index 44e1a49a1..686fef86d 100644 --- a/packages/environment-glimmerx/modifier/index.ts +++ b/packages/environment-glimmerx/modifier/index.ts @@ -2,16 +2,18 @@ import * as glimmerxModifier from '@glimmerx/modifier'; export * from '@glimmerx/modifier'; -import type { CreatesModifier } from '@glint/template/-private'; -import type { DirectInvokable } from '@glint/template/-private/resolution'; -import type { EmptyObject } from '@glint/template/-private/signature'; +import type { + BoundModifier, + DirectInvokable, + EmptyObject, +} from '@glint/template/-private/integration'; type OnModifier = DirectInvokable< ( args: EmptyObject, name: Name, callback: (event: HTMLElementEventMap[Name]) => void - ) => CreatesModifier + ) => BoundModifier >; export const on = (glimmerxModifier.on as unknown) as OnModifier; diff --git a/packages/environment-glimmerx/package.json b/packages/environment-glimmerx/package.json index f0fffd2d8..adef3ca9a 100644 --- a/packages/environment-glimmerx/package.json +++ b/packages/environment-glimmerx/package.json @@ -5,7 +5,7 @@ "description": "A Glint environment to support GlimmerX projects", "license": "MIT", "author": "Dan Freeman (https://github.com/dfreeman)", - "glint-environment": "environment/index.js", + "glint-environment": "-private/environment/index.js", "keywords": [ "glint-environment" ], @@ -17,7 +17,7 @@ }, "files": [ "README.md", - "types/**/*.{js,d.ts}", + "-private/**/*.{js,d.ts}", "environment/**/*.{js,d.ts}", "modifier/**/*.{js,d.ts}", "helper/**/*.{js,d.ts}", From aa55d85481670783b18037628075180fc79fc0d9 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:04:06 +0100 Subject: [PATCH 4/9] Update @glint/environment-glimmerx tests for new layout --- .../environment-glimmerx/__tests__/component.test.ts | 4 ++-- .../environment-glimmerx/__tests__/globals.test.ts | 2 +- packages/environment-glimmerx/__tests__/helper.test.ts | 10 +++++----- .../environment-glimmerx/__tests__/modifier.test.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/environment-glimmerx/__tests__/component.test.ts b/packages/environment-glimmerx/__tests__/component.test.ts index 3d827d707..b4655d437 100644 --- a/packages/environment-glimmerx/__tests__/component.test.ts +++ b/packages/environment-glimmerx/__tests__/component.test.ts @@ -5,9 +5,9 @@ import { resolve, ResolveContext, yieldToBlock, -} from '@glint/environment-glimmerx/types'; +} from '@glint/environment-glimmerx/-private/dsl'; import { expectTypeOf } from 'expect-type'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { EmptyObject } from '@glint/template/-private/integration'; { class NoArgsComponent extends Component { diff --git a/packages/environment-glimmerx/__tests__/globals.test.ts b/packages/environment-glimmerx/__tests__/globals.test.ts index fa2fb573b..babe8b783 100644 --- a/packages/environment-glimmerx/__tests__/globals.test.ts +++ b/packages/environment-glimmerx/__tests__/globals.test.ts @@ -7,7 +7,7 @@ import { InElementKeyword } from '@glint/template/-private/keywords/in-element'; import { LetKeyword } from '@glint/template/-private/keywords/let'; import { WithKeyword } from '@glint/template/-private/keywords/with'; -import { Globals } from '@glint/environment-glimmerx/types'; +import { Globals } from '@glint/environment-glimmerx/-private/dsl'; expectTypeOf(Globals['debugger']).toEqualTypeOf(); expectTypeOf(Globals['each']).toEqualTypeOf(); diff --git a/packages/environment-glimmerx/__tests__/helper.test.ts b/packages/environment-glimmerx/__tests__/helper.test.ts index 2659dacb3..77aede8a7 100644 --- a/packages/environment-glimmerx/__tests__/helper.test.ts +++ b/packages/environment-glimmerx/__tests__/helper.test.ts @@ -1,7 +1,7 @@ -import { resolve } from '@glint/environment-glimmerx/types'; +import { resolve } from '@glint/environment-glimmerx/-private/dsl'; import { helper, fn as fnDefinition } from '@glint/environment-glimmerx/helper'; +import { EmptyObject } from '@glint/template/-private/integration'; import { expectTypeOf } from 'expect-type'; -import { NoNamedArgs } from '@glint/template/-private'; // Built-in helper: `fn` { @@ -31,7 +31,7 @@ import { NoNamedArgs } from '@glint/template/-private'; let definition = helper(([a, b]: [T, U]) => a || b); let or = resolve(definition); - expectTypeOf(or).toEqualTypeOf<(args: NoNamedArgs, t: T, u: U) => T | U>(); + expectTypeOf(or).toEqualTypeOf<(args: EmptyObject, t: T, u: U) => T | U>(); // @ts-expect-error: extra named arg or({ hello: true }, 'a', 'b'); @@ -78,7 +78,7 @@ import { NoNamedArgs } from '@glint/template/-private'; let repeat = resolve(definition); - expectTypeOf(repeat).toEqualTypeOf<(args: NoNamedArgs, item: T, count?: number) => Array>(); + expectTypeOf(repeat).toEqualTypeOf<(args: EmptyObject, item: T, count?: number) => Array>(); // @ts-expect-error: unexpected named arg repeat({ word: 'hi' }, 123, 12); @@ -99,7 +99,7 @@ import { NoNamedArgs } from '@glint/template/-private'; let isString = resolve(definition); - expectTypeOf(isString).toEqualTypeOf<(args: NoNamedArgs, arg: unknown) => arg is string>(); + expectTypeOf(isString).toEqualTypeOf<(args: EmptyObject, arg: unknown) => arg is string>(); let x = 'hi' as string | number; if (isString({}, x)) { diff --git a/packages/environment-glimmerx/__tests__/modifier.test.ts b/packages/environment-glimmerx/__tests__/modifier.test.ts index b38a62ce3..4994d987b 100644 --- a/packages/environment-glimmerx/__tests__/modifier.test.ts +++ b/packages/environment-glimmerx/__tests__/modifier.test.ts @@ -1,5 +1,5 @@ import { on as onDefinition } from '@glint/environment-glimmerx/modifier'; -import { resolve, applyModifier } from '@glint/environment-glimmerx/types'; +import { resolve, applyModifier } from '@glint/environment-glimmerx/-private/dsl'; import { expectTypeOf } from 'expect-type'; // Built-in modifier: `on` From 91a63812bb9a0202fa5c03128ef457b1d65b415f Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:06:07 +0100 Subject: [PATCH 5/9] Rationalize @glint/environment-ember-loose modules --- .../{types => -private/dsl}/globals.d.ts | 34 +++++++++---------- .../-private/dsl/index.d.ts | 2 ++ .../{ => -private}/environment/index.ts | 2 +- .../intrinsics/action.d.ts | 2 +- .../intrinsics/component.d.ts | 9 +++-- .../-private/intrinsics/concat.d.ts | 5 +++ .../-private/intrinsics/each-in.d.ts | 7 ++++ .../{types => -private}/intrinsics/fn.d.ts | 3 +- .../{types => -private}/intrinsics/get.d.ts | 3 +- .../{types => -private}/intrinsics/input.d.ts | 4 +-- .../intrinsics/link-to.d.ts | 5 ++- .../-private/intrinsics/log.d.ts | 5 +++ .../{types => -private}/intrinsics/mount.d.ts | 2 +- .../{types => -private}/intrinsics/mut.d.ts | 3 +- .../{types => -private}/intrinsics/on.d.ts | 7 ++-- .../-private/intrinsics/outlet.d.ts | 5 +++ .../intrinsics/textarea.d.ts | 4 +-- .../-private/intrinsics/unbound.d.ts | 5 +++ packages/environment-ember-loose/.gitignore | 4 ++- .../environment-ember-loose/.prettierignore | 8 +++-- .../ember-component/helper.ts | 3 +- .../ember-component/index.ts | 13 ++++--- .../ember-modifier/index.ts | 13 ++++--- .../glimmer-component/index.ts | 13 ++++--- packages/environment-ember-loose/package.json | 7 ++-- .../registry/index.d.ts | 6 ++++ .../environment-ember-loose/types/index.d.ts | 2 -- .../types/intrinsics/concat.d.ts | 6 ---- .../types/intrinsics/each-in.d.ts | 8 ----- .../types/intrinsics/log.d.ts | 6 ---- .../types/intrinsics/outlet.d.ts | 6 ---- .../types/intrinsics/unbound.d.ts | 6 ---- .../types/registry.d.ts | 1 - 33 files changed, 112 insertions(+), 97 deletions(-) rename packages/environment-ember-loose/{types => -private/dsl}/globals.d.ts (91%) create mode 100644 packages/environment-ember-loose/-private/dsl/index.d.ts rename packages/environment-ember-loose/{ => -private}/environment/index.ts (92%) rename packages/environment-ember-loose/{types => -private}/intrinsics/action.d.ts (95%) rename packages/environment-ember-loose/{types => -private}/intrinsics/component.d.ts (89%) create mode 100644 packages/environment-ember-loose/-private/intrinsics/concat.d.ts create mode 100644 packages/environment-ember-loose/-private/intrinsics/each-in.d.ts rename packages/environment-ember-loose/{types => -private}/intrinsics/fn.d.ts (87%) rename packages/environment-ember-loose/{types => -private}/intrinsics/get.d.ts (55%) rename packages/environment-ember-loose/{types => -private}/intrinsics/input.d.ts (79%) rename packages/environment-ember-loose/{types => -private}/intrinsics/link-to.d.ts (67%) create mode 100644 packages/environment-ember-loose/-private/intrinsics/log.d.ts rename packages/environment-ember-loose/{types => -private}/intrinsics/mount.d.ts (58%) rename packages/environment-ember-loose/{types => -private}/intrinsics/mut.d.ts (56%) rename packages/environment-ember-loose/{types => -private}/intrinsics/on.d.ts (64%) create mode 100644 packages/environment-ember-loose/-private/intrinsics/outlet.d.ts rename packages/environment-ember-loose/{types => -private}/intrinsics/textarea.d.ts (73%) create mode 100644 packages/environment-ember-loose/-private/intrinsics/unbound.d.ts create mode 100644 packages/environment-ember-loose/registry/index.d.ts delete mode 100644 packages/environment-ember-loose/types/index.d.ts delete mode 100644 packages/environment-ember-loose/types/intrinsics/concat.d.ts delete mode 100644 packages/environment-ember-loose/types/intrinsics/each-in.d.ts delete mode 100644 packages/environment-ember-loose/types/intrinsics/log.d.ts delete mode 100644 packages/environment-ember-loose/types/intrinsics/outlet.d.ts delete mode 100644 packages/environment-ember-loose/types/intrinsics/unbound.d.ts delete mode 100644 packages/environment-ember-loose/types/registry.d.ts diff --git a/packages/environment-ember-loose/types/globals.d.ts b/packages/environment-ember-loose/-private/dsl/globals.d.ts similarity index 91% rename from packages/environment-ember-loose/types/globals.d.ts rename to packages/environment-ember-loose/-private/dsl/globals.d.ts index 458495ba0..1bc6b504c 100644 --- a/packages/environment-ember-loose/types/globals.d.ts +++ b/packages/environment-ember-loose/-private/dsl/globals.d.ts @@ -1,22 +1,22 @@ import * as VM from '@glint/template/-private/keywords'; -import { ActionKeyword } from './intrinsics/action'; -import { ComponentKeyword } from './intrinsics/component'; -import { ConcatHelper } from './intrinsics/concat'; -import { EachInKeyword } from './intrinsics/each-in'; -import { FnHelper } from './intrinsics/fn'; -import { GetHelper } from './intrinsics/get'; -import { InputComponent } from './intrinsics/input'; -import { LinkToKeyword, LinkToComponent } from './intrinsics/link-to'; -import { LogHelper } from './intrinsics/log'; -import { MountKeyword } from './intrinsics/mount'; -import { MutKeyword } from './intrinsics/mut'; -import { OnModifier } from './intrinsics/on'; -import { OutletKeyword } from './intrinsics/outlet'; -import { TextareaComponent } from './intrinsics/textarea'; -import { UnboundKeyword } from './intrinsics/unbound'; - -import Registry from './registry'; +import { ActionKeyword } from '../intrinsics/action'; +import { ComponentKeyword } from '../intrinsics/component'; +import { ConcatHelper } from '../intrinsics/concat'; +import { EachInKeyword } from '../intrinsics/each-in'; +import { FnHelper } from '../intrinsics/fn'; +import { GetHelper } from '../intrinsics/get'; +import { InputComponent } from '../intrinsics/input'; +import { LinkToKeyword, LinkToComponent } from '../intrinsics/link-to'; +import { LogHelper } from '../intrinsics/log'; +import { MountKeyword } from '../intrinsics/mount'; +import { MutKeyword } from '../intrinsics/mut'; +import { OnModifier } from '../intrinsics/on'; +import { OutletKeyword } from '../intrinsics/outlet'; +import { TextareaComponent } from '../intrinsics/textarea'; +import { UnboundKeyword } from '../intrinsics/unbound'; + +import Registry from '../../registry'; // The keyword vs global breakdown here is loosely matched with // the listing in http://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html diff --git a/packages/environment-ember-loose/-private/dsl/index.d.ts b/packages/environment-ember-loose/-private/dsl/index.d.ts new file mode 100644 index 000000000..0939982b8 --- /dev/null +++ b/packages/environment-ember-loose/-private/dsl/index.d.ts @@ -0,0 +1,2 @@ +export * from '@glint/template/-private/dsl'; +export { Globals } from './globals'; diff --git a/packages/environment-ember-loose/environment/index.ts b/packages/environment-ember-loose/-private/environment/index.ts similarity index 92% rename from packages/environment-ember-loose/environment/index.ts rename to packages/environment-ember-loose/-private/environment/index.ts index 6502e6b17..f2bea3711 100644 --- a/packages/environment-ember-loose/environment/index.ts +++ b/packages/environment-ember-loose/-private/environment/index.ts @@ -3,7 +3,7 @@ import { GlintEnvironmentConfig } from '@glint/config'; export default function glimmerxEnvironment(): GlintEnvironmentConfig { return { template: { - typesPath: '@glint/environment-ember-loose/types', + typesPath: '@glint/environment-ember-loose/-private/dsl', getPossibleScriptPaths(templatePath) { if (/[\\/]template\.hbs$/.test(templatePath)) { diff --git a/packages/environment-ember-loose/types/intrinsics/action.d.ts b/packages/environment-ember-loose/-private/intrinsics/action.d.ts similarity index 95% rename from packages/environment-ember-loose/types/intrinsics/action.d.ts rename to packages/environment-ember-loose/-private/intrinsics/action.d.ts index d25bbeed2..0e668c568 100644 --- a/packages/environment-ember-loose/types/intrinsics/action.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/action.d.ts @@ -1,4 +1,4 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; +import { DirectInvokable } from '@glint/template/-private/integration'; export type ActionNamedArgs = { value?: keyof T; diff --git a/packages/environment-ember-loose/types/intrinsics/component.d.ts b/packages/environment-ember-loose/-private/intrinsics/component.d.ts similarity index 89% rename from packages/environment-ember-loose/types/intrinsics/component.d.ts rename to packages/environment-ember-loose/-private/intrinsics/component.d.ts index 2b080badd..9737be13f 100644 --- a/packages/environment-ember-loose/types/intrinsics/component.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/component.d.ts @@ -1,5 +1,10 @@ -import { AcceptsBlocks, AnyBlocks, EmptyObject } from '@glint/template/-private/signature'; -import { DirectInvokable, Invokable } from '@glint/template/-private/resolution'; +import { + AcceptsBlocks, + AnyBlocks, + EmptyObject, + DirectInvokable, + Invokable, +} from '@glint/template/-private/integration'; type RegistryComponentArgs = Registry[T] extends new ( ...args: any diff --git a/packages/environment-ember-loose/-private/intrinsics/concat.d.ts b/packages/environment-ember-loose/-private/intrinsics/concat.d.ts new file mode 100644 index 000000000..1bb22d21b --- /dev/null +++ b/packages/environment-ember-loose/-private/intrinsics/concat.d.ts @@ -0,0 +1,5 @@ +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; + +export type ConcatHelper = DirectInvokable<{ + (args: EmptyObject, ...params: unknown[]): string; +}>; diff --git a/packages/environment-ember-loose/-private/intrinsics/each-in.d.ts b/packages/environment-ember-loose/-private/intrinsics/each-in.d.ts new file mode 100644 index 000000000..a024f43b4 --- /dev/null +++ b/packages/environment-ember-loose/-private/intrinsics/each-in.d.ts @@ -0,0 +1,7 @@ +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; + +export type EachInKeyword = DirectInvokable<{ + (args: EmptyObject, object: T): AcceptsBlocks<{ + default: [key: keyof T, value: T[keyof T]]; + }>; +}>; diff --git a/packages/environment-ember-loose/types/intrinsics/fn.d.ts b/packages/environment-ember-loose/-private/intrinsics/fn.d.ts similarity index 87% rename from packages/environment-ember-loose/types/intrinsics/fn.d.ts rename to packages/environment-ember-loose/-private/intrinsics/fn.d.ts index 68314889c..3a22a6205 100644 --- a/packages/environment-ember-loose/types/intrinsics/fn.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/fn.d.ts @@ -1,5 +1,4 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; import { Mut } from './mut'; export type FnHelper = DirectInvokable<{ diff --git a/packages/environment-ember-loose/types/intrinsics/get.d.ts b/packages/environment-ember-loose/-private/intrinsics/get.d.ts similarity index 55% rename from packages/environment-ember-loose/types/intrinsics/get.d.ts rename to packages/environment-ember-loose/-private/intrinsics/get.d.ts index 898ebfabe..61fbbfe9e 100644 --- a/packages/environment-ember-loose/types/intrinsics/get.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/get.d.ts @@ -1,5 +1,4 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; export type GetHelper = DirectInvokable<{ (args: EmptyObject, obj: T, key: K): T[K]; diff --git a/packages/environment-ember-loose/types/intrinsics/input.d.ts b/packages/environment-ember-loose/-private/intrinsics/input.d.ts similarity index 79% rename from packages/environment-ember-loose/types/intrinsics/input.d.ts rename to packages/environment-ember-loose/-private/intrinsics/input.d.ts index b5d17700d..c6b79f33d 100644 --- a/packages/environment-ember-loose/types/intrinsics/input.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/input.d.ts @@ -1,6 +1,4 @@ -import { AcceptsBlocks } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; export interface CheckboxInputArgs { type: 'checkbox'; diff --git a/packages/environment-ember-loose/types/intrinsics/link-to.d.ts b/packages/environment-ember-loose/-private/intrinsics/link-to.d.ts similarity index 67% rename from packages/environment-ember-loose/types/intrinsics/link-to.d.ts rename to packages/environment-ember-loose/-private/intrinsics/link-to.d.ts index 255e269b4..7cdca3f50 100644 --- a/packages/environment-ember-loose/types/intrinsics/link-to.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/link-to.d.ts @@ -1,8 +1,7 @@ -import { AcceptsBlocks, NoNamedArgs } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; export type LinkToKeyword = DirectInvokable<{ - (args: NoNamedArgs, route: string, ...params: unknown[]): AcceptsBlocks<{ + (args: EmptyObject, route: string, ...params: unknown[]): AcceptsBlocks<{ default?: []; }>; }>; diff --git a/packages/environment-ember-loose/-private/intrinsics/log.d.ts b/packages/environment-ember-loose/-private/intrinsics/log.d.ts new file mode 100644 index 000000000..d38b68d12 --- /dev/null +++ b/packages/environment-ember-loose/-private/intrinsics/log.d.ts @@ -0,0 +1,5 @@ +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; + +export type LogHelper = DirectInvokable<{ + (args: EmptyObject, ...params: unknown[]): void; +}>; diff --git a/packages/environment-ember-loose/types/intrinsics/mount.d.ts b/packages/environment-ember-loose/-private/intrinsics/mount.d.ts similarity index 58% rename from packages/environment-ember-loose/types/intrinsics/mount.d.ts rename to packages/environment-ember-loose/-private/intrinsics/mount.d.ts index e2e3ab05f..2ae10f9ee 100644 --- a/packages/environment-ember-loose/types/intrinsics/mount.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/mount.d.ts @@ -1,4 +1,4 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; +import { DirectInvokable } from '@glint/template/-private/integration'; export type MountKeyword = DirectInvokable<{ (args: { model?: unknown }, engine: string): void; diff --git a/packages/environment-ember-loose/types/intrinsics/mut.d.ts b/packages/environment-ember-loose/-private/intrinsics/mut.d.ts similarity index 56% rename from packages/environment-ember-loose/types/intrinsics/mut.d.ts rename to packages/environment-ember-loose/-private/intrinsics/mut.d.ts index 652d64e05..f78d2fcdd 100644 --- a/packages/environment-ember-loose/types/intrinsics/mut.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/mut.d.ts @@ -1,5 +1,4 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; declare const Mut: unique symbol; diff --git a/packages/environment-ember-loose/types/intrinsics/on.d.ts b/packages/environment-ember-loose/-private/intrinsics/on.d.ts similarity index 64% rename from packages/environment-ember-loose/types/intrinsics/on.d.ts rename to packages/environment-ember-loose/-private/intrinsics/on.d.ts index 26a3ef637..f908830d6 100644 --- a/packages/environment-ember-loose/types/intrinsics/on.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/on.d.ts @@ -1,5 +1,4 @@ -import { CreatesModifier } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; +import { BoundModifier, DirectInvokable } from '@glint/template/-private/integration'; export interface OnModifierArgs { capture?: boolean; @@ -12,10 +11,10 @@ export type OnModifier = DirectInvokable<{ args: OnModifierArgs, name: Name, callback: (event: HTMLElementEventMap[Name]) => void - ): CreatesModifier; + ): BoundModifier; ( args: OnModifierArgs, name: string, callback: (event: Event) => void - ): CreatesModifier; + ): BoundModifier; }>; diff --git a/packages/environment-ember-loose/-private/intrinsics/outlet.d.ts b/packages/environment-ember-loose/-private/intrinsics/outlet.d.ts new file mode 100644 index 000000000..c548da611 --- /dev/null +++ b/packages/environment-ember-loose/-private/intrinsics/outlet.d.ts @@ -0,0 +1,5 @@ +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; + +export type OutletKeyword = DirectInvokable<{ + (args: EmptyObject, name?: string): void; +}>; diff --git a/packages/environment-ember-loose/types/intrinsics/textarea.d.ts b/packages/environment-ember-loose/-private/intrinsics/textarea.d.ts similarity index 73% rename from packages/environment-ember-loose/types/intrinsics/textarea.d.ts rename to packages/environment-ember-loose/-private/intrinsics/textarea.d.ts index b85b0a9eb..d1f338784 100644 --- a/packages/environment-ember-loose/types/intrinsics/textarea.d.ts +++ b/packages/environment-ember-loose/-private/intrinsics/textarea.d.ts @@ -1,6 +1,4 @@ -import { AcceptsBlocks } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; +import { AcceptsBlocks, DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; export interface TextareaArgs { value?: string; diff --git a/packages/environment-ember-loose/-private/intrinsics/unbound.d.ts b/packages/environment-ember-loose/-private/intrinsics/unbound.d.ts new file mode 100644 index 000000000..913e4eb8e --- /dev/null +++ b/packages/environment-ember-loose/-private/intrinsics/unbound.d.ts @@ -0,0 +1,5 @@ +import { DirectInvokable, EmptyObject } from '@glint/template/-private/integration'; + +export type UnboundKeyword = DirectInvokable<{ + (args: EmptyObject, value: T): T; +}>; diff --git a/packages/environment-ember-loose/.gitignore b/packages/environment-ember-loose/.gitignore index e0a250d7b..886494ef9 100644 --- a/packages/environment-ember-loose/.gitignore +++ b/packages/environment-ember-loose/.gitignore @@ -2,4 +2,6 @@ *.d.ts tsconfig.tsbuildinfo -!types/**/*.d.ts +!registry/**/*.d.ts +!-private/dsl/**/*.d.ts +!-private/intrinsics/**/*.d.ts diff --git a/packages/environment-ember-loose/.prettierignore b/packages/environment-ember-loose/.prettierignore index 1f57ba585..c84466fe4 100644 --- a/packages/environment-ember-loose/.prettierignore +++ b/packages/environment-ember-loose/.prettierignore @@ -1,2 +1,6 @@ -/*/*.js -/*/*.d.ts +/**/*.js +/**/*.d.ts + +!/registry/**/*.d.ts +!/-private/dsl/**/*.d.ts +!/-private/intrinsics/**/*.d.ts diff --git a/packages/environment-ember-loose/ember-component/helper.ts b/packages/environment-ember-loose/ember-component/helper.ts index bf48a0f27..0b2dbc5c6 100644 --- a/packages/environment-ember-loose/ember-component/helper.ts +++ b/packages/environment-ember-loose/ember-component/helper.ts @@ -1,5 +1,4 @@ -import type { Invoke, Invokable } from '@glint/template/-private/resolution'; -import type { EmptyObject } from '@glint/template/-private/signature'; +import type { Invoke, Invokable, EmptyObject } from '@glint/template/-private/integration'; declare const Ember: { Helper: EmberHelperConstructor }; diff --git a/packages/environment-ember-loose/ember-component/index.ts b/packages/environment-ember-loose/ember-component/index.ts index 18f64dbfc..a402beed8 100644 --- a/packages/environment-ember-loose/ember-component/index.ts +++ b/packages/environment-ember-loose/ember-component/index.ts @@ -1,6 +1,11 @@ -import type { ContextType, Invoke, TemplateContext } from '@glint/template/-private'; -import type { Element } from '@glint/template/-private/attributes'; -import type { AcceptsBlocks, EmptyObject } from '@glint/template/-private/signature'; +import type { + Context, + Invoke, + TemplateContext, + Element, + AcceptsBlocks, + EmptyObject, +} from '@glint/template/-private/integration'; declare const Ember: { Component: EmberComponentConstructor }; @@ -27,7 +32,7 @@ const Component = (EmberComponent as unknown) as new extends EmberComponent { [Invoke]: (args: Get) => AcceptsBlocks>; [Element]: Get; - [ContextType]: TemplateContext, Get, Get>; + [Context]: TemplateContext, Get, Get>; } export default Component; diff --git a/packages/environment-ember-loose/ember-modifier/index.ts b/packages/environment-ember-loose/ember-modifier/index.ts index 2db95f2f2..79d3f22ec 100644 --- a/packages/environment-ember-loose/ember-modifier/index.ts +++ b/packages/environment-ember-loose/ember-modifier/index.ts @@ -1,6 +1,9 @@ -import type { CreatesModifier } from '@glint/template/-private'; -import type { Invokable, Invoke } from '@glint/template/-private/resolution'; -import type { EmptyObject } from '@glint/template/-private/signature'; +import type { + Invokable, + Invoke, + BoundModifier, + EmptyObject, +} from '@glint/template/-private/integration'; const EmberModifier = window.require('ember-modifier').default; type EmberModifier = import('ember-modifier').default; @@ -14,7 +17,7 @@ type Get = Key extends keyof T type ModifierFactory = ( fn: (element: El, positional: Positional, named: Named) => unknown -) => new () => Invokable<(named: Named, ...positional: Positional) => CreatesModifier>; +) => new () => Invokable<(named: Named, ...positional: Positional) => BoundModifier>; export const modifier = emberModifier as ModifierFactory; @@ -37,7 +40,7 @@ interface Modifier [Invoke]: ( args: Get, ...positional: Get - ) => CreatesModifier; + ) => BoundModifier; } export default Modifier; diff --git a/packages/environment-ember-loose/glimmer-component/index.ts b/packages/environment-ember-loose/glimmer-component/index.ts index 0a3315328..05aa0bb5c 100644 --- a/packages/environment-ember-loose/glimmer-component/index.ts +++ b/packages/environment-ember-loose/glimmer-component/index.ts @@ -1,6 +1,11 @@ -import type { ContextType, Invoke, TemplateContext } from '@glint/template/-private'; -import type { Element } from '@glint/template/-private/attributes'; -import type { AcceptsBlocks, EmptyObject } from '@glint/template/-private/signature'; +import type { + Context, + Invoke, + TemplateContext, + Element, + AcceptsBlocks, + EmptyObject, +} from '@glint/template/-private/integration'; const GlimmerComponent = window.require('@glimmer/component').default; type GlimmerComponent = import('@glimmer/component').default; @@ -23,7 +28,7 @@ const Component = GlimmerComponent as new ( interface Component extends GlimmerComponent> { [Invoke]: (args: Get) => AcceptsBlocks>; [Element]: Get; - [ContextType]: TemplateContext, Get, Get>; + [Context]: TemplateContext, Get, Get>; } export default Component; diff --git a/packages/environment-ember-loose/package.json b/packages/environment-ember-loose/package.json index 0d9aa25db..54f401b06 100644 --- a/packages/environment-ember-loose/package.json +++ b/packages/environment-ember-loose/package.json @@ -5,7 +5,7 @@ "description": "A Glint environment to support loose-mode Ember.js projects", "license": "MIT", "author": "Dan Freeman (https://github.com/dfreeman)", - "glint-environment": "environment/index.js", + "glint-environment": "-private/environment/index.js", "keywords": [ "glint-environment" ], @@ -17,11 +17,12 @@ }, "files": [ "README.md", - "types/**/*.{js,d.ts}", + "-private/**/*.{js,d.ts}", "environment/**/*.{js,d.ts}", "ember-component/**/*.{js,d.ts}", "ember-modifier/**/*.{js,d.ts}", - "glimmer-component/**/*.{js,d.ts}" + "glimmer-component/**/*.{js,d.ts}", + "registry/**/*.{js,d.ts}" ], "dependencies": { "@glint/config": "^0.3.1", diff --git a/packages/environment-ember-loose/registry/index.d.ts b/packages/environment-ember-loose/registry/index.d.ts new file mode 100644 index 000000000..c2d556eb1 --- /dev/null +++ b/packages/environment-ember-loose/registry/index.d.ts @@ -0,0 +1,6 @@ +// This module exists as a public hook for consumers to add +// entities to the global template namespace, as that's the +// only way in loose-mode Ember for components/helpers/etc +// to be discovered. + +export default interface Registry {} diff --git a/packages/environment-ember-loose/types/index.d.ts b/packages/environment-ember-loose/types/index.d.ts deleted file mode 100644 index 073430770..000000000 --- a/packages/environment-ember-loose/types/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from '@glint/template'; -export { Globals } from './globals'; diff --git a/packages/environment-ember-loose/types/intrinsics/concat.d.ts b/packages/environment-ember-loose/types/intrinsics/concat.d.ts deleted file mode 100644 index 29dc99793..000000000 --- a/packages/environment-ember-loose/types/intrinsics/concat.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NoNamedArgs } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; - -export type ConcatHelper = DirectInvokable<{ - (args: NoNamedArgs, ...params: unknown[]): string; -}>; diff --git a/packages/environment-ember-loose/types/intrinsics/each-in.d.ts b/packages/environment-ember-loose/types/intrinsics/each-in.d.ts deleted file mode 100644 index f3d2837ff..000000000 --- a/packages/environment-ember-loose/types/intrinsics/each-in.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { AcceptsBlocks, NoNamedArgs } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; - -export type EachInKeyword = DirectInvokable<{ - (args: NoNamedArgs, object: T): AcceptsBlocks<{ - default: [key: keyof T, value: T[keyof T]]; - }>; -}>; diff --git a/packages/environment-ember-loose/types/intrinsics/log.d.ts b/packages/environment-ember-loose/types/intrinsics/log.d.ts deleted file mode 100644 index 51544d3cd..000000000 --- a/packages/environment-ember-loose/types/intrinsics/log.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NoNamedArgs } from '@glint/template/-private'; -import { DirectInvokable } from '@glint/template/-private/resolution'; - -export type LogHelper = DirectInvokable<{ - (args: NoNamedArgs, ...params: unknown[]): void; -}>; diff --git a/packages/environment-ember-loose/types/intrinsics/outlet.d.ts b/packages/environment-ember-loose/types/intrinsics/outlet.d.ts deleted file mode 100644 index 133af9286..000000000 --- a/packages/environment-ember-loose/types/intrinsics/outlet.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; - -export type OutletKeyword = DirectInvokable<{ - (args: EmptyObject, name?: string): void; -}>; diff --git a/packages/environment-ember-loose/types/intrinsics/unbound.d.ts b/packages/environment-ember-loose/types/intrinsics/unbound.d.ts deleted file mode 100644 index 62fa6436b..000000000 --- a/packages/environment-ember-loose/types/intrinsics/unbound.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DirectInvokable } from '@glint/template/-private/resolution'; -import { EmptyObject } from '@glint/template/-private/signature'; - -export type UnboundKeyword = DirectInvokable<{ - (args: EmptyObject, value: T): T; -}>; diff --git a/packages/environment-ember-loose/types/registry.d.ts b/packages/environment-ember-loose/types/registry.d.ts deleted file mode 100644 index a05b0db55..000000000 --- a/packages/environment-ember-loose/types/registry.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default interface Registry {} From 3301e98fca5a5d57454f1a131481619c260192d4 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:06:21 +0100 Subject: [PATCH 6/9] Update @glint/environment-ember-loose tests for new layout --- .../__tests__/component.test.ts | 4 ++-- .../environment-ember-loose/__tests__/helper.test.ts | 6 +++--- .../__tests__/intrinsics/action.test.ts | 2 +- .../__tests__/intrinsics/component.test.ts | 4 ++-- .../__tests__/intrinsics/concat.test.ts | 2 +- .../__tests__/intrinsics/each-in.test.ts | 2 +- .../__tests__/intrinsics/fn.test.ts | 2 +- .../__tests__/intrinsics/get.test.ts | 2 +- .../__tests__/intrinsics/input.test.ts | 2 +- .../__tests__/intrinsics/link-to.test.ts | 2 +- .../__tests__/intrinsics/log.test.ts | 2 +- .../__tests__/intrinsics/mount.test.ts | 2 +- .../__tests__/intrinsics/mut.test.ts | 4 ++-- .../__tests__/intrinsics/on.test.ts | 2 +- .../__tests__/intrinsics/outlet.test.ts | 2 +- .../__tests__/intrinsics/textarea.test.ts | 2 +- .../__tests__/intrinsics/unbound.test.ts | 2 +- .../__tests__/modifier.test.ts | 12 ++++++------ 18 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/environment-ember-loose/__tests__/component.test.ts b/packages/environment-ember-loose/__tests__/component.test.ts index 9742bee91..007860ff7 100644 --- a/packages/environment-ember-loose/__tests__/component.test.ts +++ b/packages/environment-ember-loose/__tests__/component.test.ts @@ -5,8 +5,8 @@ import { resolve, ResolveContext, yieldToBlock, -} from '@glint/environment-ember-loose/types'; -import { EmptyObject } from '@glint/template/-private/signature'; +} from '@glint/environment-ember-loose/-private/dsl'; +import { EmptyObject } from '@glint/template/-private/integration'; import { expectTypeOf } from 'expect-type'; { diff --git a/packages/environment-ember-loose/__tests__/helper.test.ts b/packages/environment-ember-loose/__tests__/helper.test.ts index e0387a067..e8ebd2e64 100644 --- a/packages/environment-ember-loose/__tests__/helper.test.ts +++ b/packages/environment-ember-loose/__tests__/helper.test.ts @@ -1,14 +1,14 @@ import Helper, { helper } from '@glint/environment-ember-loose/ember-component/helper'; -import { resolve } from '@glint/environment-ember-loose/types'; +import { resolve } from '@glint/environment-ember-loose/-private/dsl'; import { expectTypeOf } from 'expect-type'; -import { NoNamedArgs } from '@glint/template/-private'; +import { EmptyObject } from '@glint/template/-private/integration'; // Functional helper: positional params { let definition = helper(([a, b]: [T, U]) => a || b); let or = resolve(definition); - expectTypeOf(or).toEqualTypeOf<(args: NoNamedArgs, t: T, u: U) => T | U>(); + expectTypeOf(or).toEqualTypeOf<(args: EmptyObject, t: T, u: U) => T | U>(); // @ts-expect-error: extra named arg or({ hello: true }, 'a', 'b'); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/action.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/action.test.ts index 26b60ca1c..cb463f196 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/action.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/action.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let action = resolve(Globals['action']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/component.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/component.test.ts index 95e0b2eff..30ad0a006 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/component.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/component.test.ts @@ -1,7 +1,7 @@ import { expectTypeOf } from 'expect-type'; -import { resolve, invokeBlock } from '@glint/template'; +import { resolve, invokeBlock } from '@glint/environment-ember-loose/-private/dsl'; import Component from '@glint/environment-ember-loose/ember-component'; -import { ComponentKeyword } from '../../types/intrinsics/component'; +import { ComponentKeyword } from '@glint/environment-ember-loose/-private/intrinsics/component'; const componentKeyword = resolve({} as ComponentKeyword); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/concat.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/concat.test.ts index 4c541e5e4..dd700b6c9 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/concat.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/concat.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let concat = resolve(Globals['concat']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/each-in.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/each-in.test.ts index ca8b59913..a949f5eac 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/each-in.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/each-in.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve, invokeBlock } from '@glint/environment-ember-loose/types'; +import { Globals, resolve, invokeBlock } from '@glint/environment-ember-loose/-private/dsl'; let eachIn = resolve(Globals['each-in']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/fn.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/fn.test.ts index 80446526f..d57dacf2b 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/fn.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/fn.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let fn = resolve(Globals['fn']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/get.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/get.test.ts index e2f87e352..8a592d815 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/get.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/get.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let get = resolve(Globals['get']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/input.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/input.test.ts index b8479c593..5dfe7b6fa 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/input.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/input.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let input = resolve(Globals['input']); let Input = resolve(Globals['Input']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/link-to.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/link-to.test.ts index da2e0dba2..e36ba90cb 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/link-to.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/link-to.test.ts @@ -1,4 +1,4 @@ -import { Globals, resolve, invokeBlock } from '@glint/environment-ember-loose/types'; +import { Globals, resolve, invokeBlock } from '@glint/environment-ember-loose/-private/dsl'; let linkTo = resolve(Globals['link-to']); let LinkTo = resolve(Globals['LinkTo']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/log.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/log.test.ts index c54ed20c8..95b22e158 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/log.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/log.test.ts @@ -1,4 +1,4 @@ -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let log = resolve(Globals['log']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/mount.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/mount.test.ts index d563be47a..ed978aee4 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/mount.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/mount.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let mount = resolve(Globals['mount']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/mut.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/mut.test.ts index 660a9a467..933e0d771 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/mut.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/mut.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; -import { Mut } from '../../types/intrinsics/mut'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; +import { Mut } from '@glint/environment-ember-loose/-private/intrinsics/mut'; let fn = resolve(Globals['fn']); let mut = resolve(Globals['mut']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/on.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/on.test.ts index 508c15a8d..9518fe190 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/on.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/on.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, applyModifier, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, applyModifier, resolve } from '@glint/environment-ember-loose/-private/dsl'; const on = resolve(Globals['on']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/outlet.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/outlet.test.ts index f7683b135..098ee5a82 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/outlet.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/outlet.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let outlet = resolve(Globals['outlet']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/textarea.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/textarea.test.ts index 55895c5db..e2a5501ab 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/textarea.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/textarea.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let textarea = resolve(Globals['textarea']); let Textarea = resolve(Globals['Textarea']); diff --git a/packages/environment-ember-loose/__tests__/intrinsics/unbound.test.ts b/packages/environment-ember-loose/__tests__/intrinsics/unbound.test.ts index f2bd1c5df..096c36b3d 100644 --- a/packages/environment-ember-loose/__tests__/intrinsics/unbound.test.ts +++ b/packages/environment-ember-loose/__tests__/intrinsics/unbound.test.ts @@ -1,5 +1,5 @@ import { expectTypeOf } from 'expect-type'; -import { Globals, resolve } from '@glint/environment-ember-loose/types'; +import { Globals, resolve } from '@glint/environment-ember-loose/-private/dsl'; let unbound = resolve(Globals['unbound']); diff --git a/packages/environment-ember-loose/__tests__/modifier.test.ts b/packages/environment-ember-loose/__tests__/modifier.test.ts index 481a3272c..069bc0156 100644 --- a/packages/environment-ember-loose/__tests__/modifier.test.ts +++ b/packages/environment-ember-loose/__tests__/modifier.test.ts @@ -1,7 +1,7 @@ import Modifier, { modifier } from '@glint/environment-ember-loose/ember-modifier'; -import { resolve } from '@glint/environment-ember-loose/types'; +import { resolve } from '@glint/environment-ember-loose/-private/dsl'; import { expectTypeOf } from 'expect-type'; -import { CreatesModifier } from '@glint/template/-private'; +import { BoundModifier } from '@glint/template/-private/integration'; // Class-based modifier { @@ -39,8 +39,8 @@ import { CreatesModifier } from '@glint/template/-private'; let neat = resolve(NeatModifier); - expectTypeOf(neat({}, 'hello')).toEqualTypeOf>(); - expectTypeOf(neat({ multiplier: 3 }, 'hello')).toEqualTypeOf>(); + expectTypeOf(neat({}, 'hello')).toEqualTypeOf>(); + expectTypeOf(neat({ multiplier: 3 }, 'hello')).toEqualTypeOf>(); // @ts-expect-error: missing required positional arg neat({}); @@ -69,8 +69,8 @@ import { CreatesModifier } from '@glint/template/-private'; let neat = resolve(definition); - expectTypeOf(neat({}, 'hello')).toEqualTypeOf>(); - expectTypeOf(neat({ multiplier: 3 }, 'hello')).toEqualTypeOf>(); + expectTypeOf(neat({}, 'hello')).toEqualTypeOf>(); + expectTypeOf(neat({ multiplier: 3 }, 'hello')).toEqualTypeOf>(); // @ts-expect-error: missing required positional arg neat({}); From 35d8798eaca8f5a73aeb9fe464714c23bd8f26df Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:06:46 +0100 Subject: [PATCH 7/9] Update remaining tests for new layout --- packages/config/__tests__/environment.test.ts | 2 +- .../core/__tests__/cli/declaration.test.ts | 2 +- packages/transform/__tests__/debug.test.ts | 32 ++++++++--------- packages/transform/__tests__/rewrite.test.ts | 36 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/config/__tests__/environment.test.ts b/packages/config/__tests__/environment.test.ts index 3ce41f0a4..baa7e0c1e 100644 --- a/packages/config/__tests__/environment.test.ts +++ b/packages/config/__tests__/environment.test.ts @@ -38,7 +38,7 @@ describe('Environments', () => { test('getting specified template tag config', () => { let tags = { - '@glimmerx/component': { hbs: { typesSource: '@glint/environment-glimmerx/types' } }, + '@glimmerx/component': { hbs: { typesSource: '@glint/environment-glimmerx/-private/dsl' } }, }; let env = new GlintEnvironment('test-env', { tags }); diff --git a/packages/core/__tests__/cli/declaration.test.ts b/packages/core/__tests__/cli/declaration.test.ts index 1b637b3b7..12ff2d160 100644 --- a/packages/core/__tests__/cli/declaration.test.ts +++ b/packages/core/__tests__/cli/declaration.test.ts @@ -45,7 +45,7 @@ describe('CLI: emitting declarations', () => { Args: ApplicationArgs; }> { private startupTime; - static template: import(\\"@glint/environment-glimmerx/types\\").Template; + static template: void; } " `); diff --git a/packages/transform/__tests__/debug.test.ts b/packages/transform/__tests__/debug.test.ts index 95d535a3a..731c0dd4d 100644 --- a/packages/transform/__tests__/debug.test.ts +++ b/packages/transform/__tests__/debug.test.ts @@ -32,47 +32,47 @@ describe('Debug utilities', () => { | Mapping: Template | hbs(0:50): hbs\`\\\\n \\\\n \` - | ts(0:277): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/types\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext) {\\\\n χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {});\\\\n 𝚪;\\\\n });\\\\n})() + | ts(0:291): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/-private/dsl\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/-private/dsl\\").ResolveContext) {\\\\n χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {});\\\\n 𝚪;\\\\n });\\\\n})() | | | Mapping: Identifier | | hbs(0:0): - | | ts(170:181): MyComponent + | | ts(184:195): MyComponent | | | | Mapping: ElementNode | | hbs(9:46): - | | ts(186:259): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {}); + | | ts(200:273): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {}); | | | | | Mapping: ElementNode | | | hbs(9:46): - | | | ts(186:259): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {}); + | | | ts(200:273): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {}); | | | | | | | Mapping: Identifier | | | | hbs(10:25): HelperComponent - | | | | ts(214:229): HelperComponent + | | | | ts(228:243): HelperComponent | | | | | | | | Mapping: AttrNode | | | | hbs(26:43): @foo={{this.bar}} - | | | | ts(233:249): foo: 𝚪.this.bar + | | | | ts(247:263): foo: 𝚪.this.bar | | | | | | | | | Mapping: Identifier | | | | | hbs(27:30): foo - | | | | | ts(233:236): foo + | | | | | ts(247:250): foo | | | | | | | | | | Mapping: MustacheStatement | | | | | hbs(31:43): {{this.bar}} - | | | | | ts(238:249): 𝚪.this.bar + | | | | | ts(252:263): 𝚪.this.bar | | | | | | | | | | | Mapping: PathExpression | | | | | | hbs(33:41): this.bar - | | | | | | ts(238:249): 𝚪.this.bar + | | | | | | ts(252:263): 𝚪.this.bar | | | | | | | | | | | | | Mapping: Identifier | | | | | | | hbs(33:37): this - | | | | | | | ts(241:245): this + | | | | | | | ts(255:259): this | | | | | | | | | | | | | | Mapping: Identifier | | | | | | | hbs(38:41): bar - | | | | | | | ts(246:249): bar + | | | | | | | ts(260:263): bar | | | | | | | | | | | | | | | | | | @@ -83,23 +83,23 @@ describe('Debug utilities', () => { | Mapping: Template | hbs(0:28): hbs\`\\\\n Hello, {{@foo}}\\\\n \` - | ts(0:262): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/types\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext) {\\\\n χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({}));\\\\n 𝚪;\\\\n });\\\\n})() + | ts(0:276): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/-private/dsl\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/-private/dsl\\").ResolveContext) {\\\\n χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({}));\\\\n 𝚪;\\\\n });\\\\n})() | | | Mapping: Identifier | | hbs(0:0): - | | ts(170:185): HelperComponent + | | ts(184:199): HelperComponent | | | | Mapping: MustacheStatement | | hbs(16:24): {{@foo}} - | | ts(190:242): χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({})) + | | ts(204:256): χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({})) | | | | | Mapping: PathExpression | | | hbs(18:22): @foo - | | | ts(225:236): 𝚪.args.foo + | | | ts(239:250): 𝚪.args.foo | | | | | | | Mapping: Identifier | | | | hbs(19:22): foo - | | | | ts(233:236): foo + | | | | ts(247:250): foo | | | | | | | | | diff --git a/packages/transform/__tests__/rewrite.test.ts b/packages/transform/__tests__/rewrite.test.ts index a6c406d57..cef09428d 100644 --- a/packages/transform/__tests__/rewrite.test.ts +++ b/packages/transform/__tests__/rewrite.test.ts @@ -25,8 +25,8 @@ describe('rewriteModule', () => { export default class MyComponent extends Component { static template = (() => { hbs; - let χ!: typeof import(\\"@glint/environment-glimmerx/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-glimmerx/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/-private/dsl\\").ResolveContext) { 𝚪; }); })(); @@ -53,8 +53,8 @@ describe('rewriteModule', () => { export default class MyComponent extends Component<{ value: K }> { static template = (() => { hbs; - let χ!: typeof import(\\"@glint/environment-glimmerx/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext>) { + let χ!: typeof import(\\"@glint/environment-glimmerx/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/-private/dsl\\").ResolveContext>) { 𝚪; }); })(); @@ -91,8 +91,8 @@ describe('rewriteModule', () => { export default class extends Component { static template = (() => { hbs; - let χ!: typeof import(\\"@glint/environment-glimmerx/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-glimmerx/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/-private/dsl\\").ResolveContext) { 𝚪; }); })(); @@ -149,8 +149,8 @@ describe('rewriteModule', () => { export default class MyComponent extends Component { private static '~template' = (() => { MyComponent['~template']; - let χ!: typeof import(\\"@glint/environment-ember-loose/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-ember-loose/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/-private/dsl\\").ResolveContext) { 𝚪; }); })(); @@ -182,8 +182,8 @@ describe('rewriteModule', () => { class MyComponent extends Component { private static '~template' = (() => { MyComponent['~template']; - let χ!: typeof import(\\"@glint/environment-ember-loose/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-ember-loose/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/-private/dsl\\").ResolveContext) { 𝚪; }); })(); @@ -215,8 +215,8 @@ describe('rewriteModule', () => { export default class MyComponent extends Component<{ value: K }> { private static '~template' = (() => { MyComponent['~template']; - let χ!: typeof import(\\"@glint/environment-ember-loose/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/types\\").ResolveContext>) { + let χ!: typeof import(\\"@glint/environment-ember-loose/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/-private/dsl\\").ResolveContext>) { 𝚪; }); })(); @@ -256,8 +256,8 @@ describe('rewriteModule', () => { "import Component from '@glimmer/component'; export default class extends Component { private static '~template' = (() => { - let χ!: typeof import(\\"@glint/environment-ember-loose/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-ember-loose/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/-private/dsl\\").ResolveContext) { 𝚪; }); })(); @@ -334,7 +334,7 @@ describe('rewriteModule', () => { import Component from '@glimmer/component'; export default class MyComponent extends Component { } - declare module '@glint/environment-ember-loose/types/registry' { + declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Test: MyComponent; } @@ -355,13 +355,13 @@ describe('rewriteModule', () => { export default class MyComponent extends Component { private static '~template' = (() => { MyComponent['~template']; - let χ!: typeof import(\\"@glint/environment-ember-loose/types\\"); - return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/types\\").ResolveContext) { + let χ!: typeof import(\\"@glint/environment-ember-loose/-private/dsl\\"); + return χ.template(function(𝚪: import(\\"@glint/environment-ember-loose/-private/dsl\\").ResolveContext) { 𝚪; }); })(); } - declare module '@glint/environment-ember-loose/types/registry' { + declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Test: MyComponent; } From 8e21d1b7d045e03608008beec82f9b4d9a3a349d Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:07:18 +0100 Subject: [PATCH 8/9] Update test packages for new layout --- test-packages/ts-ember-app/app/components/bar/index.ts | 2 +- .../ts-ember-app/app/components/ember-component.ts | 2 +- test-packages/ts-ember-app/app/components/foo.ts | 2 +- test-packages/ts-ember-app/app/components/qux.ts | 2 +- test-packages/ts-ember-app/app/helpers/repeat.ts | 6 +++--- .../ts-ember-app/app/pods/components/baz/component.ts | 2 +- test-packages/ts-ember-app/types/demo-ember-app/index.d.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test-packages/ts-ember-app/app/components/bar/index.ts b/test-packages/ts-ember-app/app/components/bar/index.ts index fc277d694..0a6c2853e 100644 --- a/test-packages/ts-ember-app/app/components/bar/index.ts +++ b/test-packages/ts-ember-app/app/components/bar/index.ts @@ -10,7 +10,7 @@ export default class Bar extends Component { name = 'BAR'; } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Bar: typeof Bar; } diff --git a/test-packages/ts-ember-app/app/components/ember-component.ts b/test-packages/ts-ember-app/app/components/ember-component.ts index b152118f1..0cb7c9a46 100644 --- a/test-packages/ts-ember-app/app/components/ember-component.ts +++ b/test-packages/ts-ember-app/app/components/ember-component.ts @@ -21,7 +21,7 @@ export default class EmberComponent extends Component { } } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { EmberComponent: typeof EmberComponent; } diff --git a/test-packages/ts-ember-app/app/components/foo.ts b/test-packages/ts-ember-app/app/components/foo.ts index ffb8a8657..ef053b487 100644 --- a/test-packages/ts-ember-app/app/components/foo.ts +++ b/test-packages/ts-ember-app/app/components/foo.ts @@ -6,7 +6,7 @@ export default class Foo extends Component { obj = { a: 'A', b: 'B', c: 1, 𝚪: '' }; } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Foo: typeof Foo; } diff --git a/test-packages/ts-ember-app/app/components/qux.ts b/test-packages/ts-ember-app/app/components/qux.ts index 68254cab1..07a9df599 100644 --- a/test-packages/ts-ember-app/app/components/qux.ts +++ b/test-packages/ts-ember-app/app/components/qux.ts @@ -4,7 +4,7 @@ export default class Qux extends Component { name = 'QUX'; } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Qux: typeof Qux; } diff --git a/test-packages/ts-ember-app/app/helpers/repeat.ts b/test-packages/ts-ember-app/app/helpers/repeat.ts index 32cea8a03..4f0bbaa59 100644 --- a/test-packages/ts-ember-app/app/helpers/repeat.ts +++ b/test-packages/ts-ember-app/app/helpers/repeat.ts @@ -1,6 +1,6 @@ import { helper } from '@glint/environment-ember-loose/ember-component/helper'; -function repeat(params: [string, number]/*, hash*/) { +function repeat(params: [string, number] /*, hash*/) { return params[0].repeat(params[1]); } @@ -8,8 +8,8 @@ const repeatHelper = helper(repeat); export default repeatHelper; -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { - 'repeat': typeof repeatHelper; + repeat: typeof repeatHelper; } } diff --git a/test-packages/ts-ember-app/app/pods/components/baz/component.ts b/test-packages/ts-ember-app/app/pods/components/baz/component.ts index ccd32b474..fed9e5d48 100644 --- a/test-packages/ts-ember-app/app/pods/components/baz/component.ts +++ b/test-packages/ts-ember-app/app/pods/components/baz/component.ts @@ -8,7 +8,7 @@ export default class BazComponent extends Component { name = 'BAZ'; } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Baz: typeof BazComponent; } diff --git a/test-packages/ts-ember-app/types/demo-ember-app/index.d.ts b/test-packages/ts-ember-app/types/demo-ember-app/index.d.ts index fa8531f2b..65ff771ab 100644 --- a/test-packages/ts-ember-app/types/demo-ember-app/index.d.ts +++ b/test-packages/ts-ember-app/types/demo-ember-app/index.d.ts @@ -1,5 +1,5 @@ import Ember from 'ember'; -import '@glint/environment-ember-loose/types/registry'; +import '@glint/environment-ember-loose/registry'; declare global { // eslint-disable-next-line @typescript-eslint/no-empty-interface From 9915d5016ff49a765eda61205a71f6192a321821 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Fri, 19 Mar 2021 18:07:30 +0100 Subject: [PATCH 9/9] Update README for new registry location --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 992c3d0a5..acee9c792 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ export default class Greeting extends Component { Because Ember's template resolution occurs dynamically at runtime today, Glint needs a way of mapping the names used in your templates to the actual backing value they'll be resolved to. This takes the form of a "type registry" similar to the one that powers Ember Data's types. -The recommended approach is to include a declaration in each component, modifier or helper module that adds it to the registry, which is the default export of `@glint/environment-ember-loose/types/registry`. +The recommended approach is to include a declaration in each component, modifier or helper module that adds it to the registry, which is the default export of `@glint/environment-ember-loose/registry`. ```ts // app/components/greeting.ts @@ -228,7 +228,7 @@ export default class Greeting extends Component { // ... } -declare module '@glint/environment-ember-loose/types/registry' { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { Greeting: typeof Greeting; }