Commit graph

19 commits

Author SHA1 Message Date
ascorbic
03c3b3eb79 feat(common): add Netlify image loader (#54311)
Add an image loader for Netlify Image CDN. It is slightly different in implementation from existing loaders, because it allows absolute URLs

Fixes #54303

PR Close #54311
2024-02-08 16:17:57 +00:00
Joey Perrott
0460a9dfaf refactor: migrate common to prettier formatting (#54150)
Migrate formatting to prettier for common from clang-format

PR Close #54150
2024-01-30 16:08:07 +00:00
Tano Abeleyra
6499f5ae28 fix(common): invalid ImageKit transformation (#49201)
q-auto is an invalid/unsupported transformation and should not be used

PR Close #49201
2023-03-27 08:33:22 -07:00
Pawel Kozlowski
2c8579f1b4 refactor(common): decouple preconnect checks from image loaders (#47565)
Previously the built-in image loaders for the optimized image directive
were tightly coupled to the preconnect checks infrastructure. This was
creating a problem when developers were trying to provide a loader on
a component level (or, more generally, deeper in the DI hierarchy):
- PreconnectLinkChecker is the application-level service, provided in root;
- it makes sense to provide loaders in different parts of the DI hierarchy;

This refactoring removes the PreconnectLinkChecker configuration from
the loaders infrastructure and makes it application-wide config. The
PRECONNECT_CHECK_BLOCKLIST is also a simple provider (it was a
multi-provider previously) which should make the overall configuration
easier.

PR Close #47565
2022-09-29 16:39:35 -07:00
Andrew Kushnir
ca7bf65933 fix(common): rename rawSrc -> ngSrc in NgOptimizedImage directive (#47362)
As an ongoing effort to stabilize the NgOptimizedImage API before existing the Developer Preview, this commit renames the `rawSrc` attribute used for the NgOptimizedImage selector matching to `ngSrc`. The `rawSrcset` is also renamed to `ngSrcset` for consistency.

The motivation for this change is to align the attribute name better with other built-in directives, such as `ngFor`, `ngIf`, `ngClass`, `ngStyle`, etc.

Note: this is technically a breaking change, but since the NgOptimizedImage directive is in the Developer Preview mode, we land the change in a patch branch.

PR Close #47362
2022-09-09 14:25:37 -07:00
Kara Erickson
aa254244f4 refactor(common): clean up util.ts and preconnect_link_checker files (#47082)
This commit cleans up some stylistic nits and
moves functions out of util.ts into files that
are more specifically named (url.ts and error.ts).

PR Close #47082
2022-08-16 17:36:54 +00:00
Andrew Kushnir
f995f9fad1 refactor(common): update error messages of NgOptimizedImage directive (#47082)
This commit updates error messages that the NgOptimizedImage directive throws or logs into a console.

PR Close #47082
2022-08-16 17:36:54 +00:00
Andrew Kushnir
244ad766c0 test(common): add parent injector to the createEnvironmentInjector calls in tests (#47082)
This commit updates the `createEnvironmentInjector` calls to pass parent injector, which became required as an argument.

PR Close #47082
2022-08-16 17:36:54 +00:00
Andrew Kushnir
8106084679 refactor(common): throw an error if an absolute URL is passed to Image Loaders (#47082)
This commit updates the logic of Image Loaders to throw an error in case an absolute URL is provided an an input to the loader function. The loaders can construct URLs based on image paths relative to the bas URL configured for a loader.

PR Close #47082
2022-08-16 17:36:53 +00:00
Pawel Kozlowski
768a310b6e refactor(common): unify url error reporting in image loaders (#47082)
This refactoring pulls url-related error reporting into one place.
It also makes sure that error messages and the related error
reporting logic are tree-shakable.

PR Close #47082
2022-08-16 17:36:53 +00:00
Pawel Kozlowski
bd76ad6fa6 refactor(common): properly configure PRECONNECT_CHECK_BLOCKLIST (#47082)
Refactoring tests made me realise that we are misinterpreting the
ensurePreconnect option - in fact it should configure the
PRECONNECT_CHECK_BLOCKLIST provider _only_ if the ensurePreconnect
is set to false.

PR Close #47082
2022-08-16 17:36:53 +00:00
Pawel Kozlowski
3b17d4c011 test(common): remove unneeded describe block (#47082)
This commit removes a nested describe block as it
does't add any value this point. Also moved the
utils tests to the bottom of the file as those are
less important as compared to the other tests.

PR Close #47082
2022-08-16 17:36:53 +00:00
Katie Hempenius
bff870db61 feat(common): add cloudflare loader (#47082)
Closes #46315

PR Close #47082
2022-08-16 17:36:53 +00:00
Andrew Kushnir
3836ebbbdf refactor(common): move loader util functions to a common location (#47082)
This commit refactors the code to avoid an extra utils file and instead, all extra helpers are moved to a common location.

PR Close #47082
2022-08-16 17:36:53 +00:00
Andrew Kushnir
dde5b9bff0 refactor(common): allow Cloudinary and ImageKit loaders to specify the ensurePreconnect option (#47082)
This commit modifies the provideCloudinaryLoader and provideImageKitLoader functions to support an additional ensurePreconnect option, similar to the Imgix loader functions.

PR Close #47082
2022-08-16 17:36:53 +00:00
Katie Hempenius
4e952ba216 feat(common): add loaders for cloudinary & imagekit (#47082)
This commit adds loaders for cloudinary and imagekit.

PR Close #47082
2022-08-16 17:36:53 +00:00
Andrew Kushnir
3774d84cfb test(common): optimize image loader tests of the NgOptimizedImage directive (#47082)
This commit updates the image loader tests to avoid creating the TestBed environment, since it's not really needed for the tests. Instead, the loader functions are invoked directly and the output is verified.

PR Close #47082
2022-08-16 17:36:53 +00:00
Pawel Kozlowski
98f20436ec refactor(common): allow loaders to specify the ensurePreconnect option (#47082)
This commit modifies the provideImgixLoader function to support
an additional ensurePreconnect option. Other loaders could follow
the same pattern to support a similar option as well.

As more loaders get developed we will refactor code to streamline
the loader authoring and enforce consistency.

PR Close #47082
2022-08-16 17:36:53 +00:00
Kara Erickson
7ce497e5bc feat(common): add built-in Imgix loader (#47082)
This commit adds a built-in Imgix loader for the
NgOptimizedImage directive. If you provide the
desired Imgix hostname, an ImageLoader will be
generated with the correct options.

Usage looks like this:

```ts
providers: [
  provideImgixLoader('https://some.imgix.net')
]
```

It sets the "auto=format" flag by default, which
ensures that the smallest image format supported
by the browser is served.

This change also moves the IMAGE_LOADER, ImageLoader,
and ImageLoaderConfig into a new directory that will
be shared by all built-in image loaders.

PR Close #47082
2022-08-16 17:36:52 +00:00