1.13.1 • Published 2 days ago

@embroider/util v1.13.1

Weekly downloads
148
License
MIT
Repository
github
Last release
2 days ago

@embroider/util

Utilities to help apps and addons with Embroider support.

Compatibility

  • Ember.js v3.13 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install @embroider/util

The Utilities

ensureSafeComponent

This function is intended to help addon authors who still need to support Ember < 3.25. In all other cases, instead of using this you should directly pass components around as values (not as strings) and invoke them directly with angle brackets (not the {{component}} helper).

For the full explanation of why and how you would use this, see the Addon Author Guide.

Example usage in Javascript:

import { ensureSafeComponent } from '@embroider/util';
import Component from '@glimmer/component';
import DefaultTitleComponent from './default-title';

export default class extends Component {
  get title() {
    return ensureSafeComponent(this.args.title || DefaultTitleComponent, this);
  }
}
<this.title />

Example usage in a template:

{{#let
  (ensure-safe-component (or @title (component 'default-title')))
  as |Title|
}}
  <Title />
{{/let}}

The first argument is allowed to be:

  • a string. If we see a string, we will emit a deprecation warning because passing components-as-strings doesn't work safely under Embroider with staticComponents enabled. We will return a value that is safe to invoke (via angle brackets) on your current Ember version.
  • a curried component definition (which is the kind of value you receive when someone does <YourComponent @customThing={{component "fancy"}}/>). These are returned unchanged, because they're always safe to invoke.
  • a component class, in which case if your ember version does not yet support directly invoking component classes, we will convert it to a curried component definition for you.

In the Javascript version, you must pass a second argument that is any object with an owner (a Component instance works great).

Glint usage

If you are using Glint and environment-ember-loose, you can add all the macros to your app at once by adding

import type { EmbroiderUtilRegistry } from "@embroider/util";

to your app's e.g. types/glint.d.ts file, and making sure your registry extends from EmbroiderMacrosRegistry:

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry
    extends EmbroiderUtilRegistry, /* other registries here */ {
      // ...
    }
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

1.13.1

2 days ago

1.13.0

2 months ago

1.11.2

10 months ago

1.12.1

6 months ago

1.12.0

10 months ago

1.11.1

11 months ago

1.11.0

12 months ago

1.10.0

1 year ago

1.9.0

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.3

2 years ago

1.8.0

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.2.0

2 years ago

1.0.0

2 years ago

1.4.0

2 years ago

1.1.0

2 years ago

1.5.0

2 years ago

1.3.0

2 years ago

0.50.1

2 years ago

0.50.2

2 years ago

0.50.0

2 years ago

0.49.0

2 years ago

0.48.0

2 years ago

0.48.1

2 years ago

0.47.2

2 years ago

0.47.1

3 years ago

0.46.2

3 years ago

0.46.0

3 years ago

0.47.0

3 years ago

0.46.1

3 years ago

0.45.0

3 years ago

0.44.2

3 years ago

0.44.1

3 years ago

0.44.0

3 years ago

0.44.0-alpha.2

3 years ago

0.43.5

3 years ago

0.43.4

3 years ago

0.44.0-alpha.1

3 years ago

0.44.0-alpha.0

3 years ago

0.43.3

3 years ago

0.43.2

3 years ago

0.43.1

3 years ago

0.43.0

3 years ago

0.42.3

3 years ago

0.42.2

3 years ago

0.42.1

3 years ago

0.42.0

3 years ago

0.40.0

3 years ago

0.41.0

3 years ago

0.39.1

3 years ago

0.39.0

3 years ago

0.38.0

3 years ago

0.38.0-alpha.3

3 years ago

0.38.0-alpha.2

3 years ago

0.38.0-alpha.1

3 years ago

0.38.0-alpha.0

3 years ago

0.37.0

3 years ago

0.36.0

3 years ago

0.35.1

3 years ago

0.35.0

3 years ago

0.34.0

3 years ago

0.33.0

3 years ago

0.32.0

3 years ago

0.31.0

3 years ago