GithubHelp home page GithubHelp logo

svelte-repl's People

Contributors

andrelmlins avatar benmccann avatar conduitry avatar dependabot[bot] avatar emiltholin avatar joshnuss avatar remyoudemans avatar rich-harris avatar scottbedard avatar surajpoddar16 avatar tanhauhau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svelte-repl's Issues

Adding new component tab scrolls view unnecessarily

In the home page for Svelte documentation website, I noticed that whenever you open a new tab in a REPL example the view scrolls so that it shows the element with the ID that was added in the bottom of the view.

This happens because of this line in ComponentSelector.svelte:

document.getElementById(component.name).scrollIntoView(false);

I just don't understand why we have to scrollIntoView (and using IDs) if the component was added right to the side of the + button which was clicked? The user will have the new tab right there so I don't see the point in performing that scroll. This causes weird behavior both when you have only one REPL component loaded in the page (if it is not near the top of the page) and when you have multiple components which add elements with the same ID to the DOM and the scroll happens considering the wrong element.

Maybe there is some user case I'm missing in which it would be worth to have that scroll? Please let me know. Otherwise, I'm willing to work on a PR to remove that behavior or even do it differently.

2019-05-05 23 51 29

Repl Error - Unexpected token (Note that you need plugins to import files that are not JavaScript)

Hi,

I recently published a package svelte-speedometer, which seem to work fine when I download the repl code locally and with svelte storybook but not in hosted Svelte Repl.

EDIT: The component is bootstrapped with official svelte component template - https://github.com/sveltejs/component-template

Repl Link where issue can be seen - https://svelte.dev/repl/cf869c9ab9f9431195222ba6cea10b59?version=3.20.1

I cloned the svelte-repl locally where things seem to be working fine. Link - https://github.com/palerdot/svelte-repl-issue-repro

The actual cloned zip file can be seen here in the repo - https://github.com/palerdot/svelte-repl-issue-repro/blob/master/svelte-app.zip

Source code - https://github.com/palerdot/svelte-speedometer

Storybook link where things seem to work - https://palerdot.in/svelte-speedometer

Any help on this is appreciated, as it seems there is already this codesandbox issue because of which codesandbox cannot be used to host svelte code. With Svelte REPL not working, it is difficult to share svelte snippets for this package.

Please let me know if any other information is needed from my end.

Feature request: autoclose tags

I think it would make the REPL significantly more encouraging to use if html tags which are not self-closing were automatically closed when finish writing an opening tag.

I would be happy to implement this but I'm struggling to get the REPL running locally.

feature request: result force reload

I seem to get into bugs in my own code that crashes result with error messages like Cannot access uninitialized variable., and runtime errors like Error loading namey-mcnameface from bundle.run.

Debugging my own errors is hard, as error message gives no indication which variable that is uninitialized. Additionally, result-pane does not seem to recover from runtime errors like "bundle.run unavailable".

Would be great to be able to "force reload" of result-pane, so that I can set a breakpoint and step through the code. This is somewhat doable today, by saving and then reloading the browser, but would be nice to have a button "reload result".

Status update messages not specific to REPL instance

The status update messages sent from the worker don't correctly target particular instances of the REPL. At least, that's what I'm assuming is happening. This is visible on the homepage https://svelte.dev/ where we have four REPL widgets. Editing one causes the rebundling messages to appear on others - even though they're definitely not getting rebundled, because they don't lose their state.

Update in-browser bundling to use newer Rollup version

To suppose newer language features in the compiled code (like ?? and ?.) we need to update the version of Rollup used for the in-browser bundling. This might be as easy as just upgrading the version we're using, but there might have been some relevant breaking changes from v1 -> v2 in terms of how we're programmatically calling it in the browser.

Solve the halting problem

it's really annoying when you're in the middle of typing a for loop...

for (let i = 0; i < things.length; <cursor>)

...and the code starts running before you have a chance to write i += 1. Similarly if you're trying to write this...

while (true) {
  // some code...
  if (someConditionIsMet()) break;
}

...you will get as far as while (true) {, it will add the closing }, and you're screwed.

Maybe not the easiest thing to fix, and certainly not in a general way, but I wonder if there's something that can be done to handle common cases. Like, idk, not running the code if the cursor is currently inside a loop?

Too many errors hides code window

I set up an example with a lot of unused CSS selectors. This spawned a lot of errors in the info div, covering up the editor completely so I couldn't correct the errors.

Help wanted, how can I implement this REPL into my own code?

Can anyone help me getting this Repl component to work? I have tried to install Sapper and then install this Repl component into that, but that makes the server crash as soon as I import it. I have tried it with just Svelte but then it says that I need plugins to import files that are not JavaScript. (codemirror.css)

What I really want is to make this REPL the base in a new client side component editor in a PHP platform we use. So we can use it to build Svelte components that is compiled into pure JS that is inserted into our PHP pages.

Node resolution in REPL files

Being able to import from ./foo and have this resolve to foo.js in the REPL might be nice, and more in line with how this stuff is going to work when actually bundling.

Document the dev environment setup

I wanted to give #43 a go, but I can't figure out how to setup the dev environment.

I cloned both this and the svelte repo. Installed dependencies in the site folder, ran the needed commands there, and npm linked the repl repo into the site repo. After that I get compile errors when building the website though, so I'm probably missing something.

✗ client
../../svelte-repl/src/SplitPane.svelte (21:1)
'transition_in' is not exported by ../../svelte-repl/node_modules/svelte/internal.mjs
19:     const { top, bottom, left, right } = refs.container.getBoundingClientRect();
20: 
21:     const extents = type === 'vertical' ? [top, bottom] : [left, right];
      ^
22: 
23:     const px = yootils.clamp(
✗ server
../../svelte-repl/src/SplitPane.svelte (3:1)
'add_attribute' is not exported by ../../svelte-repl/node_modules/svelte/internal.mjs
1: <script>
2:   import * as yootils from 'yootils';
3:   import { createEventDispatcher } from 'svelte';
     ^
4: 
5:   const dispatch = createEventDispatcher();

Any pointers?

console.log

would it be possible to have a logging panel for debugging purposes ?

Warn when closing unsaved state

It already happened a few times to me, that I by accident closed a tab with unsaved "dabblings" I had in the repl. It would be nice if it would ask if it should close without saving.

Fun with svelte/foo resolution

The current version of the REPL resolves svelte/foo to unpkg.com/svelte/foo.mjs. This will break if a new version of Svelte is released in its current form, because svelte/foo ought to resolve to svelte/foo/index.mjs.

The new version also includes svelte/foo/package.json which should theoretically make unpkg.com/svelte/foo?module resolve directly to unpkg.com/svelte/foo/index.mjs via unpkg. But this doesn't work in the existing versions of Svelte, because unpkg.com/foo?module will just give us the CJS version.

The most obvious solution is ugly: inspect the version number, and if it's less than or equal to 3.4.4, go with the old logic unpkg.com/svelte/foo.mjs, and if it's greater, go with unpkg.com/svelte/foo?module.

Also potentially an issue: https://unpkg.com/[email protected]/index.mjs?module right now contains an ESM module (as expected, since unpkg respects package.json), but the import is from ./internal?module. I don't know whether this is going to be a problem. This would happen with all of the requests and responses if we went forward with the changes outlined here.

Suggestion: use 'npx' and add 'svelte', rollup plugins etc to package.json

In the downloads, making the scripts in package.json use npx:

"scripts": {
    "build": "npx rollup -c",
    "autobuild": "npx rollup -c -w",

And including all the relevant rollup plugins in package.json would make using the zip files easier. This way npm i would install all the required packages locally and let people get started faster.

What about auth?

About auth

Hi. I was logged to https://svelte.dev/repl & change some code, save it. But I can't find list of my saved codes.

Question

Can I save code for open in future sessions?

What I do wrong?

Press F5 & get failed to fetch

Screenshot_2019-04-23_19-29-54

  • 🐧 Is it possible to do REPL (online tool), like codepen & etc ?..

Unable to import from packages beginning with "@"

Trying to import from a package whose name begins with "@" results in an error:

Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)

For example:

<script>
	import {MDCCheckbox} from '@material/checkbox';
</script>

Will throw that error.

Wrong array contents displayed in REPL Console pane

Steps to reproduce

  1. Open repl https://svelte.dev/repl/b3be31da940b4d50b6216283fd04cacc?version=3.16.7
  2. Resize Console pane so that log contents are visible.
  3. In the result view check the provided checkbox.

Expected results
When value under checkbox (bound value) changed, the new contents of the array displayed in the Console Pane due to $: console.log call

Actual results
The array contents are logged, however the contents are wrong (when value is true, value logged is false)

v3 Svelte components loaded from npm fail to initialize properly in the REPL.

I published svelte-image-encoder to npm: https://www.npmjs.com/package/svelte-image-encoder

When I try to update the v3 REPL to use the npm package instead of the file in the Gist, it gives me a runtime error for a bind:this={element} directive inside onMount(), element being undefined when it runs. However the demo builds and runs well with a local Sapper/Rollup setup when using the npm installed package.

I think it might have to do with index.js or index.mjs being built differently.

For a quick reproduction replace import ImgEncoder from './ImgEncoder.svelte'; with import ImgEncoder from 'svelte-image-encoder'; in App.js in this demo.

Suggested so far on Discord:

Conduitry: My initial thought is to try to build the pkg.svelte resolution rules into the REPL. I don't know how much trouble that would be
rich_harris: maybe not terrible. would just mean we'd have to get https://unpkg.com/[package-name]/package.json and inspect it before fetching from bundle.run

Scroll issue on REPL when having too many errors

The bug

If you dump a bunch of nonexistent vars in the repl, the info pane might grow as high as your editor, meaning you can't edit your code anymore because the info alerts are in the way.

Steps to reproduce

Copy paste the following text into App.svelte in the repl:

{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}
{name2}
{name1}

This occurs "in real life" when you are refactoring things and moving things from file to file.

To fix

Easy CSS fix: .info { max-height: 40vh; overflow: scroll; }

I wanted to PR this but, see #44 .

vars

The default README.md contains strange UTF8 replacement characters

When using the "download" feature of the REPL on svelte.dev (https://svelte.dev/repl/), it downloads a file called svelte-app.zip. At the root of the ZIP, there is a file called README.md. This file contains a sequence of bytes that is invalid in UTF8 :

$ hexdump -C README.md 
00000000  2a 50 73 73 74 20 14 a0  6c 6f 6f 6b 69 6e 67 20  |*Psst ..looking |
00000010  66 6f 72 20 61 20 73 68  61 72 65 61 62 6c 65 20  |for a shareable |

(just after Psst , there is a 0x14 0xa0 byte sequence which is invalid)

download specific pages

I want to download the source directly.

I see that there's a ".json" version of each URL with all the files. Is it OK to use this (i.e. will it stay like this? )

Alert if repl hasn't been saved

This is a feature request

I have a habit of closing tabs or windows by mistake and losing work, and others probably do too. It would be awesome if when the user closes the tab or leaves the page, that an alert is shown warning that the repl has not been saved. Perhaps a message like

Warning: this repl has not been saved and leaving will lose the most recent changes since last saving

If the user closes the message, immediately presses save, then leaves the page without making any other changes. Then this message won't be shown.

Happy to write the code and make a PR if this feature sounds like a good idea?

Reserved tab name "App" causes issues

  1. Create a new tab.
  2. Try to name it "Append".
  3. Note how after typing "App", the input field loses focus and the new tab is no longer deleteable nor renameable.

I assume this is due to the name state updating with each input event. Possible solutions would include only updating the name on blur or not identifying the "main" tab by its name (but instead, for example, by its index).

How does rollup import codemirror.css?

I'm trying to get the REPL working as a component using Rollup. I'm able to use webpack by moving everything into a component/REPL folder inside a Svelte app PR #114, but when I do the same thing using Rollup, I get an error stating [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) src\components\REPL\codemirror.css (3:0).

Looking at codemirror.js, it seems like codemirror.css is being imported there, but Rollup isn't allowing the import of css. I've tried using rollup-plugin-css-only in my rollup.config.js, but then I get another error stating [!] Error: UMD and IIFE output formats are not supported for code-splitting builds.

Then I changed the output.format to esm and I get this error. [!] Error: When building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option..

Three errors, and I'm out.

I figure there's something I'm missing in my config file that will allow me to use everything in the svelte-repl/src file similar to svelte/site/src/components/Repl, but I need some help figuring out exactly what that is.

Multiple tabs share undo buffer

There seems to be one common undo/redo buffer shared between all tabs of the REPL. To make matters worse, switching between tabs is something that the editor apparently sees as an update to the text in it - so if you switch from tab A to tab B and then press ctrl-z/cmd-z/whatever, you will end up with the contents of tab A in tab B.

Error on importing packages with @

Hi there!

When trying to import @smui/select I get the following error:

Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)

Example (using the demo code from https://www.npmjs.com/package/@smui/select):

<script>
  import Select, {Option} from '@smui/select';
 
  let fruits = ['Apple', 'Orange', 'Banana', 'Mango'];
  let fruitChoice = '';
</script> 
 
<Select bind:value={fruitChoice} label="Fruit">
  <Option value=""></Option>
  {#each fruits as fruit}
    <Option value={fruit} selected={fruitChoice === fruit}>{fruit}</Option>
  {/each}
</Select>

This seems related with #46

// cc @hperrin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.