Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]feat(CX-882): Reimplement OpaqueImageView #5021

Closed
wants to merge 21 commits into from

Conversation

gkartalis
Copy link
Member

@gkartalis gkartalis commented Jun 23, 2021

The type of this PR is: Enhancement

This PR resolves CX-882

Description

The problem that this ticket solves is to get Images to load on Android in a similar and more performant way as they do in iOS.

For this reason we decided to go with react-native-fast-image library.

This PR reimplements OpaqueImageView (which is the component that renders most of our Images) and also:

  • introduces react-native-fast-image
  • removes the native code and AROpaqueImageView and replaces that with <OpaqueImageView />
  • updates jest tests to cover new components
  • removes native tests related to AROpaqueImageView

FastImage component requires height and width in contrast with the Image component from react-native. This is why I added the height/width props in some cases like this: src/lib/Components/ArtworkGrids/ArtworkGridItem.tsx

Need to be fixed

  • native tests iOS
  • testing deepzoom
  • tablet testing
  • videos/screenshots
  • cleanup ( I would love to do that once everything is done)

PR Checklist (tick all before merging)

  • I have included screenshots or videos to illustrate my changes, or I have not changed anything that impacts the UI.
  • I have tested my changes on iOS and Android.
  • I have added tests for my changes, or my changes don't require testing, or I have included a link to a separate Jira ticket covering the tests.
  • I have added a feature flag, or my changes don't require a feature flag. (How do I add one?)
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added an app state migration, or my changes do not require one. (What are migrations?)
  • I have added a CHANGELOG.yml entry or my changes do not require one.

@gkartalis gkartalis self-assigned this Jun 23, 2021
@gkartalis gkartalis removed their assignment Jun 23, 2021
@@ -32,7 +33,7 @@ const Show: React.FC<Props> = ({ styles, show }) => {
<View style={[styles?.container]}>
<OpaqueImageView
imageURL={imageURL}
style={[styles?.image, { overflow: "hidden", borderRadius: 2, flex: 0 }]}
style={[styles?.image, { overflow: "hidden", borderRadius: 2, flex: 0 }] as ImageStyle}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to not use as ImageStyle here so any suggestions to avoid that are welcome.
When removing I'm getting the following error:

Type 'ImageStyle | undefined' is not assignable to type 'ImageStyle'.
Type 'undefined' is not assignable to type 'ImageStyle'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is the styles?.image, which could be undefined, and the style array doesn't like it. Doing it like styles?.image ?? {} makes sure there is "something" there and not just undefined. Not perfectly clean, but I think nicer than having a typecast. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

const sectionedArtworks = []
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
const sectionRatioSums = []
const sectionedArtworks: GenericGrid_artworks[] = []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed some of the // @ts-expect-error

const section = sectionedArtworks[sectionIndex]
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any ideas here about how to remove this as well are welcome 🤓

@gkartalis gkartalis self-assigned this Jun 25, 2021
Comment on lines 64 to 76
const useComponentSize = () => {
const [layoutHeight, setLayoutHeight] = useState(0)
const [layoutWidth, setLayoutWidth] = useState(0)

constructor(props: Props) {
super(props)
const onLayout = useCallback((event) => {
const { width, height } = event.nativeEvent.layout
const scale = PixelRatio.get()
setLayoutHeight(height * scale)
setLayoutWidth(width * scale)
}, [])

// Unless `aspectRatio` was not specified at all, default the ratio to 1 to prevent illegal layout calculations.
const ratio = props.aspectRatio
this.state = {
aspectRatio: ratio === undefined ? undefined : ratio || 1,
}
return { layoutHeight, layoutWidth, onLayout }
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could pull this out somewhere else. Any suggestions where?

@@ -155,7 +155,7 @@ class InfiniteScrollArtworksGrid extends React.Component<Props & PrivateProps, S
const { shouldAddPadding } = this.props
const artworkPadding = shouldAddPadding ? space(4) : 0

return (width - sectionMargins) / (this.props.sectionCount! - artworkPadding)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea how this calculation worked so far.. 🤔

@gkartalis gkartalis closed this Feb 14, 2022
@gkartalis gkartalis deleted the gkartalis/CX-882/reimplement-opaqueImageView branch February 14, 2022 17:48
@artsy-peril
Copy link
Contributor

artsy-peril bot commented Apr 28, 2022

yaml-lint

Author: Thomas Rasshofer

Description: A simple (CLI) tool to lint YAML files

Homepage: https://github.com/rasshofer/yaml-lint#readme

Createdover 5 years ago
Last Updated6 days ago
LicenseMIT
Maintainers1
Releases15
Direct Dependenciesconsola, globby, js-yaml and nconf
Keywordsyaml, lint, linter and cli
README

YAML Lint

A simple (CLI) tool to lint YAML files

Coverage Status

Usage

npm install --save-dev yaml-lint
const yamlLint = require('yaml-lint');

yamlLint
  .lint('test: 123')
  .then(() => {
    console.log('Valid YAML file.');
  })
  .catch((error) => {
    console.error('Invalid YAML file.', error);
  });

CLI

npm install -g yaml-lint
yamllint test.yaml

Options

YAML Lint is configured using the following options via a configuration file, environment variables, and/or command-line arguments.

First of all, YAML Lint looks for a JSON file called .yaml-lint.json within the current working directory.

{
  "schema": "CORE_SCHEMA",
  "ignore": "dir/*.yaml"
}

Afterwards, YAML Lint will take environment variables into account.

YAMLLINT_SCHEMA=CORE_SCHEMA YAMLLINT_IGNORE=dir/*.yaml yamllint

Concluding, YAML Lint will take command-line arguments into account.

yamllint --schema=CORE_SCHEMA --ignore=dir/*.yaml

(All options are merged into a single configuration using the hierarchy described above.)

schema (string)

Specifies a schema to use

ignore (string or array of strings)

Specifies one or multiple glob patterns to ignore

yamllint **/*.(yaml|yml) --ignore=foobar.yml --ignore=dir/*.yaml

Changelog

  • 1.6.0
    • Implement support for multi-document sources
  • 1.5.0
    • Add tests for CLI
  • 1.4.0
    • Display all failing files instead of only the first best one
  • 1.3.0
    • Migrate to TypeScript and update dependencies
  • 1.2.4
    • Fix paths for ignored patterns
  • 1.2.3
    • Remove nocase rule to prevent problems on Windows
  • 1.2.2
    • Fix CLI support relative paths
  • 1.2.1
    • Fix README
  • 1.2.0
    • Add documentation regarding how to specify options
    • Update dependencies
    • Support ignoring specific files
  • 1.1.0
    • Update dependencies
    • Migrate syntax to ES2015+
  • 1.0.0
    • Update dependencies
    • Enable tests for Node.js 8
    • Remove support for Node.js 0.x
  • 0.0.4
    • Print file names when logging YAML errors while using the CLI
  • 0.0.3
    • Implement check for empty file selections while using the CLI
  • 0.0.2
    • Prettier error messages within CLI
    • Add shebang for CLI
  • 0.0.1
    • Initial version

License

Copyright (c) 2022 Thomas Rasshofer
Licensed under the MIT license.

See LICENSE for more info.

Contributors

yaml

Author: Eemeli Aro

Description: JavaScript parser and stringifier for YAML

Homepage: https://eemeli.org/yaml/

Createdabout 11 years ago
Last Updated13 days ago
LicenseISC
Maintainers1
Releases64
KeywordsYAML, parser and stringifier
README

YAML

yaml is a definitive library for YAML, the human friendly data serialization standard.
This library:

  • Supports both YAML 1.1 and YAML 1.2 and all common data schemas,
  • Passes all of the yaml-test-suite tests,
  • Can accept any string as input without throwing, parsing as much YAML out of it as it can, and
  • Supports parsing, modifying, and writing YAML comments and blank lines.

The library is released under the ISC open source license, and the code is available on GitHub.
It has no external dependencies and runs on Node.js as well as modern browsers.

For the purposes of versioning, any changes that break any of the documented endpoints or APIs will be considered semver-major breaking changes.
Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).

For more information, see the project's documentation site: eemeli.org/yaml

To install:

npm install yaml

Note: These docs are for yaml@2. For v1, see the v1.10.0 tag for the source and eemeli.org/yaml/v1 for the documentation.

API Overview

The API provided by yaml has three layers, depending on how deep you need to go: Parse & Stringify, Documents, and the underlying Lexer/Parser/Composer.
The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent AST, and the third lets you get progressively closer to YAML source, if that's your thing.

import { parse, stringify } from 'yaml'
// or
import YAML from 'yaml'
// or
const YAML = require('yaml')

Parse & Stringify

Documents

Content Nodes

Parsing YAML

YAML.parse

# file.yml
YAML:
  - A human-readable data serialization language
  - https://en.wikipedia.org/wiki/YAML
yaml:
  - A complete JavaScript implementation
  - https://www.npmjs.com/package/yaml
import fs from 'fs'
import YAML from 'yaml'

YAML.parse('3.14159')
// 3.14159

YAML.parse('[ true, false, maybe, null ]\n')
// [ true, false, 'maybe', null ]

const file = fs.readFileSync('./file.yml', 'utf8')
YAML.parse(file)
// { YAML:
//   [ 'A human-readable data serialization language',
//     'https://en.wikipedia.org/wiki/YAML' ],
//   yaml:
//   [ 'A complete JavaScript implementation',
//     'https://www.npmjs.com/package/yaml' ] }

YAML.stringify

import YAML from 'yaml'

YAML.stringify(3.14159)
// '3.14159\n'

YAML.stringify([true, false, 'maybe', null])
// `- true
// - false
// - maybe
// - null
// `

YAML.stringify({ number: 3, plain: 'string', block: 'two\nlines\n' })
// `number: 3
// plain: string
// block: |
//   two
//   lines
// `

Browser testing provided by:

stylelint-processor-styled-components

Author: Max Stoiber

Description: A stylelint processor for styled-components

Homepage: https://github.com/styled-components/stylelint-processor-styled-components#readme

Createdover 5 years ago
Last Updatedabout 2 years ago
LicenseMIT
Maintainers4
Releases30
Direct Dependencies@babel/parser, @babel/traverse, micromatch and postcss
Keywordsstylelint, processor, stylelint-processor, styled-components and lint
README

stylelint-processor-styled-components

Lint your styled components with stylelint!

Build Status
Coverage Status
Join the community on Spectrum
Greenkeeper

Video of project in use

Setup

You need:

(npm install --save-dev \
  stylelint \
  stylelint-processor-styled-components \
  stylelint-config-styled-components \
  stylelint-config-recommended)

Now use those in your .stylelintrc and run stylelint with your JavaScript files!

{
  "processors": ["stylelint-processor-styled-components"],
  "extends": [
    "stylelint-config-recommended",
    "stylelint-config-styled-components"
  ]
}

NOTE: The processor works with Flow- and TypeScript-typed files too! (we'll assume TypeScript usage if your files end in .ts or .tsx)

And it also has some options. Their default values are,

{
  "processors": [["stylelint-processor-styled-components", {
    "moduleName": "styled-components",
    "importName": "default",
    "strict": false,
    "ignoreFiles": [],
    "parserPlugins": [
      "jsx",
      ["decorators", { "decoratorsBeforeExport": true }],
      "classProperties",
      "exportExtensions",
      "functionBind",
      "functionSent"
    ]
  }]]
}
  • Combining with moduleName, importName and strict, you can tell the processor what kinds of tagged template literals to lint.
import styled, { css, keyframes } from 'styled-components';

// `importName` from `moduleName`, which means where `styled` comes from
styled(Component)``;
styled('div')``;
styled.div``;

// any other imports from `moduleName` (if `strict` is true, they will not be linted)
css``;
keyframes``;

// special extend calls, which have been deprecated in styled-components v4
Component.extend``;

  • ignoreFiles is passed to micromatch as the second parameter, which means one or more glob patterns for matching.

  • parserPlugins is used to make the processor's parser be able to parse new syntaxes. All available babel parser plugins and related options can be found in Babel's website.

Documentation

Further documentation for this processor lives on the styled-components website!

F.A.Q.

Why does it throw Unexpected token? Even thought the file didn't import styled-components.

You can custom babel plugins by option.parserPlugins now. An API example is our test. But if someone can implement #231, that will be much better.

If your project includes yarn.lock or package-lock.json, an alternative cause can be that babel related dependencies, i.e. @babel/parser and @babel/traverse, are outdated, especially when linting files with new TypeScript syntaxes. You can upgrade them by removing their entries in the lockfile and reinstall dependencies.

Why does it throw unexpected lint errors?

The processor can not always parse interpolations with right things. But you can use interpolation-tagging to help it. If you have ideas to make it more intelligent, feel free to send a PR or share your solution by an new issue.

What's more, if set syntax: css-in-js in stylelint@10, it can extract styles from styled-components without this processor. Even though there are still lots of differences with this processor, we hope this processor's abilities can be migrated to stylelint totally in the future.

I don't want specified tagged template literal to be parsed, i.e. css.

You can set option.strict. More examples are in #258.

License

Licensed under the MIT License, Copyright © 2017 Maximilian Stoiber. See LICENSE.md for more information!

Based on Mapbox' excellent stylelint-processor-markdown, thanks to @davidtheclark!

stylelint-config-styled-components

Author: ismay

Description: A shareable stylelint config for stylelint-processor-styled-components

Homepage: https://github.com/styled-components/stylelint-config-styled-components#readme

Createdover 4 years ago
Last Updatedover 4 years ago
LicenseMIT
Maintainers3
Releases1
Keywordsstylelint, stylelint-config and styled-components
README

stylelint-config-styled-components

The shareable stylelint config for stylelint-processor-styled-components

npm version
build status
greenkeeper badge

Why

When using stylelint-processor-styled-components
a couple of stylelint rules throw errors that you cannot prevent. Like
'no-empty-source' or
'no-missing-end-of-source-newline'.

This shareable config will automatically disable rules that cause unresolvable conflicts. Besides
those rules vendor prefixed properties
and values will throw an error since
styled-components automatically generates vendor prefixes for your css. Note that if you want to
change any of these rules you can always override them in your stylelint config.

Installation

npm install stylelint-config-styled-components --save-dev

Usage

After installing, add this config to your stylelint config like so:

{
  "extends": "stylelint-config-styled-components"
}

If you're extending multiple shareable configs, put this config as the last so it overrides the relevant rules in all previous configs:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-styled-components"
  ]
}

See also https://stylelint.io/user-guide/configuration for documentation on the various ways
stylelint can be configured.

License

MIT

stylelint-config-standard

Author: Stylelint

Description: Standard shareable config for Stylelint

Homepage: https://github.com/stylelint/stylelint-config-standard#readme

Createdover 6 years ago
Last Updated21 days ago
LicenseMIT
Maintainers3
Releases35
Direct Dependenciesstylelint-config-recommended
Keywordsstylelint, stylelint-config and standard
This README is too long to show.

stylelint

Author: stylelint

Description: A mighty, modern CSS linter.

Homepage: https://stylelint.io

Createdover 7 years ago
Last Updated2 days ago
LicenseMIT
Maintainers6
Releases182
Direct Dependenciesbalanced-match, colord, cosmiconfig, css-functions-list, debug, execall, fast-glob, fastest-levenshtein, file-entry-cache, get-stdin, global-modules, globby, globjoin, html-tags, ignore, import-lazy, imurmurhash, is-plain-object, known-css-properties, mathml-tag-names, meow, micromatch, normalize-path, normalize-selector, picocolors, postcss, postcss-media-query-parser, postcss-resolve-nested-selector, postcss-safe-parser, postcss-selector-parser, postcss-value-parser, resolve-from, specificity, string-width, strip-ansi, style-search, supports-hyperlinks, svg-tags, table, v8-compile-cache and write-file-atomic
Keywordscss-in-js, css, less, lint, linter, markdown, sass, scss, stylelint and sugarss
README

Stylelint

npm version
Build Status
npm downloads

A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.

Features

It's mighty as it:

  • has over 170 built-in rules for modern CSS syntax and features
  • supports plugins so you can create your own rules
  • automatically fixes problems where possible
  • is well tested with over 15000 unit tests
  • supports shareable configs that you can extend or create
  • is unopinionated so that you can customize it to your exact needs
  • complements pretty printers like Prettier
  • has a growing community and is used by Google, GitHub and WordPress

And can be extended to:

  • parse CSS-like syntaxes like SCSS, Sass, Less and SugarSS
  • extract embedded styles from HTML, Markdown and CSS-in-JS object & template literals

How it'll help you

It'll help you avoid errors, for example styles that are:

  • invalid, e.g. malformed hex colors and named grid areas
  • valid but with unintended consequences, e.g. duplicated selectors and overridden properties

And enforce conventions, for example:

  • what units, functions, at-rules etc are allowed
  • consistent patterns for selector names, at-rule names, custom properties etc
  • maximum specificity or maximum quantity of each selector type
  • your preferred notation for color functions, font weight etc

There are also rules for enforcing stylistic consistency, but we now recommend you use Stylelint alongside a pretty printer like Prettier. Linters and pretty printers are complementary tools that work together.

Example output

Example

Guides

Contributors

Stylelint is maintained by volunteers. Without the code contributions from all these fantastic people, Stylelint would not exist. Become a contributor.

Sponsors

Thank you to all our sponsors! Become a sponsor.

Backers

Thank you to all our backers! Become a backer.

Website hosting

Deploys by Netlify

License

The MIT License.

luxon

Author: Isaac Cambron

Description: Immutable date wrapper

Homepage: https://github.com/moment/luxon#readme

Createdalmost 5 years ago
Last Updated11 days ago
LicenseMIT
Maintainers1
Releases124
Keywordsdate and immutable
README

Luxon

MIT License Build Status NPM version Coverage Status PRs welcome

Luxon is a library for working with dates and times in JavaScript.

DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").toISO();

Upgrading to 2.0

Guide

Features

  • DateTime, Duration, and Interval types.
  • Immutable, chainable, unambiguous API.
  • Parsing and formatting for common and custom formats.
  • Native time zone and Intl support (no locale or tz files).

Download/install

Download/install instructions

Documentation

Development

See contributing.

Phasers to stun

jest-styled-components

Author: Michele Bertoli

Description: Jest utilities for Styled Components

Homepage: http://npmjs.com/package/jest-styled-components

Createdabout 5 years ago
Last Updated5 months ago
LicenseMIT
Maintainers4
Releases101
Direct Dependenciescss
This README is too long to show.

@artsy/auto-config

Author: Justin Bennett

Description: Artsy's shared auto release config

Homepage: https://github.com/artsy/auto-config#readme

Createdover 3 years ago
Last Updated20 days ago
LicenseMIT
Maintainers14
Releases25
README

auto-config

Artsy's shared auto release config

react-native-fast-image

Author: Dylan Vann

Description: 🚩 FastImage, performant React Native image component.

Homepage: https://github.com/DylanVann/react-native-fast-image#readme

Createdabout 5 years ago
Last Updated4 months ago
License(MIT AND Apache-2.0)
Maintainers1
Releases115
Keywordscache, cached, fastimage, image and priority
README

🚩 FastImage

Performant React Native image component.

Version
Downloads
Build Status
Code Coverage

Watch on GitHub
Star on GitHub
Tweet


FastImage example app.

React Native's Image component handles image caching like browsers
for the most part.
If the server is returning proper cache control
headers for images you'll generally get the sort of built in
caching behavior you'd have in a browser.
Even so many people have noticed:

  • Flickering.
  • Cache misses.
  • Low performance loading from cache.
  • Low performance in general.

FastImage is an Image replacement that solves these issues.
FastImage is a wrapper around
SDWebImage (iOS)
and
Glide (Android).

Features

  • Aggressively cache images.
  • Add authorization headers.
  • Prioritize images.
  • Preload images.
  • GIF support.
  • Border radius.

Usage

Note: You must be using React Native 0.60.0 or higher to use the most recent version of react-native-fast-image.

yarn add react-native-fast-image
cd ios && pod install
import FastImage from 'react-native-fast-image'

const YourImage = () => (
    <FastImage
        style={{ width: 200, height: 200 }}
        source={{
            uri: 'https://unsplash.it/400/400?image=1',
            headers: { Authorization: 'someAuthToken' },
            priority: FastImage.priority.normal,
        }}
        resizeMode={FastImage.resizeMode.contain}
    />
)

Are you using Glide already using an AppGlideModule?

Are you using Proguard?

If you use Proguard you will need to add these lines to android/app/proguard-rules.pro:

-keep public class com.dylanvann.fastimage.* {*;}
-keep public class com.dylanvann.fastimage.** {*;}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

Properties

source?: object

Source for the remote image to load.


source.uri?: string

Remote url to load the image from. e.g. 'https://facebook.github.io/react/img/logo_og.png'.


source.headers?: object

Headers to load the image with. e.g. { Authorization: 'someAuthToken' }.


source.priority?: enum

  • FastImage.priority.low - Low Priority.
  • FastImage.priority.normal (Default) - Normal Priority.
  • FastImage.priority.high - High Priority.

source.cache?: enum

  • FastImage.cacheControl.immutable - (Default) - Only updates if url changes.
  • FastImage.cacheControl.web - Use headers and follow normal caching procedures.
  • FastImage.cacheControl.cacheOnly - Only show images from cache, do not make any network requests.

resizeMode?: enum

  • FastImage.resizeMode.contain - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.cover (Default) - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.stretch - Scale width and height independently, This may change the aspect ratio of the src.
  • FastImage.resizeMode.center - Do not scale the image, keep centered.

onLoadStart?: () => void

Called when the image starts to load.


onProgress?: (event) => void

Called when the image is loading.

e.g. onProgress={e => console.log(e.nativeEvent.loaded / e.nativeEvent.total)}


onLoad?: (event) => void

Called on a successful image fetch. Called with the width and height of the loaded image.

e.g. onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}


onError?: () => void

Called on an image fetching error.


onLoadEnd?: () => void

Called when the image finishes loading, whether it was successful or an error.


style

A React Native style. Supports using borderRadius.


fallback: boolean

If true will fallback to using Image.
In this case the image will still be styled and laid out the same way as FastImage.


tintColor?: number | string

If supplied, changes the color of all the non-transparent pixels to the given color.

Static Methods

FastImage.preload: (source[]) => void

Preload images to display later. e.g.

FastImage.preload([
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
])

FastImage.clearMemoryCache: () => Promise<void>

Clear all images from memory cache.

FastImage.clearDiskCache: () => Promise<void>

Clear all images from disk cache.

Troubleshooting

If you have any problems using this library try the steps in troubleshooting and see if they fix it.

Development

Follow these instructions to get the example app running.

Supported React Native Versions

This project only aims to support the latest version of React Native.
This simplifies the development and the testing of the project.

If you require new features or bug fixes for older versions you can fork this project.

Credits

The idea for this modules came from
vovkasm's
react-native-web-image
package.
It also uses Glide and SDWebImage, but didn't have some features I needed (priority, headers).

Thanks to @mobinni for helping with the conceptualization

Licenses

  • FastImage - MIT © DylanVann
  • SDWebImage - MIT
  • Glide - BSD, part MIT and Apache 2.0. See the LICENSE file for details.

New dependencies added: react-native-fast-image, @artsy/auto-config, jest-styled-components, luxon, stylelint, stylelint-config-standard, stylelint-config-styled-components, stylelint-processor-styled-components, yaml and yaml-lint.

Hi there! 👋

We're trialing semantic commit formatting which has not been detected in your PR title.

Refer to this RFC and Conventional Commits for PR/commit formatting guidelines.

Generated by 🚫 dangerJS against e9c91f8

1 similar comment
@artsy-peril
Copy link
Contributor

artsy-peril bot commented Apr 28, 2022

yaml-lint

Author: Thomas Rasshofer

Description: A simple (CLI) tool to lint YAML files

Homepage: https://github.com/rasshofer/yaml-lint#readme

Createdover 5 years ago
Last Updated6 days ago
LicenseMIT
Maintainers1
Releases15
Direct Dependenciesconsola, globby, js-yaml and nconf
Keywordsyaml, lint, linter and cli
README

YAML Lint

A simple (CLI) tool to lint YAML files

Coverage Status

Usage

npm install --save-dev yaml-lint
const yamlLint = require('yaml-lint');

yamlLint
  .lint('test: 123')
  .then(() => {
    console.log('Valid YAML file.');
  })
  .catch((error) => {
    console.error('Invalid YAML file.', error);
  });

CLI

npm install -g yaml-lint
yamllint test.yaml

Options

YAML Lint is configured using the following options via a configuration file, environment variables, and/or command-line arguments.

First of all, YAML Lint looks for a JSON file called .yaml-lint.json within the current working directory.

{
  "schema": "CORE_SCHEMA",
  "ignore": "dir/*.yaml"
}

Afterwards, YAML Lint will take environment variables into account.

YAMLLINT_SCHEMA=CORE_SCHEMA YAMLLINT_IGNORE=dir/*.yaml yamllint

Concluding, YAML Lint will take command-line arguments into account.

yamllint --schema=CORE_SCHEMA --ignore=dir/*.yaml

(All options are merged into a single configuration using the hierarchy described above.)

schema (string)

Specifies a schema to use

ignore (string or array of strings)

Specifies one or multiple glob patterns to ignore

yamllint **/*.(yaml|yml) --ignore=foobar.yml --ignore=dir/*.yaml

Changelog

  • 1.6.0
    • Implement support for multi-document sources
  • 1.5.0
    • Add tests for CLI
  • 1.4.0
    • Display all failing files instead of only the first best one
  • 1.3.0
    • Migrate to TypeScript and update dependencies
  • 1.2.4
    • Fix paths for ignored patterns
  • 1.2.3
    • Remove nocase rule to prevent problems on Windows
  • 1.2.2
    • Fix CLI support relative paths
  • 1.2.1
    • Fix README
  • 1.2.0
    • Add documentation regarding how to specify options
    • Update dependencies
    • Support ignoring specific files
  • 1.1.0
    • Update dependencies
    • Migrate syntax to ES2015+
  • 1.0.0
    • Update dependencies
    • Enable tests for Node.js 8
    • Remove support for Node.js 0.x
  • 0.0.4
    • Print file names when logging YAML errors while using the CLI
  • 0.0.3
    • Implement check for empty file selections while using the CLI
  • 0.0.2
    • Prettier error messages within CLI
    • Add shebang for CLI
  • 0.0.1
    • Initial version

License

Copyright (c) 2022 Thomas Rasshofer
Licensed under the MIT license.

See LICENSE for more info.

Contributors

yaml

Author: Eemeli Aro

Description: JavaScript parser and stringifier for YAML

Homepage: https://eemeli.org/yaml/

Createdabout 11 years ago
Last Updated13 days ago
LicenseISC
Maintainers1
Releases64
KeywordsYAML, parser and stringifier
README

YAML

yaml is a definitive library for YAML, the human friendly data serialization standard.
This library:

  • Supports both YAML 1.1 and YAML 1.2 and all common data schemas,
  • Passes all of the yaml-test-suite tests,
  • Can accept any string as input without throwing, parsing as much YAML out of it as it can, and
  • Supports parsing, modifying, and writing YAML comments and blank lines.

The library is released under the ISC open source license, and the code is available on GitHub.
It has no external dependencies and runs on Node.js as well as modern browsers.

For the purposes of versioning, any changes that break any of the documented endpoints or APIs will be considered semver-major breaking changes.
Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).

For more information, see the project's documentation site: eemeli.org/yaml

To install:

npm install yaml

Note: These docs are for yaml@2. For v1, see the v1.10.0 tag for the source and eemeli.org/yaml/v1 for the documentation.

API Overview

The API provided by yaml has three layers, depending on how deep you need to go: Parse & Stringify, Documents, and the underlying Lexer/Parser/Composer.
The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent AST, and the third lets you get progressively closer to YAML source, if that's your thing.

import { parse, stringify } from 'yaml'
// or
import YAML from 'yaml'
// or
const YAML = require('yaml')

Parse & Stringify

Documents

Content Nodes

Parsing YAML

YAML.parse

# file.yml
YAML:
  - A human-readable data serialization language
  - https://en.wikipedia.org/wiki/YAML
yaml:
  - A complete JavaScript implementation
  - https://www.npmjs.com/package/yaml
import fs from 'fs'
import YAML from 'yaml'

YAML.parse('3.14159')
// 3.14159

YAML.parse('[ true, false, maybe, null ]\n')
// [ true, false, 'maybe', null ]

const file = fs.readFileSync('./file.yml', 'utf8')
YAML.parse(file)
// { YAML:
//   [ 'A human-readable data serialization language',
//     'https://en.wikipedia.org/wiki/YAML' ],
//   yaml:
//   [ 'A complete JavaScript implementation',
//     'https://www.npmjs.com/package/yaml' ] }

YAML.stringify

import YAML from 'yaml'

YAML.stringify(3.14159)
// '3.14159\n'

YAML.stringify([true, false, 'maybe', null])
// `- true
// - false
// - maybe
// - null
// `

YAML.stringify({ number: 3, plain: 'string', block: 'two\nlines\n' })
// `number: 3
// plain: string
// block: |
//   two
//   lines
// `

Browser testing provided by:

stylelint-processor-styled-components

Author: Max Stoiber

Description: A stylelint processor for styled-components

Homepage: https://github.com/styled-components/stylelint-processor-styled-components#readme

Createdover 5 years ago
Last Updatedabout 2 years ago
LicenseMIT
Maintainers4
Releases30
Direct Dependencies@babel/parser, @babel/traverse, micromatch and postcss
Keywordsstylelint, processor, stylelint-processor, styled-components and lint
README

stylelint-processor-styled-components

Lint your styled components with stylelint!

Build Status
Coverage Status
Join the community on Spectrum
Greenkeeper

Video of project in use

Setup

You need:

(npm install --save-dev \
  stylelint \
  stylelint-processor-styled-components \
  stylelint-config-styled-components \
  stylelint-config-recommended)

Now use those in your .stylelintrc and run stylelint with your JavaScript files!

{
  "processors": ["stylelint-processor-styled-components"],
  "extends": [
    "stylelint-config-recommended",
    "stylelint-config-styled-components"
  ]
}

NOTE: The processor works with Flow- and TypeScript-typed files too! (we'll assume TypeScript usage if your files end in .ts or .tsx)

And it also has some options. Their default values are,

{
  "processors": [["stylelint-processor-styled-components", {
    "moduleName": "styled-components",
    "importName": "default",
    "strict": false,
    "ignoreFiles": [],
    "parserPlugins": [
      "jsx",
      ["decorators", { "decoratorsBeforeExport": true }],
      "classProperties",
      "exportExtensions",
      "functionBind",
      "functionSent"
    ]
  }]]
}
  • Combining with moduleName, importName and strict, you can tell the processor what kinds of tagged template literals to lint.
import styled, { css, keyframes } from 'styled-components';

// `importName` from `moduleName`, which means where `styled` comes from
styled(Component)``;
styled('div')``;
styled.div``;

// any other imports from `moduleName` (if `strict` is true, they will not be linted)
css``;
keyframes``;

// special extend calls, which have been deprecated in styled-components v4
Component.extend``;

  • ignoreFiles is passed to micromatch as the second parameter, which means one or more glob patterns for matching.

  • parserPlugins is used to make the processor's parser be able to parse new syntaxes. All available babel parser plugins and related options can be found in Babel's website.

Documentation

Further documentation for this processor lives on the styled-components website!

F.A.Q.

Why does it throw Unexpected token? Even thought the file didn't import styled-components.

You can custom babel plugins by option.parserPlugins now. An API example is our test. But if someone can implement #231, that will be much better.

If your project includes yarn.lock or package-lock.json, an alternative cause can be that babel related dependencies, i.e. @babel/parser and @babel/traverse, are outdated, especially when linting files with new TypeScript syntaxes. You can upgrade them by removing their entries in the lockfile and reinstall dependencies.

Why does it throw unexpected lint errors?

The processor can not always parse interpolations with right things. But you can use interpolation-tagging to help it. If you have ideas to make it more intelligent, feel free to send a PR or share your solution by an new issue.

What's more, if set syntax: css-in-js in stylelint@10, it can extract styles from styled-components without this processor. Even though there are still lots of differences with this processor, we hope this processor's abilities can be migrated to stylelint totally in the future.

I don't want specified tagged template literal to be parsed, i.e. css.

You can set option.strict. More examples are in #258.

License

Licensed under the MIT License, Copyright © 2017 Maximilian Stoiber. See LICENSE.md for more information!

Based on Mapbox' excellent stylelint-processor-markdown, thanks to @davidtheclark!

stylelint-config-styled-components

Author: ismay

Description: A shareable stylelint config for stylelint-processor-styled-components

Homepage: https://github.com/styled-components/stylelint-config-styled-components#readme

Createdover 4 years ago
Last Updatedover 4 years ago
LicenseMIT
Maintainers3
Releases1
Keywordsstylelint, stylelint-config and styled-components
README

stylelint-config-styled-components

The shareable stylelint config for stylelint-processor-styled-components

npm version
build status
greenkeeper badge

Why

When using stylelint-processor-styled-components
a couple of stylelint rules throw errors that you cannot prevent. Like
'no-empty-source' or
'no-missing-end-of-source-newline'.

This shareable config will automatically disable rules that cause unresolvable conflicts. Besides
those rules vendor prefixed properties
and values will throw an error since
styled-components automatically generates vendor prefixes for your css. Note that if you want to
change any of these rules you can always override them in your stylelint config.

Installation

npm install stylelint-config-styled-components --save-dev

Usage

After installing, add this config to your stylelint config like so:

{
  "extends": "stylelint-config-styled-components"
}

If you're extending multiple shareable configs, put this config as the last so it overrides the relevant rules in all previous configs:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-styled-components"
  ]
}

See also https://stylelint.io/user-guide/configuration for documentation on the various ways
stylelint can be configured.

License

MIT

stylelint-config-standard

Author: Stylelint

Description: Standard shareable config for Stylelint

Homepage: https://github.com/stylelint/stylelint-config-standard#readme

Createdover 6 years ago
Last Updated21 days ago
LicenseMIT
Maintainers3
Releases35
Direct Dependenciesstylelint-config-recommended
Keywordsstylelint, stylelint-config and standard
This README is too long to show.

stylelint

Author: stylelint

Description: A mighty, modern CSS linter.

Homepage: https://stylelint.io

Createdover 7 years ago
Last Updated2 days ago
LicenseMIT
Maintainers6
Releases182
Direct Dependenciesbalanced-match, colord, cosmiconfig, css-functions-list, debug, execall, fast-glob, fastest-levenshtein, file-entry-cache, get-stdin, global-modules, globby, globjoin, html-tags, ignore, import-lazy, imurmurhash, is-plain-object, known-css-properties, mathml-tag-names, meow, micromatch, normalize-path, normalize-selector, picocolors, postcss, postcss-media-query-parser, postcss-resolve-nested-selector, postcss-safe-parser, postcss-selector-parser, postcss-value-parser, resolve-from, specificity, string-width, strip-ansi, style-search, supports-hyperlinks, svg-tags, table, v8-compile-cache and write-file-atomic
Keywordscss-in-js, css, less, lint, linter, markdown, sass, scss, stylelint and sugarss
README

Stylelint

npm version
Build Status
npm downloads

A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.

Features

It's mighty as it:

  • has over 170 built-in rules for modern CSS syntax and features
  • supports plugins so you can create your own rules
  • automatically fixes problems where possible
  • is well tested with over 15000 unit tests
  • supports shareable configs that you can extend or create
  • is unopinionated so that you can customize it to your exact needs
  • complements pretty printers like Prettier
  • has a growing community and is used by Google, GitHub and WordPress

And can be extended to:

  • parse CSS-like syntaxes like SCSS, Sass, Less and SugarSS
  • extract embedded styles from HTML, Markdown and CSS-in-JS object & template literals

How it'll help you

It'll help you avoid errors, for example styles that are:

  • invalid, e.g. malformed hex colors and named grid areas
  • valid but with unintended consequences, e.g. duplicated selectors and overridden properties

And enforce conventions, for example:

  • what units, functions, at-rules etc are allowed
  • consistent patterns for selector names, at-rule names, custom properties etc
  • maximum specificity or maximum quantity of each selector type
  • your preferred notation for color functions, font weight etc

There are also rules for enforcing stylistic consistency, but we now recommend you use Stylelint alongside a pretty printer like Prettier. Linters and pretty printers are complementary tools that work together.

Example output

Example

Guides

Contributors

Stylelint is maintained by volunteers. Without the code contributions from all these fantastic people, Stylelint would not exist. Become a contributor.

Sponsors

Thank you to all our sponsors! Become a sponsor.

Backers

Thank you to all our backers! Become a backer.

Website hosting

Deploys by Netlify

License

The MIT License.

luxon

Author: Isaac Cambron

Description: Immutable date wrapper

Homepage: https://github.com/moment/luxon#readme

Createdalmost 5 years ago
Last Updated11 days ago
LicenseMIT
Maintainers1
Releases124
Keywordsdate and immutable
README

Luxon

MIT License Build Status NPM version Coverage Status PRs welcome

Luxon is a library for working with dates and times in JavaScript.

DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").toISO();

Upgrading to 2.0

Guide

Features

  • DateTime, Duration, and Interval types.
  • Immutable, chainable, unambiguous API.
  • Parsing and formatting for common and custom formats.
  • Native time zone and Intl support (no locale or tz files).

Download/install

Download/install instructions

Documentation

Development

See contributing.

Phasers to stun

jest-styled-components

Author: Michele Bertoli

Description: Jest utilities for Styled Components

Homepage: http://npmjs.com/package/jest-styled-components

Createdabout 5 years ago
Last Updated5 months ago
LicenseMIT
Maintainers4
Releases101
Direct Dependenciescss
This README is too long to show.

@artsy/auto-config

Author: Justin Bennett

Description: Artsy's shared auto release config

Homepage: https://github.com/artsy/auto-config#readme

Createdover 3 years ago
Last Updated20 days ago
LicenseMIT
Maintainers14
Releases25
README

auto-config

Artsy's shared auto release config

react-native-fast-image

Author: Dylan Vann

Description: 🚩 FastImage, performant React Native image component.

Homepage: https://github.com/DylanVann/react-native-fast-image#readme

Createdabout 5 years ago
Last Updated4 months ago
License(MIT AND Apache-2.0)
Maintainers1
Releases115
Keywordscache, cached, fastimage, image and priority
README

🚩 FastImage

Performant React Native image component.

Version
Downloads
Build Status
Code Coverage

Watch on GitHub
Star on GitHub
Tweet


FastImage example app.

React Native's Image component handles image caching like browsers
for the most part.
If the server is returning proper cache control
headers for images you'll generally get the sort of built in
caching behavior you'd have in a browser.
Even so many people have noticed:

  • Flickering.
  • Cache misses.
  • Low performance loading from cache.
  • Low performance in general.

FastImage is an Image replacement that solves these issues.
FastImage is a wrapper around
SDWebImage (iOS)
and
Glide (Android).

Features

  • Aggressively cache images.
  • Add authorization headers.
  • Prioritize images.
  • Preload images.
  • GIF support.
  • Border radius.

Usage

Note: You must be using React Native 0.60.0 or higher to use the most recent version of react-native-fast-image.

yarn add react-native-fast-image
cd ios && pod install
import FastImage from 'react-native-fast-image'

const YourImage = () => (
    <FastImage
        style={{ width: 200, height: 200 }}
        source={{
            uri: 'https://unsplash.it/400/400?image=1',
            headers: { Authorization: 'someAuthToken' },
            priority: FastImage.priority.normal,
        }}
        resizeMode={FastImage.resizeMode.contain}
    />
)

Are you using Glide already using an AppGlideModule?

Are you using Proguard?

If you use Proguard you will need to add these lines to android/app/proguard-rules.pro:

-keep public class com.dylanvann.fastimage.* {*;}
-keep public class com.dylanvann.fastimage.** {*;}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

Properties

source?: object

Source for the remote image to load.


source.uri?: string

Remote url to load the image from. e.g. 'https://facebook.github.io/react/img/logo_og.png'.


source.headers?: object

Headers to load the image with. e.g. { Authorization: 'someAuthToken' }.


source.priority?: enum

  • FastImage.priority.low - Low Priority.
  • FastImage.priority.normal (Default) - Normal Priority.
  • FastImage.priority.high - High Priority.

source.cache?: enum

  • FastImage.cacheControl.immutable - (Default) - Only updates if url changes.
  • FastImage.cacheControl.web - Use headers and follow normal caching procedures.
  • FastImage.cacheControl.cacheOnly - Only show images from cache, do not make any network requests.

resizeMode?: enum

  • FastImage.resizeMode.contain - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.cover (Default) - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • FastImage.resizeMode.stretch - Scale width and height independently, This may change the aspect ratio of the src.
  • FastImage.resizeMode.center - Do not scale the image, keep centered.

onLoadStart?: () => void

Called when the image starts to load.


onProgress?: (event) => void

Called when the image is loading.

e.g. onProgress={e => console.log(e.nativeEvent.loaded / e.nativeEvent.total)}


onLoad?: (event) => void

Called on a successful image fetch. Called with the width and height of the loaded image.

e.g. onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}


onError?: () => void

Called on an image fetching error.


onLoadEnd?: () => void

Called when the image finishes loading, whether it was successful or an error.


style

A React Native style. Supports using borderRadius.


fallback: boolean

If true will fallback to using Image.
In this case the image will still be styled and laid out the same way as FastImage.


tintColor?: number | string

If supplied, changes the color of all the non-transparent pixels to the given color.

Static Methods

FastImage.preload: (source[]) => void

Preload images to display later. e.g.

FastImage.preload([
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
    {
        uri: 'https://facebook.github.io/react/img/logo_og.png',
        headers: { Authorization: 'someAuthToken' },
    },
])

FastImage.clearMemoryCache: () => Promise<void>

Clear all images from memory cache.

FastImage.clearDiskCache: () => Promise<void>

Clear all images from disk cache.

Troubleshooting

If you have any problems using this library try the steps in troubleshooting and see if they fix it.

Development

Follow these instructions to get the example app running.

Supported React Native Versions

This project only aims to support the latest version of React Native.
This simplifies the development and the testing of the project.

If you require new features or bug fixes for older versions you can fork this project.

Credits

The idea for this modules came from
vovkasm's
react-native-web-image
package.
It also uses Glide and SDWebImage, but didn't have some features I needed (priority, headers).

Thanks to @mobinni for helping with the conceptualization

Licenses

  • FastImage - MIT © DylanVann
  • SDWebImage - MIT
  • Glide - BSD, part MIT and Apache 2.0. See the LICENSE file for details.

New dependencies added: react-native-fast-image, @artsy/auto-config, jest-styled-components, luxon, stylelint, stylelint-config-standard, stylelint-config-styled-components, stylelint-processor-styled-components, yaml and yaml-lint.

Hi there! 👋

We're trialing semantic commit formatting which has not been detected in your PR title.

Refer to this RFC and Conventional Commits for PR/commit formatting guidelines.

Generated by 🚫 dangerJS against e9c91f8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants