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

feat: support javascript snippet files #219

Merged
merged 16 commits into from
Oct 30, 2023

Commits on Oct 21, 2023

  1. Configuration menu
    Copy the full SHA
    44e2689 View commit details
    Browse the repository at this point in the history
  2. feat(snippets): support javascript snippet files

    parsing snippets now first involves attempting to import it as a javascript
    module, with the default export expected to be the snippets.
    this enables improved snippet config writing, and could supercede the need for
    the "variables" setting of the plugin.
    
    if importing fails, falls back to existing behavior of parsing as json5 string.
    
    security risk: dynamically imported user-provided files may execute malicious
    code; users should be validate snippet files others share.
    duanwilliam committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    6a2546f View commit details
    Browse the repository at this point in the history
  3. feat(snippets): support regexp literal triggers in js; support regexp…

    … flags
    
    in js snippets files, support passing in regexp literals as the trigger.
    also, generally support regexp flags for regexp snippets (i.e. regexp literals,
    or snippets with the `r` option).
    only the following flags are allowed: `i`, `m`, `s`, `u`, `v`.
    when a snippet with a regexp literal trigger also has flags defined,
    the flags get merged together.
    duanwilliam committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    76991c4 View commit details
    Browse the repository at this point in the history
  4. docs: add documentation on snippet file format, flags field

    describe snippet file formats (js, json5); add documentation on added `flags`
    field; note validity of regex triggers in js snippet files.
    duanwilliam committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    b17a507 View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2023

  1. fix(snippets): mark ParsedSnippet flags as always defined

    previously, flags were marked as optional field.
    however, flags are always defined as a string, even if an empty one.
    duanwilliam committed Oct 22, 2023
    Configuration menu
    Copy the full SHA
    22b76c7 View commit details
    Browse the repository at this point in the history
  2. refactor(snippets): improve snippet validation

    add stricter validation checks, and improve validation check type signature
    duanwilliam committed Oct 22, 2023
    Configuration menu
    Copy the full SHA
    b489c16 View commit details
    Browse the repository at this point in the history
  3. refactor(snippets): always treat snippets file as js

    removes the dependency on json5.
    if the snippets file isn't a js module with a default export,
    it now gets treated as a js array via an `export default ` prepended to it,
    as opposed to a json5 array.
    json5 is valid js so it should hopefully not break anything
    duanwilliam committed Oct 22, 2023
    Configuration menu
    Copy the full SHA
    0b7703a View commit details
    Browse the repository at this point in the history
  4. docs: update snippets file format description; add security warning

    update docs to not mention json5 since it's no longer used.
    
    add a warning on readme underneath snippet sharing,
    to warn about the dangers of running arbitrary javascript code.
    duanwilliam committed Oct 22, 2023
    Configuration menu
    Copy the full SHA
    fa604a8 View commit details
    Browse the repository at this point in the history
  5. fix(snippets): properly handle regex literal flags

    typo in code was using unmodified raw options string,
    so regex literal triggers did not result in `Option.regex` being marked.
    duanwilliam committed Oct 22, 2023
    Configuration menu
    Copy the full SHA
    49e4418 View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. feat: use var(--text-accent) for regex in snippet editor

    previously was a hardcoded color that was not very readable on dark bg
    duanwilliam committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    a3d24d5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d1172ad View commit details
    Browse the repository at this point in the history
  3. refactor: clean up ParsedSnippet constructor

    remove redundant uses of raw snippet, make state of values more explicit.
    duanwilliam committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    54cb71e View commit details
    Browse the repository at this point in the history
  4. chore: make RawSnippet class an interface

    `RawSnippet` is never actually instantiated, and serves more so as an interface
    representing the expected shape of a parsed snippet. as such an interface is
    more appropriate than a `class` for it.
    duanwilliam committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    ab27c13 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f35dfd8 View commit details
    Browse the repository at this point in the history
  6. style: rename variable

    in `ParsedSnippet` constructor, variable was named `override` because it
    overrode certain fields of `raw` in construction of final parsed snippet.
    however, `parsed` no longer uses both `raw` and `override`, and so as such
    `override` more so represents the _resolved_ fields.
    duanwilliam committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    b65d6bf View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    57c011d View commit details
    Browse the repository at this point in the history