From 4f084909dfdfb777185d0a614340fd22a7f4038e Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 21:50:22 +0200 Subject: [PATCH 1/7] Create new core package --- packages/cloudinary/.gitignore | 1 - packages/core/.eslintignore | 13 +++++++ packages/core/.eslintrc.js | 44 ++++++++++++++++++++++ packages/core/.gitignore | 11 ++++++ packages/core/README.md | 7 ++++ packages/core/babel.config.json | 12 ++++++ packages/core/package.json | 67 +++++++++++++++++++++++++++++++++ packages/core/rollup.config.mjs | 21 +++++++++++ packages/core/src/index.ts | 1 + packages/core/src/types.ts | 0 packages/core/tsconfig.json | 37 ++++++++++++++++++ packages/imgix/.gitignore | 1 - pnpm-lock.yaml | 51 +++++++++++++++++++++++++ 13 files changed, 264 insertions(+), 2 deletions(-) create mode 100644 packages/core/.eslintignore create mode 100644 packages/core/.eslintrc.js create mode 100644 packages/core/.gitignore create mode 100644 packages/core/README.md create mode 100644 packages/core/babel.config.json create mode 100644 packages/core/package.json create mode 100644 packages/core/rollup.config.mjs create mode 100644 packages/core/src/index.ts create mode 100644 packages/core/src/types.ts create mode 100644 packages/core/tsconfig.json diff --git a/packages/cloudinary/.gitignore b/packages/cloudinary/.gitignore index b02e86e73..74e255b33 100644 --- a/packages/cloudinary/.gitignore +++ b/packages/cloudinary/.gitignore @@ -1,7 +1,6 @@ # The authoritative copies of these live in the monorepo root (because they're # more useful on github that way), but the build copies them into here so they # will also appear in published NPM packages. -/README.md /LICENSE.md # compiled output diff --git a/packages/core/.eslintignore b/packages/core/.eslintignore new file mode 100644 index 000000000..62fd7c1fc --- /dev/null +++ b/packages/core/.eslintignore @@ -0,0 +1,13 @@ +# compiled output +/dist/ +/declarations/ +/tmp/ + +# dependencies +/node_modules/ + +# misc +/coverage/ +!.* +.*/ +.eslintcache diff --git a/packages/core/.eslintrc.js b/packages/core/.eslintrc.js new file mode 100644 index 000000000..b5e27d048 --- /dev/null +++ b/packages/core/.eslintrc.js @@ -0,0 +1,44 @@ +'use strict'; + +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + babelOptions: { + root: __dirname, + }, + }, + extends: ['eslint:recommended', 'plugin:prettier/recommended'], + env: { + browser: true, + }, + rules: {}, + overrides: [ + // ts files + { + files: ['**/*.ts'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + // Add any custom rules here + }, + }, + // node files + { + files: ['./.eslintrc.js', './.prettierrc.js'], + parserOptions: { + sourceType: 'script', + }, + env: { + browser: false, + node: true, + }, + plugins: ['n'], + extends: ['plugin:n/recommended'], + }, + ], +}; diff --git a/packages/core/.gitignore b/packages/core/.gitignore new file mode 100644 index 000000000..74e255b33 --- /dev/null +++ b/packages/core/.gitignore @@ -0,0 +1,11 @@ +# The authoritative copies of these live in the monorepo root (because they're +# more useful on github that way), but the build copies them into here so they +# will also appear in published NPM packages. +/LICENSE.md + +# compiled output +/dist +/declarations + +# npm/pnpm/yarn pack output +*.tgz diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 000000000..eb287fa37 --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1,7 @@ +# @ember-responsive-image/core + +Internal package + +## License + +This project is licensed under the [MIT License](../../LICENSE.md). diff --git a/packages/core/babel.config.json b/packages/core/babel.config.json new file mode 100644 index 000000000..f9e44f31f --- /dev/null +++ b/packages/core/babel.config.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "@babel/plugin-transform-typescript", + { + "allExtensions": true, + "onlyRemoveTypeImports": true, + "allowDeclareFields": true + } + ] + ] +} diff --git a/packages/core/package.json b/packages/core/package.json new file mode 100644 index 000000000..4ad780d76 --- /dev/null +++ b/packages/core/package.json @@ -0,0 +1,67 @@ +{ + "name": "@ember-responsive-image/core", + "version": "1.0.0-beta.0", + "description": "Internal core functions and config for ember-responsive-image", + "keywords": [ + "ember-addon" + ], + "repository": "https://github.com/simonihmig/ember-responsive-image", + "license": "MIT", + "author": "Simon Ihmig ", + "files": [ + "declarations", + "dist" + ], + "scripts": { + "build": "concurrently 'npm:build:*'", + "build:js": "rollup --config", + "build:types": "tsc --emitDeclarationOnly", + "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'", + "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'", + "lint:js": "eslint . --cache", + "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --noEmit", + "start": "concurrently 'npm:start:*'", + "start:js": "rollup --config --watch --no-watch.clearScreen", + "start:types": "tsc --emitDeclarationOnly --watch", + "test": "No tests available", + "prepack": "rollup --config" + }, + "devDependencies": { + "@babel/core": "7.24.4", + "@babel/plugin-transform-typescript": "7.24.4", + "@babel/runtime": "7.24.4", + "@tsconfig/ember": "3.0.6", + "@typescript-eslint/eslint-plugin": "7.7.1", + "@typescript-eslint/parser": "7.7.1", + "@rollup/plugin-babel": "6.0.4", + "concurrently": "8.2.2", + "eslint": "8.57.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-n": "17.3.1", + "eslint-plugin-prettier": "5.1.3", + "prettier": "3.2.5", + "rollup": "4.16.4", + "rollup-plugin-copy": "3.5.0", + "typescript": "5.4.5" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" + }, + "exports": { + ".": { + "types": "./declarations/index.d.ts", + "default": "./dist/index.js" + } + }, + "typesVersions": { + "*": { + "*": [ + "declarations/index" + ] + } + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/packages/core/rollup.config.mjs b/packages/core/rollup.config.mjs new file mode 100644 index 000000000..77c10d573 --- /dev/null +++ b/packages/core/rollup.config.mjs @@ -0,0 +1,21 @@ +import { babel } from '@rollup/plugin-babel'; +import copy from 'rollup-plugin-copy'; + +export default { + input: 'src/index.ts', + output: { + dir: './dist', + }, + + plugins: [ + babel(), + + // Copy Readme and License into published package + copy({ + targets: [ + // { src: '../../README.md', dest: '.' }, + { src: '../../LICENSE.md', dest: '.' }, + ], + }), + ], +}; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts new file mode 100644 index 000000000..098f1619e --- /dev/null +++ b/packages/core/src/index.ts @@ -0,0 +1 @@ +// export type * from './types.ts'; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 000000000..11326ca89 --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,37 @@ +{ + "extends": "@tsconfig/ember/tsconfig.json", + "include": ["src/**/*", "unpublished-development-types/**/*"], + "compilerOptions": { + "allowJs": true, + "noEmit": false, + "declarationDir": "declarations", + + /** + https://www.typescriptlang.org/tsconfig#rootDir + "Default: The longest common path of all non-declaration input files." + + Because we want our declarations' structure to match our rollup output, + we need this "rootDir" to match the "srcDir" in the rollup.config.mjs. + + This way, we can have simpler `package.json#exports` that matches + imports to files on disk + */ + "rootDir": "./src", + + /** + https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax + + We don't want to include types dependencies in our compiled output, so tell TypeScript + to enforce using `import type` instead of `import` for Types. + */ + "verbatimModuleSyntax": true, + + /** + https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions + + We want our tooling to know how to resolve our custom files so the appropriate plugins + can do the proper transformations on those files. + */ + "allowImportingTsExtensions": true + } +} diff --git a/packages/imgix/.gitignore b/packages/imgix/.gitignore index b02e86e73..74e255b33 100644 --- a/packages/imgix/.gitignore +++ b/packages/imgix/.gitignore @@ -1,7 +1,6 @@ # The authoritative copies of these live in the monorepo root (because they're # more useful on github that way), but the build copies them into here so they # will also appear in published NPM packages. -/README.md /LICENSE.md # compiled output diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5e1e2a0f..ab1ab2339 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -261,6 +261,57 @@ importers: specifier: 5.4.5 version: 5.4.5 + packages/core: + devDependencies: + '@babel/core': + specifier: 7.24.4 + version: 7.24.4 + '@babel/plugin-transform-typescript': + specifier: 7.24.4 + version: 7.24.4(@babel/core@7.24.4) + '@babel/runtime': + specifier: 7.24.4 + version: 7.24.4 + '@rollup/plugin-babel': + specifier: 6.0.4 + version: 6.0.4(@babel/core@7.24.4)(@types/babel__core@7.20.5)(rollup@4.16.4) + '@tsconfig/ember': + specifier: 3.0.6 + version: 3.0.6 + '@typescript-eslint/eslint-plugin': + specifier: 7.7.1 + version: 7.7.1(@typescript-eslint/parser@7.7.1(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/parser': + specifier: 7.7.1 + version: 7.7.1(eslint@8.57.0)(typescript@5.4.5) + concurrently: + specifier: 8.2.2 + version: 8.2.2 + eslint: + specifier: 8.57.0 + version: 8.57.0 + eslint-config-prettier: + specifier: 9.1.0 + version: 9.1.0(eslint@8.57.0) + eslint-plugin-n: + specifier: 17.3.1 + version: 17.3.1(eslint@8.57.0) + eslint-plugin-prettier: + specifier: 5.1.3 + version: 5.1.3(@types/eslint@8.56.10)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.2.5) + prettier: + specifier: 3.2.5 + version: 3.2.5 + rollup: + specifier: 4.16.4 + version: 4.16.4 + rollup-plugin-copy: + specifier: 3.5.0 + version: 3.5.0 + typescript: + specifier: 5.4.5 + version: 5.4.5 + packages/ember-responsive-image: dependencies: '@ember-responsive-image/blurhash': From 1e0b5330b5679df3155c6717d2e547ad416c79d9 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:07:39 +0200 Subject: [PATCH 2/7] Extract types and util into core package --- packages/cloudinary/package.json | 1 + .../responsive-image-cloudinary-provider.ts | 8 ++-- packages/core/rollup.config.mjs | 4 +- packages/core/src/index.ts | 3 +- .../src/utils => core/src}/match.ts | 2 +- packages/core/src/types.ts | 37 +++++++++++++++++++ packages/ember-responsive-image/package.json | 1 + .../src/components/responsive-image.ts | 6 ++- .../src/helpers/responsive-image-resolve.ts | 2 +- packages/ember-responsive-image/src/index.ts | 2 - packages/ember-responsive-image/src/types.ts | 37 ------------------- packages/imgix/package.json | 1 + .../responsive-image-imgix-provider.ts | 8 ++-- packages/webpack/package.json | 1 + packages/webpack/src/export.ts | 5 ++- packages/webpack/src/images.ts | 2 +- packages/webpack/src/types.ts | 2 +- pnpm-lock.yaml | 12 ++++++ 18 files changed, 77 insertions(+), 57 deletions(-) rename packages/{ember-responsive-image/src/utils => core/src}/match.ts (89%) delete mode 100644 packages/ember-responsive-image/src/types.ts diff --git a/packages/cloudinary/package.json b/packages/cloudinary/package.json index 74deeb791..6d63e87da 100644 --- a/packages/cloudinary/package.json +++ b/packages/cloudinary/package.json @@ -45,6 +45,7 @@ "@babel/core": "7.24.4", "@babel/plugin-transform-typescript": "7.24.4", "@babel/runtime": "7.24.4", + "@ember-responsive-image/core": "workspace:*", "ember-responsive-image": "workspace:*", "@embroider/addon-dev": "4.3.1", "@glimmer/component": "1.1.2", diff --git a/packages/cloudinary/src/helpers/responsive-image-cloudinary-provider.ts b/packages/cloudinary/src/helpers/responsive-image-cloudinary-provider.ts index f244a1555..99809e50f 100644 --- a/packages/cloudinary/src/helpers/responsive-image-cloudinary-provider.ts +++ b/packages/cloudinary/src/helpers/responsive-image-cloudinary-provider.ts @@ -4,11 +4,9 @@ import { assert } from '@ember/debug'; import { getOwnConfig } from '@embroider/macros'; import type { CloudinaryConfig } from '../types.ts'; -import type { - ResponsiveImageService, - ImageType, - ImageData, -} from 'ember-responsive-image'; +import type { ResponsiveImageService } from 'ember-responsive-image'; + +import type { ImageType, ImageData } from '@ember-responsive-image/core'; interface CloudinaryOptions { transformations?: string; diff --git a/packages/core/rollup.config.mjs b/packages/core/rollup.config.mjs index 77c10d573..3b9c09fd0 100644 --- a/packages/core/rollup.config.mjs +++ b/packages/core/rollup.config.mjs @@ -8,7 +8,9 @@ export default { }, plugins: [ - babel(), + babel({ + extensions: ['.js', '.ts'], + }), // Copy Readme and License into published package copy({ diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 098f1619e..cb504eb11 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1 +1,2 @@ -// export type * from './types.ts'; +export type * from './types.ts'; +export { findMatchingImage } from './match.ts'; diff --git a/packages/ember-responsive-image/src/utils/match.ts b/packages/core/src/match.ts similarity index 89% rename from packages/ember-responsive-image/src/utils/match.ts rename to packages/core/src/match.ts index 2408fa5f1..aff689ac7 100644 --- a/packages/ember-responsive-image/src/utils/match.ts +++ b/packages/core/src/match.ts @@ -1,4 +1,4 @@ -import type { ImageOutputResult, ImageType } from '../types.ts'; +import type { ImageOutputResult, ImageType } from './types.ts'; export function findMatchingImage( images: ImageOutputResult[], diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index e69de29bb..76899ac38 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -0,0 +1,37 @@ +export type ImageType = 'png' | 'jpeg' | 'webp' | 'avif'; + +export interface LqipBase { + type: string; +} + +export interface LqipInline extends LqipBase { + type: 'inline'; + class: string; +} + +export interface LqipColor extends LqipBase { + type: 'color'; + class: string; +} + +export interface LqipBlurhash extends LqipBase { + type: 'blurhash'; + hash: string; + width: number; + height: number; +} + +export interface ImageData { + imageTypes: ImageType[]; + availableWidths?: number[]; + aspectRatio?: number; + imageUrlFor(width: number, type?: ImageType): string; + fingerprint?: string; + lqip?: LqipInline | LqipColor | LqipBlurhash; +} + +export interface ImageOutputResult { + url: string; + width: number; + format: ImageType; +} diff --git a/packages/ember-responsive-image/package.json b/packages/ember-responsive-image/package.json index cdd5031f2..14b5a1864 100644 --- a/packages/ember-responsive-image/package.json +++ b/packages/ember-responsive-image/package.json @@ -53,6 +53,7 @@ "@babel/core": "7.24.4", "@babel/plugin-transform-typescript": "7.24.4", "@babel/runtime": "7.24.4", + "@ember-responsive-image/core": "workspace:*", "@embroider/addon-dev": "4.3.1", "@glimmer/component": "1.1.2", "@glimmer/tracking": "1.1.2", diff --git a/packages/ember-responsive-image/src/components/responsive-image.ts b/packages/ember-responsive-image/src/components/responsive-image.ts index 4d23d87d3..e8bb2e513 100644 --- a/packages/ember-responsive-image/src/components/responsive-image.ts +++ b/packages/ember-responsive-image/src/components/responsive-image.ts @@ -5,7 +5,11 @@ import { assert } from '@ember/debug'; import { cached, tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { macroCondition, dependencySatisfies } from '@embroider/macros'; -import type { ImageType, LqipBlurhash, ImageData } from '../types.ts'; +import type { + ImageType, + LqipBlurhash, + ImageData, +} from '@ember-responsive-image/core'; import './responsive-image.css'; diff --git a/packages/ember-responsive-image/src/helpers/responsive-image-resolve.ts b/packages/ember-responsive-image/src/helpers/responsive-image-resolve.ts index f492d2a89..a590dd081 100644 --- a/packages/ember-responsive-image/src/helpers/responsive-image-resolve.ts +++ b/packages/ember-responsive-image/src/helpers/responsive-image-resolve.ts @@ -2,7 +2,7 @@ import { inject as service } from '@ember/service'; import { htmlSafe } from '@ember/template'; import Helper from '@ember/component/helper'; import ResponsiveImageService from '../services/responsive-image.ts'; -import type { ImageType, ImageData } from '../types.ts'; +import type { ImageType, ImageData } from '@ember-responsive-image/core'; interface ResponsiveImageResolveSignature { Args: { diff --git a/packages/ember-responsive-image/src/index.ts b/packages/ember-responsive-image/src/index.ts index 55458990f..659a718be 100644 --- a/packages/ember-responsive-image/src/index.ts +++ b/packages/ember-responsive-image/src/index.ts @@ -1,5 +1,3 @@ export { default as ResponsiveImage } from './components/responsive-image.ts'; export { default as ResponsiveImageService } from './services/responsive-image.ts'; export { default as resolve } from './helpers/responsive-image-resolve.ts'; -export * from './types.ts'; -export { findMatchingImage } from './utils/match.ts'; diff --git a/packages/ember-responsive-image/src/types.ts b/packages/ember-responsive-image/src/types.ts deleted file mode 100644 index 76899ac38..000000000 --- a/packages/ember-responsive-image/src/types.ts +++ /dev/null @@ -1,37 +0,0 @@ -export type ImageType = 'png' | 'jpeg' | 'webp' | 'avif'; - -export interface LqipBase { - type: string; -} - -export interface LqipInline extends LqipBase { - type: 'inline'; - class: string; -} - -export interface LqipColor extends LqipBase { - type: 'color'; - class: string; -} - -export interface LqipBlurhash extends LqipBase { - type: 'blurhash'; - hash: string; - width: number; - height: number; -} - -export interface ImageData { - imageTypes: ImageType[]; - availableWidths?: number[]; - aspectRatio?: number; - imageUrlFor(width: number, type?: ImageType): string; - fingerprint?: string; - lqip?: LqipInline | LqipColor | LqipBlurhash; -} - -export interface ImageOutputResult { - url: string; - width: number; - format: ImageType; -} diff --git a/packages/imgix/package.json b/packages/imgix/package.json index 0fe78df80..7510084d6 100644 --- a/packages/imgix/package.json +++ b/packages/imgix/package.json @@ -45,6 +45,7 @@ "@babel/core": "7.24.4", "@babel/plugin-transform-typescript": "7.24.4", "@babel/runtime": "7.24.4", + "@ember-responsive-image/core": "workspace:*", "ember-responsive-image": "workspace:*", "@embroider/addon-dev": "4.3.1", "@glimmer/component": "1.1.2", diff --git a/packages/imgix/src/helpers/responsive-image-imgix-provider.ts b/packages/imgix/src/helpers/responsive-image-imgix-provider.ts index 2d6472940..4ed5eddf8 100644 --- a/packages/imgix/src/helpers/responsive-image-imgix-provider.ts +++ b/packages/imgix/src/helpers/responsive-image-imgix-provider.ts @@ -4,11 +4,9 @@ import { assert } from '@ember/debug'; import { getOwnConfig } from '@embroider/macros'; import type { ImgixConfig } from '../types.ts'; -import type { - ResponsiveImageService, - ImageType, - ImageData, -} from 'ember-responsive-image'; +import type { ResponsiveImageService } from 'ember-responsive-image'; + +import type { ImageType, ImageData } from '@ember-responsive-image/core'; interface ImgixProviderSignature { Args: { diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 140f0b81d..245464135 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -22,6 +22,7 @@ "prepack": "rollup --config" }, "dependencies": { + "@ember-responsive-image/core": "workspace:^", "base-n": "^3.0.0", "loader-utils": "^3.2.0", "sharp": "^0.33.0" diff --git a/packages/webpack/src/export.ts b/packages/webpack/src/export.ts index 22a51bdbd..636e4f956 100644 --- a/packages/webpack/src/export.ts +++ b/packages/webpack/src/export.ts @@ -1,4 +1,7 @@ -import type { ImageOutputResult, ImageType } from 'ember-responsive-image'; +import type { + ImageOutputResult, + ImageType, +} from '@ember-responsive-image/core'; import { interpolateName } from 'loader-utils'; import * as path from 'path'; import type { LoaderContext } from 'webpack'; diff --git a/packages/webpack/src/images.ts b/packages/webpack/src/images.ts index 9d4eb4d27..4f4fa605b 100644 --- a/packages/webpack/src/images.ts +++ b/packages/webpack/src/images.ts @@ -1,4 +1,4 @@ -import type { ImageType } from 'ember-responsive-image'; +import type { ImageType } from '@ember-responsive-image/core'; import type { Metadata, Sharp } from 'sharp'; import type { LoaderContext } from 'webpack'; import type { diff --git a/packages/webpack/src/types.ts b/packages/webpack/src/types.ts index 937fd0648..dd9daf61e 100644 --- a/packages/webpack/src/types.ts +++ b/packages/webpack/src/types.ts @@ -3,7 +3,7 @@ import type { LqipBlurhash, LqipColor, LqipInline, -} from 'ember-responsive-image'; +} from '@ember-responsive-image/core'; import type { Metadata, Sharp } from 'sharp'; export type OutputImageType = 'original' | ImageType; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab1ab2339..b7fb6a003 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -128,6 +128,9 @@ importers: '@babel/runtime': specifier: 7.24.4 version: 7.24.4 + '@ember-responsive-image/core': + specifier: workspace:* + version: link:../core '@embroider/addon-dev': specifier: 4.3.1 version: 4.3.1(@glint/template@1.4.0)(rollup@4.16.4) @@ -348,6 +351,9 @@ importers: '@babel/runtime': specifier: 7.24.4 version: 7.24.4 + '@ember-responsive-image/core': + specifier: workspace:* + version: link:../core '@embroider/addon-dev': specifier: 4.3.1 version: 4.3.1(@glint/template@1.4.0)(rollup@4.16.4) @@ -508,6 +514,9 @@ importers: '@babel/runtime': specifier: 7.24.4 version: 7.24.4 + '@ember-responsive-image/core': + specifier: workspace:* + version: link:../core '@embroider/addon-dev': specifier: 4.3.1 version: 4.3.1(@glint/template@1.4.0)(rollup@4.16.4) @@ -646,6 +655,9 @@ importers: '@ember-responsive-image/blurhash': specifier: workspace:^ version: link:../blurhash + '@ember-responsive-image/core': + specifier: workspace:^ + version: link:../core base-n: specifier: ^3.0.0 version: 3.0.0 From cb15f48566ee31b4c4373f30634fd665d45d92ef Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:16:19 +0200 Subject: [PATCH 3/7] Fix build script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02a6537fc..c1db4275b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "MIT", "author": "Simon Ihmig ", "scripts": { - "build": "pnpm --filter ember-responsive-image run build && pnpm --filter @ember-responsive-image/webpack run build && pnpm --filter @ember-responsive-image/blurhash run build && pnpm --filter @ember-responsive-image/cloudinary run build && pnpm --filter @ember-responsive-image/imgix run build", + "build": "pnpm --filter @ember-responsive-image/core run build && pnpm --filter ember-responsive-image run build && pnpm --filter @ember-responsive-image/webpack run build && pnpm --filter @ember-responsive-image/blurhash run build && pnpm --filter @ember-responsive-image/cloudinary run build && pnpm --filter @ember-responsive-image/imgix run build", "lint": "pnpm run -r lint", "lint:fix": "pnpm run -r lint:fix", "prepare": "pnpm build", From 24eba8500f81d68c32ad62549adeb3708917387b Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:36:28 +0200 Subject: [PATCH 4/7] Fix type errors --- packages/ember-responsive-image/package.json | 2 +- packages/ember-responsive-image/src/index.ts | 1 + pnpm-lock.yaml | 9 ++++++--- test-app/package.json | 1 + test-app/tests/unit/utils/utils-test.ts | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/ember-responsive-image/package.json b/packages/ember-responsive-image/package.json index 14b5a1864..cc693ee02 100644 --- a/packages/ember-responsive-image/package.json +++ b/packages/ember-responsive-image/package.json @@ -31,6 +31,7 @@ "prepack": "rollup --config" }, "dependencies": { + "@ember-responsive-image/core": "workspace:^", "@ember/render-modifiers": "^2.0.0", "@embroider/addon-shim": "^1.8.7", "@embroider/macros": "^1.0.0", @@ -53,7 +54,6 @@ "@babel/core": "7.24.4", "@babel/plugin-transform-typescript": "7.24.4", "@babel/runtime": "7.24.4", - "@ember-responsive-image/core": "workspace:*", "@embroider/addon-dev": "4.3.1", "@glimmer/component": "1.1.2", "@glimmer/tracking": "1.1.2", diff --git a/packages/ember-responsive-image/src/index.ts b/packages/ember-responsive-image/src/index.ts index 659a718be..987dcad8f 100644 --- a/packages/ember-responsive-image/src/index.ts +++ b/packages/ember-responsive-image/src/index.ts @@ -1,3 +1,4 @@ export { default as ResponsiveImage } from './components/responsive-image.ts'; export { default as ResponsiveImageService } from './services/responsive-image.ts'; export { default as resolve } from './helpers/responsive-image-resolve.ts'; +export type { ImageData } from '@ember-responsive-image/core'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7fb6a003..61e4d4613 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -320,6 +320,9 @@ importers: '@ember-responsive-image/blurhash': specifier: workspace:^ version: link:../blurhash + '@ember-responsive-image/core': + specifier: workspace:^ + version: link:../core '@ember/render-modifiers': specifier: ^2.0.0 version: 2.1.0(@babel/core@7.24.4)(@glint/template@1.4.0)(ember-source@5.8.0(@babel/core@7.24.4)(@glimmer/component@1.1.2(@babel/core@7.24.4))(@glint/template@1.4.0)(rsvp@4.8.5)) @@ -351,9 +354,6 @@ importers: '@babel/runtime': specifier: 7.24.4 version: 7.24.4 - '@ember-responsive-image/core': - specifier: workspace:* - version: link:../core '@embroider/addon-dev': specifier: 4.3.1 version: 4.3.1(@glint/template@1.4.0)(rollup@4.16.4) @@ -761,6 +761,9 @@ importers: '@ember-responsive-image/cloudinary': specifier: workspace:* version: link:../packages/cloudinary + '@ember-responsive-image/core': + specifier: workspace:* + version: link:../packages/core '@ember-responsive-image/imgix': specifier: workspace:* version: link:../packages/imgix diff --git a/test-app/package.json b/test-app/package.json index 8abf42d1a..515f3aeeb 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -27,6 +27,7 @@ "@babel/core": "7.24.4", "@ember-responsive-image/blurhash": "workspace:*", "@ember-responsive-image/cloudinary": "workspace:*", + "@ember-responsive-image/core": "workspace:*", "@ember-responsive-image/imgix": "workspace:*", "@ember-responsive-image/webpack": "workspace:*", "@ember/optional-features": "2.1.0", diff --git a/test-app/tests/unit/utils/utils-test.ts b/test-app/tests/unit/utils/utils-test.ts index e7bbfeb68..a23ca8f8d 100644 --- a/test-app/tests/unit/utils/utils-test.ts +++ b/test-app/tests/unit/utils/utils-test.ts @@ -1,5 +1,5 @@ -import type { ImageOutputResult } from 'ember-responsive-image'; -import { findMatchingImage } from 'ember-responsive-image'; +import type { ImageOutputResult } from '@ember-responsive-image/core'; +import { findMatchingImage } from '@ember-responsive-image/core'; import { module, test } from 'qunit'; module('Unit | Utility | utils', function () { From 374ab0334b531b97f9d82758918f0d2b5d56fdbd Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:38:47 +0200 Subject: [PATCH 5/7] Fix test script --- packages/core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/package.json b/packages/core/package.json index 4ad780d76..a41bc90f8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -24,7 +24,7 @@ "start": "concurrently 'npm:start:*'", "start:js": "rollup --config --watch --no-watch.clearScreen", "start:types": "tsc --emitDeclarationOnly --watch", - "test": "No tests available", + "test": "echo 'No tests available'", "prepack": "rollup --config" }, "devDependencies": { From 1626fcbef525525617bb15b4caf9b4825644e218 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:42:28 +0200 Subject: [PATCH 6/7] Fix webpack output --- packages/webpack/src/export.ts | 2 +- .../webpack/tests/__snapshots__/index.test.ts.snap | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/webpack/src/export.ts b/packages/webpack/src/export.ts index 636e4f956..82463e891 100644 --- a/packages/webpack/src/export.ts +++ b/packages/webpack/src/export.ts @@ -66,7 +66,7 @@ export default function exportLoader( const aspectRatio = input.sharpMeta ? getAspectRatio(input.sharpMeta) : 1; const moduleOutput: string[] = [ - "import { findMatchingImage } from 'ember-responsive-image/utils/match';", + "import { findMatchingImage } from '@ember-responsive-image/core';", ]; for (const importedModule of input.imports) { diff --git a/packages/webpack/tests/__snapshots__/index.test.ts.snap b/packages/webpack/tests/__snapshots__/index.test.ts.snap index 6bb74cffc..77a2c85de 100644 --- a/packages/webpack/tests/__snapshots__/index.test.ts.snap +++ b/packages/webpack/tests/__snapshots__/index.test.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`LQIP blurhash LQIP is supported 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; const images = [{"url":__webpack_public_path__ + "images/image-640w-88d805ca22658da9.jpg","width":640,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-640w-b6cb63c0233da565.webp","width":640,"format":"webp"},{"url":__webpack_public_path__ + "images/image-750w-88d805ca22658da9.jpg","width":750,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-750w-b6cb63c0233da565.webp","width":750,"format":"webp"},{"url":__webpack_public_path__ + "images/image-828w-88d805ca22658da9.jpg","width":828,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-828w-b6cb63c0233da565.webp","width":828,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1080w-88d805ca22658da9.jpg","width":1080,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1080w-b6cb63c0233da565.webp","width":1080,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1200w-88d805ca22658da9.jpg","width":1200,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1200w-b6cb63c0233da565.webp","width":1200,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1920w-88d805ca22658da9.jpg","width":1920,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1920w-b6cb63c0233da565.webp","width":1920,"format":"webp"},{"url":__webpack_public_path__ + "images/image-2048w-88d805ca22658da9.jpg","width":2048,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-2048w-b6cb63c0233da565.webp","width":2048,"format":"webp"},{"url":__webpack_public_path__ + "images/image-3840w-88d805ca22658da9.jpg","width":3840,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-3840w-b6cb63c0233da565.webp","width":3840,"format":"webp"}]; export default { imageTypes: ["jpeg","webp"], @@ -15,7 +15,7 @@ export default { `; exports[`LQIP color LQIP is supported 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; import '/fixtures/image.jpg.css!=!@ember-responsive-image/webpack/lqip/color-css!/fixtures/image.jpg?className=eri-dyn-1'; const images = [{"url":__webpack_public_path__ + "images/image-640w-88d805ca22658da9.jpg","width":640,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-640w-b6cb63c0233da565.webp","width":640,"format":"webp"},{"url":__webpack_public_path__ + "images/image-750w-88d805ca22658da9.jpg","width":750,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-750w-b6cb63c0233da565.webp","width":750,"format":"webp"},{"url":__webpack_public_path__ + "images/image-828w-88d805ca22658da9.jpg","width":828,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-828w-b6cb63c0233da565.webp","width":828,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1080w-88d805ca22658da9.jpg","width":1080,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1080w-b6cb63c0233da565.webp","width":1080,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1200w-88d805ca22658da9.jpg","width":1200,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1200w-b6cb63c0233da565.webp","width":1200,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1920w-88d805ca22658da9.jpg","width":1920,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1920w-b6cb63c0233da565.webp","width":1920,"format":"webp"},{"url":__webpack_public_path__ + "images/image-2048w-88d805ca22658da9.jpg","width":2048,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-2048w-b6cb63c0233da565.webp","width":2048,"format":"webp"},{"url":__webpack_public_path__ + "images/image-3840w-88d805ca22658da9.jpg","width":3840,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-3840w-b6cb63c0233da565.webp","width":3840,"format":"webp"}]; export default { @@ -30,7 +30,7 @@ export default { `; exports[`LQIP inline LQIP is supported 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; import '/fixtures/image.jpg.css!=!@ember-responsive-image/webpack/lqip/inline-css!/fixtures/image.jpg?className=eri-dyn-1&targetPixels=60'; const images = [{"url":__webpack_public_path__ + "images/image-640w-88d805ca22658da9.jpg","width":640,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-640w-b6cb63c0233da565.webp","width":640,"format":"webp"},{"url":__webpack_public_path__ + "images/image-750w-88d805ca22658da9.jpg","width":750,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-750w-b6cb63c0233da565.webp","width":750,"format":"webp"},{"url":__webpack_public_path__ + "images/image-828w-88d805ca22658da9.jpg","width":828,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-828w-b6cb63c0233da565.webp","width":828,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1080w-88d805ca22658da9.jpg","width":1080,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1080w-b6cb63c0233da565.webp","width":1080,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1200w-88d805ca22658da9.jpg","width":1200,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1200w-b6cb63c0233da565.webp","width":1200,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1920w-88d805ca22658da9.jpg","width":1920,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1920w-b6cb63c0233da565.webp","width":1920,"format":"webp"},{"url":__webpack_public_path__ + "images/image-2048w-88d805ca22658da9.jpg","width":2048,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-2048w-b6cb63c0233da565.webp","width":2048,"format":"webp"},{"url":__webpack_public_path__ + "images/image-3840w-88d805ca22658da9.jpg","width":3840,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-3840w-b6cb63c0233da565.webp","width":3840,"format":"webp"}]; export default { @@ -45,7 +45,7 @@ export default { `; exports[`custom loader options are supported 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; const images = [{"url":"https:/cdn.example.com/images/test-1000.jpg","width":1000,"format":"jpeg"},{"url":"https:/cdn.example.com/images/test-1000.avif","width":1000,"format":"avif"},{"url":"https:/cdn.example.com/images/test-2000.jpg","width":2000,"format":"jpeg"},{"url":"https:/cdn.example.com/images/test-2000.avif","width":2000,"format":"avif"}]; export default { imageTypes: ["jpeg","avif"], @@ -59,7 +59,7 @@ export default { `; exports[`custom query params are supported 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; import '/fixtures/image.jpg.css!=!@ember-responsive-image/webpack/lqip/color-css!/fixtures/image.jpg?className=eri-dyn-0'; const images = [{"url":__webpack_public_path__ + "images/image-100w-19932319c3cde13c.webp","width":100,"format":"webp"},{"url":__webpack_public_path__ + "images/image-200w-b6cb63c0233da565.webp","width":200,"format":"webp"}]; export default { @@ -74,7 +74,7 @@ export default { `; exports[`it produces expected output 1`] = ` -"import { findMatchingImage } from 'ember-responsive-image/utils/match'; +"import { findMatchingImage } from '@ember-responsive-image/core'; const images = [{"url":__webpack_public_path__ + "images/image-640w-88d805ca22658da9.jpg","width":640,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-640w-b6cb63c0233da565.webp","width":640,"format":"webp"},{"url":__webpack_public_path__ + "images/image-750w-88d805ca22658da9.jpg","width":750,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-750w-b6cb63c0233da565.webp","width":750,"format":"webp"},{"url":__webpack_public_path__ + "images/image-828w-88d805ca22658da9.jpg","width":828,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-828w-b6cb63c0233da565.webp","width":828,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1080w-88d805ca22658da9.jpg","width":1080,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1080w-b6cb63c0233da565.webp","width":1080,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1200w-88d805ca22658da9.jpg","width":1200,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1200w-b6cb63c0233da565.webp","width":1200,"format":"webp"},{"url":__webpack_public_path__ + "images/image-1920w-88d805ca22658da9.jpg","width":1920,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-1920w-b6cb63c0233da565.webp","width":1920,"format":"webp"},{"url":__webpack_public_path__ + "images/image-2048w-88d805ca22658da9.jpg","width":2048,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-2048w-b6cb63c0233da565.webp","width":2048,"format":"webp"},{"url":__webpack_public_path__ + "images/image-3840w-88d805ca22658da9.jpg","width":3840,"format":"jpeg"},{"url":__webpack_public_path__ + "images/image-3840w-b6cb63c0233da565.webp","width":3840,"format":"webp"}]; export default { imageTypes: ["jpeg","webp"], From 6b9b55c336905f3720f41adcc833b8e0d4d64044 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Thu, 25 Apr 2024 22:46:04 +0200 Subject: [PATCH 7/7] Remove ember-addon keyword from core --- packages/core/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index a41bc90f8..b2aac92e8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,9 +2,6 @@ "name": "@ember-responsive-image/core", "version": "1.0.0-beta.0", "description": "Internal core functions and config for ember-responsive-image", - "keywords": [ - "ember-addon" - ], "repository": "https://github.com/simonihmig/ember-responsive-image", "license": "MIT", "author": "Simon Ihmig ",