diff --git a/README.md b/README.md index d46f070f..59bdd719 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To see Ember Freestyle in action, visit [https://chrislopresto.github.io/ember-f * Node.js v18 or above * Ember Auto Import v2 or above -ember-freestyle includes Typescript types and provides `addon/glint.ts` for Glint usage +ember-freestyle includes TypeScript types, and provides a template registry that can be imported from `ember-freestyle/template-registry` for Glint usage. ## Installation diff --git a/addon/glint.ts b/addon/glint.ts deleted file mode 100644 index fcd3ae9d..00000000 --- a/addon/glint.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type FreestyleUsage from 'ember-freestyle/components/freestyle/usage'; -import type FreestyleUsageArgument from 'ember-freestyle/components/freestyle/usage/argument'; -import type FreestyleUsageArray from 'ember-freestyle/components/freestyle/usage/array'; -import type FreestyleUsageBasicCssVariable from 'ember-freestyle/components/freestyle/usage/basic-css-variable'; -import type FreestyleUsageBool from 'ember-freestyle/components/freestyle/usage/bool'; -import type FreestyleUsageBoolControl from 'ember-freestyle/components/freestyle/usage/bool/control'; -import type FreestyleUsageNumber from 'ember-freestyle/components/freestyle/usage/number'; -import type FreestyleUsageNumberControl from 'ember-freestyle/components/freestyle/usage/number/control'; -import type FreestyleUsageObject from 'ember-freestyle/components/freestyle/usage/object'; -import type FreestyleUsageObjectControl from 'ember-freestyle/components/freestyle/usage/object/control'; -import type FreestyleUsageString from 'ember-freestyle/components/freestyle/usage/string'; -import type FreestyleUsageStringControl from 'ember-freestyle/components/freestyle/usage/string/control'; -import type FreestyleUsageComponentLike from 'ember-freestyle/components/freestyle/usage/component-like'; -import type FreestyleUsageComponentLikeControl from 'ember-freestyle/components/freestyle/usage/component-like/control'; -import type FreestyleAnnotation from 'ember-freestyle/components/freestyle-annotation'; -import type FreestyleCollection from 'ember-freestyle/components/freestyle-collection'; -import type FreestyleDynamic from 'ember-freestyle/components/freestyle-dynamic'; -import type FreestyleDynamicInput from 'ember-freestyle/components/freestyle-dynamic-input'; -import type FreestyleDynamicInputSelectOption from 'ember-freestyle/components/freestyle-dynamic-input-select-option'; -import type FreestyleFocusButton from 'ember-freestyle/components/freestyle-focus-button'; -import type FreestyleGuide from 'ember-freestyle/components/freestyle-guide'; -import type FreestyleMenu from 'ember-freestyle/components/freestyle-menu'; -import type FreestylePalette from 'ember-freestyle/components/freestyle-palette'; -import type FreestylePaletteItem from 'ember-freestyle/components/freestyle-palette-item'; -import type FreestyleSection from 'ember-freestyle/components/freestyle-section'; -import type FreestyleSource from 'ember-freestyle/components/freestyle-source'; -import type FreestyleSubsection from 'ember-freestyle/components/freestyle-subsection'; -import type FreestyleTypeface from 'ember-freestyle/components/freestyle-typeface'; -import type OldFreestyleUsage from 'ember-freestyle/components/freestyle-usage'; -import type FreestyleUsageControls from 'ember-freestyle/components/freestyle-usage-controls'; -import type FreestyleVariant from 'ember-freestyle/components/freestyle-variant'; -import type FreestyleVariantList from 'ember-freestyle/components/freestyle-variant-list'; -import FreestyleHighlight from './modifiers/freestyle-highlight'; - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'Freestyle::Usage': typeof FreestyleUsage; - 'Freestyle::Usage::Argument': typeof FreestyleUsageArgument; - 'freestyle/usage/argument': typeof FreestyleUsageArgument; - 'Freestyle::Usage::Array': typeof FreestyleUsageArray; - 'freestyle/usage/array': typeof FreestyleUsageArray; - 'Freestyle::Usage::Bool': typeof FreestyleUsageBool; - 'freestyle/usage/bool': typeof FreestyleUsageBool; - 'Freestyle::Usage::Bool::Control': typeof FreestyleUsageBoolControl; - 'Freestyle::Usage::Number': typeof FreestyleUsageNumber; - 'Freestyle::Usage::BasicCssVariable': typeof FreestyleUsageBasicCssVariable; - 'freestyle/usage/basic-css-variable': typeof FreestyleUsageBasicCssVariable; - 'freestyle/usage/number': typeof FreestyleUsageNumber; - 'Freestyle::Usage::Number::Control': typeof FreestyleUsageNumberControl; - 'Freestyle::Usage::Object': typeof FreestyleUsageObject; - 'Freestyle::Usage::Object::Control': typeof FreestyleUsageObjectControl; - 'freestyle/usage/object': typeof FreestyleUsageObject; - 'Freestyle::Usage::String': typeof FreestyleUsageString; - 'freestyle/usage/string': typeof FreestyleUsageString; - 'Freestyle::Usage::String::Control': typeof FreestyleUsageStringControl; - 'Freestyle::Usage::ComponentLike': typeof FreestyleUsageComponentLike; - 'freestyle/usage/component-like': typeof FreestyleUsageComponentLike; - 'Freestyle::Usage::ComponentLike::Control': typeof FreestyleUsageComponentLikeControl; - FreestyleAnnotation: typeof FreestyleAnnotation; - FreestyleCollection: typeof FreestyleCollection; - FreestyleDynamic: typeof FreestyleDynamic; - FreestyleDynamicInput: typeof FreestyleDynamicInput; - FreestyleDynamicInputSelectOption: typeof FreestyleDynamicInputSelectOption; - FreestyleFocusButton: typeof FreestyleFocusButton; - FreestyleGuide: typeof FreestyleGuide; - FreestyleMenu: typeof FreestyleMenu; - FreestylePalette: typeof FreestylePalette; - FreestylePaletteItem: typeof FreestylePaletteItem; - FreestyleSection: typeof FreestyleSection; - FreestyleSource: typeof FreestyleSource; - FreestyleSubsection: typeof FreestyleSubsection; - 'freestyle-subsection': typeof FreestyleSubsection; - FreestyleTypeface: typeof FreestyleTypeface; - FreestyleUsage: typeof OldFreestyleUsage; - FreestyleUsageControls: typeof FreestyleUsageControls; - FreestyleVariant: typeof FreestyleVariant; - 'freestyle-variant': typeof FreestyleVariant; - FreestyleVariantList: typeof FreestyleVariantList; - 'freestyle-variant-list': typeof FreestyleVariantList; - 'freestyle-highlight': typeof FreestyleHighlight; - } -} diff --git a/addon/template-registry.ts b/addon/template-registry.ts new file mode 100644 index 00000000..7d04fbdc --- /dev/null +++ b/addon/template-registry.ts @@ -0,0 +1,107 @@ +// components +import type FreestyleAnnotation from 'ember-freestyle/components/freestyle-annotation'; +import type FreestyleCollection from 'ember-freestyle/components/freestyle-collection'; +import type FreestyleDynamicInputSelectOption from 'ember-freestyle/components/freestyle-dynamic-input-select-option'; +import type FreestyleDynamicInput from 'ember-freestyle/components/freestyle-dynamic-input'; +import type FreestyleDynamic from 'ember-freestyle/components/freestyle-dynamic'; +import type FreestyleFocusButton from 'ember-freestyle/components/freestyle-focus-button'; +import type FreestyleGuide from 'ember-freestyle/components/freestyle-guide'; +import type FreestyleMenu from 'ember-freestyle/components/freestyle-menu'; +import type FreestylePaletteItem from 'ember-freestyle/components/freestyle-palette-item'; +import type FreestylePalette from 'ember-freestyle/components/freestyle-palette'; +import type FreestyleSection from 'ember-freestyle/components/freestyle-section'; +import type FreestyleSource from 'ember-freestyle/components/freestyle-source'; +import type FreestyleSubsection from 'ember-freestyle/components/freestyle-subsection'; +import type FreestyleTypeface from 'ember-freestyle/components/freestyle-typeface'; +import type FreestyleUsageControls from 'ember-freestyle/components/freestyle-usage-controls'; +import type FreestyleUsageLegacy from 'ember-freestyle/components/freestyle-usage'; +import type FreestyleVariantList from 'ember-freestyle/components/freestyle-variant-list'; +import type FreestyleVariant from 'ember-freestyle/components/freestyle-variant'; +import type FreestyleUsageArgument from 'ember-freestyle/components/freestyle/usage/argument'; +import type FreestyleUsageArray from 'ember-freestyle/components/freestyle/usage/array'; +import type FreestyleUsageBasicCssVariable from 'ember-freestyle/components/freestyle/usage/basic-css-variable'; +import type FreestyleUsageBoolControl from 'ember-freestyle/components/freestyle/usage/bool/control'; +import type FreestyleUsageBool from 'ember-freestyle/components/freestyle/usage/bool'; +import type FreestyleUsageComponentLikeControl from 'ember-freestyle/components/freestyle/usage/component-like/control'; +import type FreestyleUsageComponentLike from 'ember-freestyle/components/freestyle/usage/component-like'; +import type FreestyleUsage from 'ember-freestyle/components/freestyle/usage'; +import type FreestyleUsageNumberControl from 'ember-freestyle/components/freestyle/usage/number/control'; +import type FreestyleUsageNumber from 'ember-freestyle/components/freestyle/usage/number'; +import type FreestyleUsageObjectControl from 'ember-freestyle/components/freestyle/usage/object/control'; +import type FreestyleUsageObject from 'ember-freestyle/components/freestyle/usage/object'; +import type FreestyleUsageStringControl from 'ember-freestyle/components/freestyle/usage/string/control'; +import type FreestyleUsageString from 'ember-freestyle/components/freestyle/usage/string'; + +// modifiers +import type FreestyleHighlight from 'ember-freestyle/modifiers/freestyle-highlight'; + +export default interface EmberFreestyleRegistry { + // components + 'freestyle-annotation': typeof FreestyleAnnotation; + FreestyleAnnotation: typeof FreestyleAnnotation; + 'freestyle-collection': typeof FreestyleCollection; + FreestyleCollection: typeof FreestyleCollection; + 'freestyle-dynamic-input-select-option': typeof FreestyleDynamicInputSelectOption; + FreestyleDynamicInputSelectOption: typeof FreestyleDynamicInputSelectOption; + 'freestyle-dynamic-input': typeof FreestyleDynamicInput; + FreestyleDynamicInput: typeof FreestyleDynamicInput; + 'freestyle-dynamic': typeof FreestyleDynamic; + FreestyleDynamic: typeof FreestyleDynamic; + 'freestyle-focus-button': typeof FreestyleFocusButton; + FreestyleFocusButton: typeof FreestyleFocusButton; + 'freestyle-guide': typeof FreestyleGuide; + FreestyleGuide: typeof FreestyleGuide; + 'freestyle-menu': typeof FreestyleMenu; + FreestyleMenu: typeof FreestyleMenu; + 'freestyle-palette-item': typeof FreestylePaletteItem; + FreestylePaletteItem: typeof FreestylePaletteItem; + 'freestyle-palette': typeof FreestylePalette; + FreestylePalette: typeof FreestylePalette; + 'freestyle-section': typeof FreestyleSection; + FreestyleSection: typeof FreestyleSection; + 'freestyle-source': typeof FreestyleSource; + FreestyleSource: typeof FreestyleSource; + 'freestyle-subsection': typeof FreestyleSubsection; + FreestyleSubsection: typeof FreestyleSubsection; + 'freestyle-typeface': typeof FreestyleTypeface; + FreestyleTypeface: typeof FreestyleTypeface; + 'freestyle-usage-controls': typeof FreestyleUsageControls; + FreestyleUsageControls: typeof FreestyleUsageControls; + 'freestyle-usage': typeof FreestyleUsageLegacy; + FreestyleUsage: typeof FreestyleUsageLegacy; + 'freestyle-variant-list': typeof FreestyleVariantList; + FreestyleVariantList: typeof FreestyleVariantList; + 'freestyle-variant': typeof FreestyleVariant; + FreestyleVariant: typeof FreestyleVariant; + 'freestyle/usage/argument': typeof FreestyleUsageArgument; + 'Freestyle::Usage::Argument': typeof FreestyleUsageArgument; + 'freestyle/usage/array': typeof FreestyleUsageArray; + 'Freestyle::Usage::Array': typeof FreestyleUsageArray; + 'freestyle/usage/basic-css-variable': typeof FreestyleUsageBasicCssVariable; + 'Freestyle::Usage::BasicCssVariable': typeof FreestyleUsageBasicCssVariable; + 'freestyle/usage/bool/control': typeof FreestyleUsageBoolControl; + 'Freestyle::Usage::Bool::Control': typeof FreestyleUsageBoolControl; + 'freestyle/usage/bool': typeof FreestyleUsageBool; + 'Freestyle::Usage::Bool': typeof FreestyleUsageBool; + 'freestyle/usage/component-like/control': typeof FreestyleUsageComponentLikeControl; + 'Freestyle::Usage::ComponentLike::Control': typeof FreestyleUsageComponentLikeControl; + 'freestyle/usage/component-like': typeof FreestyleUsageComponentLike; + 'Freestyle::Usage::ComponentLike': typeof FreestyleUsageComponentLike; + 'freestyle/usage': typeof FreestyleUsage; + 'Freestyle::Usage': typeof FreestyleUsage; + 'freestyle/usage/number/control': typeof FreestyleUsageNumberControl; + 'Freestyle::Usage::Number::Control': typeof FreestyleUsageNumberControl; + 'freestyle/usage/number': typeof FreestyleUsageNumber; + 'Freestyle::Usage::Number': typeof FreestyleUsageNumber; + 'freestyle/usage/object/control': typeof FreestyleUsageObjectControl; + 'Freestyle::Usage::Object::Control': typeof FreestyleUsageObjectControl; + 'freestyle/usage/object': typeof FreestyleUsageObject; + 'Freestyle::Usage::Object': typeof FreestyleUsageObject; + 'freestyle/usage/string/control': typeof FreestyleUsageStringControl; + 'Freestyle::Usage::String::Control': typeof FreestyleUsageStringControl; + 'freestyle/usage/string': typeof FreestyleUsageString; + 'Freestyle::Usage::String': typeof FreestyleUsageString; + + // modifiers + 'freestyle-highlight': typeof FreestyleHighlight; +} diff --git a/tests/integration/components/freestyle/usage/component-like-test.ts b/tests/integration/components/freestyle/usage/component-like-test.ts index 2369da1d..71f1bd03 100644 --- a/tests/integration/components/freestyle/usage/component-like-test.ts +++ b/tests/integration/components/freestyle/usage/component-like-test.ts @@ -44,7 +44,7 @@ module( }); test('Does not render the controls', async function (this: Context, assert) { - await render(hbs`(hbs``); diff --git a/types/global.d.ts b/types/global.d.ts index b29ca21b..fe15fe73 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -1,5 +1,7 @@ import '@glint/environment-ember-loose'; +import type FreestyleRegistry from 'ember-freestyle/template-registry'; + import AndHelper from 'ember-truth-helpers/helpers/and'; import EqHelper from 'ember-truth-helpers/helpers/eq'; import NotHelper from 'ember-truth-helpers/helpers/not'; @@ -7,7 +9,7 @@ import { HelperLike, ModifierLike } from '@glint/template'; import { SafeString } from '@ember/template/-private/handlebars'; declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { + export default interface Registry extends FreestyleRegistry { and: typeof AndHelper; eq: typeof EqHelper; not: typeof NotHelper;