init
This commit is contained in:
commit
d3a286c2d9
62
.eslintrc.json
Normal file
62
.eslintrc.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2019,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true
|
||||
},
|
||||
"plugins": [
|
||||
"svelte3"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"**/*.svelte"
|
||||
],
|
||||
"processor": "svelte3/svelte3"
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"arrow-spacing": "error",
|
||||
"block-scoped-var": "error",
|
||||
"block-spacing": "error",
|
||||
"brace-style": ["error", "stroustrup", {}],
|
||||
"camelcase": "error",
|
||||
"comma-dangle": ["error", "never"],
|
||||
"comma-spacing": ["error", { "before": false, "after": true }],
|
||||
"comma-style": [1, "last"],
|
||||
"consistent-this": [1, "_this"],
|
||||
"curly": [1, "multi"],
|
||||
"eol-last": 1,
|
||||
"eqeqeq": 1,
|
||||
"func-names": 1,
|
||||
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||
"lines-around-comment": ["error", { "beforeBlockComment": true, "allowArrayStart": true }],
|
||||
"max-len": [1, 240, 2], // 2 spaces per tab, max 80 chars per line
|
||||
"new-cap": 1,
|
||||
"newline-before-return": "error",
|
||||
"no-array-constructor": 1,
|
||||
"no-inner-declarations": [1, "both"],
|
||||
"no-mixed-spaces-and-tabs": 1,
|
||||
"no-multi-spaces": 2,
|
||||
"no-new-object": 1,
|
||||
"no-shadow-restricted-names": 1,
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"padded-blocks": ["error", { "blocks": "never", "switches": "always" }],
|
||||
"prefer-const": "error",
|
||||
"prefer-template": "error",
|
||||
"one-var": 0,
|
||||
"quote-props": ["error", "always"],
|
||||
"quotes": [1, "single"],
|
||||
"radix": 1,
|
||||
"semi": [1, "always"],
|
||||
"space-before-blocks": [1, "always"],
|
||||
"space-infix-ops": 1,
|
||||
"vars-on-top": 1,
|
||||
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
|
||||
"spaced-comment": ["error", "always", { "markers": ["/"] }]
|
||||
}
|
||||
|
||||
}
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/node_modules/
|
||||
# /public/build/
|
||||
|
||||
.DS_Store
|
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
6
.idea/jsLibraryMappings.xml
Normal file
6
.idea/jsLibraryMappings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<includedPredefinedLibrary name="Node.js Core" />
|
||||
</component>
|
||||
</project>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/svelte_nurl.iml" filepath="$PROJECT_DIR$/.idea/svelte_nurl.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
.idea/svelte_nurl.iml
Normal file
12
.idea/svelte_nurl.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
106
README.md
Normal file
106
README.md
Normal file
@ -0,0 +1,106 @@
|
||||
*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
|
||||
|
||||
---
|
||||
|
||||
# Updates
|
||||
|
||||
## 2020-04-17
|
||||
|
||||
Added [svelte-preprocess](https://www.npmjs.com/package/svelte-preprocess) preprocessor with support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript and Pug.
|
||||
|
||||
Added [rollup-plugin-node-builtins](https://www.npmjs.com/package/rollup-plugin-node-builtins) Allows the node builtins to be required/imported. Doing so gives the proper shims to support modules that were designed for Browserify, some modules require rollup-plugin-node-globals.
|
||||
|
||||
Added [rollup-plugin-node-globals](https://www.npmjs.com/package/rollup-plugin-node-globals) Plugin to insert node globals including so code that works with browserify should work even if it uses process or buffers.
|
||||
|
||||
|
||||
---
|
||||
|
||||
# svelte app
|
||||
|
||||
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
|
||||
|
||||
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
|
||||
|
||||
```bash
|
||||
npx degit sveltejs/template svelte-app
|
||||
cd svelte-app
|
||||
```
|
||||
|
||||
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
|
||||
|
||||
|
||||
## Get started
|
||||
|
||||
Install the dependencies...
|
||||
|
||||
```bash
|
||||
cd svelte-app
|
||||
npm install
|
||||
```
|
||||
|
||||
...then start [Rollup](https://rollupjs.org):
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
|
||||
|
||||
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
|
||||
|
||||
|
||||
## Building and running in production mode
|
||||
|
||||
To create an optimised version of the app:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
|
||||
|
||||
|
||||
## Single-page app mode
|
||||
|
||||
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
|
||||
|
||||
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
|
||||
|
||||
```js
|
||||
"start": "sirv public --single"
|
||||
```
|
||||
|
||||
|
||||
## Deploying to the web
|
||||
|
||||
### With [now](https://zeit.co/now)
|
||||
|
||||
Install `now` if you haven't already:
|
||||
|
||||
```bash
|
||||
npm install -g now
|
||||
```
|
||||
|
||||
Then, from within your project folder:
|
||||
|
||||
```bash
|
||||
cd public
|
||||
now deploy --name my-project
|
||||
```
|
||||
|
||||
As an alternative, use the [Now desktop client](https://zeit.co/download) and simply drag the unzipped project folder to the taskbar icon.
|
||||
|
||||
### With [surge](https://surge.sh/)
|
||||
|
||||
Install `surge` if you haven't already:
|
||||
|
||||
```bash
|
||||
npm install -g surge
|
||||
```
|
||||
|
||||
Then, from within your project folder:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
surge public my-project.surge.sh
|
||||
```
|
4
copy.sh
Executable file
4
copy.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# rm -rf /home/martin/dev/menuserver/dist/*
|
||||
cp -r /home/martin/dev/svelte_nurl/public/* /home/martin/dev/nurl/public/v2
|
4196
package-lock.json
generated
Normal file
4196
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
package.json
Normal file
33
package.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "svelte-app",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"dev": "rollup -c -w",
|
||||
"start": "sirv public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.0.0",
|
||||
"@rollup/plugin-node-resolve": "^7.0.0",
|
||||
"@rollup/plugin-strip": "^1.3.2",
|
||||
"autoprefixer": "^9.7.6",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-svelte3": "^2.7.3",
|
||||
"node-sass": "^4.13.1",
|
||||
"rollup": "^2.6.1",
|
||||
"rollup-plugin-livereload": "^1.0.0",
|
||||
"rollup-plugin-node-builtins": "^2.1.2",
|
||||
"rollup-plugin-node-globals": "^1.4.0",
|
||||
"rollup-plugin-svelte": "^5.0.3",
|
||||
"rollup-plugin-terser": "^5.1.2",
|
||||
"svelte": "^3.0.0",
|
||||
"svelte-preprocess": "^3.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"muicss": "^0.10.1",
|
||||
"redaxios": "^0.2.0",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"sirv-cli": "^0.4.4"
|
||||
}
|
||||
}
|
3
public/build/bundle.css
Normal file
3
public/build/bundle.css
Normal file
File diff suppressed because one or more lines are too long
12
public/build/bundle.css.map
Normal file
12
public/build/bundle.css.map
Normal file
File diff suppressed because one or more lines are too long
617
public/build/bundle.js
Normal file
617
public/build/bundle.js
Normal file
@ -0,0 +1,617 @@
|
||||
|
||||
(function(l, r) { if (l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (window.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(window.document);
|
||||
var app = (function () {
|
||||
'use strict';
|
||||
|
||||
function noop() { }
|
||||
function add_location(element, file, line, column, char) {
|
||||
element.__svelte_meta = {
|
||||
loc: { file, line, column, char }
|
||||
};
|
||||
}
|
||||
function run(fn) {
|
||||
return fn();
|
||||
}
|
||||
function blank_object() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function run_all(fns) {
|
||||
fns.forEach(run);
|
||||
}
|
||||
function is_function(thing) {
|
||||
return typeof thing === 'function';
|
||||
}
|
||||
function safe_not_equal(a, b) {
|
||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
|
||||
function append(target, node) {
|
||||
target.appendChild(node);
|
||||
}
|
||||
function insert(target, node, anchor) {
|
||||
target.insertBefore(node, anchor || null);
|
||||
}
|
||||
function detach(node) {
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
function element(name) {
|
||||
return document.createElement(name);
|
||||
}
|
||||
function text(data) {
|
||||
return document.createTextNode(data);
|
||||
}
|
||||
function space() {
|
||||
return text(' ');
|
||||
}
|
||||
function listen(node, event, handler, options) {
|
||||
node.addEventListener(event, handler, options);
|
||||
return () => node.removeEventListener(event, handler, options);
|
||||
}
|
||||
function attr(node, attribute, value) {
|
||||
if (value == null)
|
||||
node.removeAttribute(attribute);
|
||||
else if (node.getAttribute(attribute) !== value)
|
||||
node.setAttribute(attribute, value);
|
||||
}
|
||||
function children(element) {
|
||||
return Array.from(element.childNodes);
|
||||
}
|
||||
function set_input_value(input, value) {
|
||||
if (value != null || input.value) {
|
||||
input.value = value;
|
||||
}
|
||||
}
|
||||
function custom_event(type, detail) {
|
||||
const e = document.createEvent('CustomEvent');
|
||||
e.initCustomEvent(type, false, false, detail);
|
||||
return e;
|
||||
}
|
||||
|
||||
let current_component;
|
||||
function set_current_component(component) {
|
||||
current_component = component;
|
||||
}
|
||||
|
||||
const dirty_components = [];
|
||||
const binding_callbacks = [];
|
||||
const render_callbacks = [];
|
||||
const flush_callbacks = [];
|
||||
const resolved_promise = Promise.resolve();
|
||||
let update_scheduled = false;
|
||||
function schedule_update() {
|
||||
if (!update_scheduled) {
|
||||
update_scheduled = true;
|
||||
resolved_promise.then(flush);
|
||||
}
|
||||
}
|
||||
function add_render_callback(fn) {
|
||||
render_callbacks.push(fn);
|
||||
}
|
||||
let flushing = false;
|
||||
const seen_callbacks = new Set();
|
||||
function flush() {
|
||||
if (flushing)
|
||||
return;
|
||||
flushing = true;
|
||||
do {
|
||||
// first, call beforeUpdate functions
|
||||
// and update components
|
||||
for (let i = 0; i < dirty_components.length; i += 1) {
|
||||
const component = dirty_components[i];
|
||||
set_current_component(component);
|
||||
update(component.$$);
|
||||
}
|
||||
dirty_components.length = 0;
|
||||
while (binding_callbacks.length)
|
||||
binding_callbacks.pop()();
|
||||
// then, once components are updated, call
|
||||
// afterUpdate functions. This may cause
|
||||
// subsequent updates...
|
||||
for (let i = 0; i < render_callbacks.length; i += 1) {
|
||||
const callback = render_callbacks[i];
|
||||
if (!seen_callbacks.has(callback)) {
|
||||
// ...so guard against infinite loops
|
||||
seen_callbacks.add(callback);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
render_callbacks.length = 0;
|
||||
} while (dirty_components.length);
|
||||
while (flush_callbacks.length) {
|
||||
flush_callbacks.pop()();
|
||||
}
|
||||
update_scheduled = false;
|
||||
flushing = false;
|
||||
seen_callbacks.clear();
|
||||
}
|
||||
function update($$) {
|
||||
if ($$.fragment !== null) {
|
||||
$$.update();
|
||||
run_all($$.before_update);
|
||||
const dirty = $$.dirty;
|
||||
$$.dirty = [-1];
|
||||
$$.fragment && $$.fragment.p($$.ctx, dirty);
|
||||
$$.after_update.forEach(add_render_callback);
|
||||
}
|
||||
}
|
||||
const outroing = new Set();
|
||||
function transition_in(block, local) {
|
||||
if (block && block.i) {
|
||||
outroing.delete(block);
|
||||
block.i(local);
|
||||
}
|
||||
}
|
||||
|
||||
const globals = (typeof window !== 'undefined' ? window : global);
|
||||
function mount_component(component, target, anchor) {
|
||||
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
||||
fragment && fragment.m(target, anchor);
|
||||
// onMount happens before the initial afterUpdate
|
||||
add_render_callback(() => {
|
||||
const new_on_destroy = on_mount.map(run).filter(is_function);
|
||||
if (on_destroy) {
|
||||
on_destroy.push(...new_on_destroy);
|
||||
}
|
||||
else {
|
||||
// Edge case - component was destroyed immediately,
|
||||
// most likely as a result of a binding initialising
|
||||
run_all(new_on_destroy);
|
||||
}
|
||||
component.$$.on_mount = [];
|
||||
});
|
||||
after_update.forEach(add_render_callback);
|
||||
}
|
||||
function destroy_component(component, detaching) {
|
||||
const $$ = component.$$;
|
||||
if ($$.fragment !== null) {
|
||||
run_all($$.on_destroy);
|
||||
$$.fragment && $$.fragment.d(detaching);
|
||||
// TODO null out other refs, including component.$$ (but need to
|
||||
// preserve final state?)
|
||||
$$.on_destroy = $$.fragment = null;
|
||||
$$.ctx = [];
|
||||
}
|
||||
}
|
||||
function make_dirty(component, i) {
|
||||
if (component.$$.dirty[0] === -1) {
|
||||
dirty_components.push(component);
|
||||
schedule_update();
|
||||
component.$$.dirty.fill(0);
|
||||
}
|
||||
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
|
||||
}
|
||||
function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
|
||||
const parent_component = current_component;
|
||||
set_current_component(component);
|
||||
const prop_values = options.props || {};
|
||||
const $$ = component.$$ = {
|
||||
fragment: null,
|
||||
ctx: null,
|
||||
// state
|
||||
props,
|
||||
update: noop,
|
||||
not_equal,
|
||||
bound: blank_object(),
|
||||
// lifecycle
|
||||
on_mount: [],
|
||||
on_destroy: [],
|
||||
before_update: [],
|
||||
after_update: [],
|
||||
context: new Map(parent_component ? parent_component.$$.context : []),
|
||||
// everything else
|
||||
callbacks: blank_object(),
|
||||
dirty
|
||||
};
|
||||
let ready = false;
|
||||
$$.ctx = instance
|
||||
? instance(component, prop_values, (i, ret, ...rest) => {
|
||||
const value = rest.length ? rest[0] : ret;
|
||||
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
|
||||
if ($$.bound[i])
|
||||
$$.bound[i](value);
|
||||
if (ready)
|
||||
make_dirty(component, i);
|
||||
}
|
||||
return ret;
|
||||
})
|
||||
: [];
|
||||
$$.update();
|
||||
ready = true;
|
||||
run_all($$.before_update);
|
||||
// `false` as a special case of no DOM component
|
||||
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
|
||||
if (options.target) {
|
||||
if (options.hydrate) {
|
||||
const nodes = children(options.target);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
$$.fragment && $$.fragment.l(nodes);
|
||||
nodes.forEach(detach);
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
$$.fragment && $$.fragment.c();
|
||||
}
|
||||
if (options.intro)
|
||||
transition_in(component.$$.fragment);
|
||||
mount_component(component, options.target, options.anchor);
|
||||
flush();
|
||||
}
|
||||
set_current_component(parent_component);
|
||||
}
|
||||
class SvelteComponent {
|
||||
$destroy() {
|
||||
destroy_component(this, 1);
|
||||
this.$destroy = noop;
|
||||
}
|
||||
$on(type, callback) {
|
||||
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
||||
callbacks.push(callback);
|
||||
return () => {
|
||||
const index = callbacks.indexOf(callback);
|
||||
if (index !== -1)
|
||||
callbacks.splice(index, 1);
|
||||
};
|
||||
}
|
||||
$set() {
|
||||
// overridden by instance, if it has props
|
||||
}
|
||||
}
|
||||
|
||||
function dispatch_dev(type, detail) {
|
||||
document.dispatchEvent(custom_event(type, Object.assign({ version: '3.20.1' }, detail)));
|
||||
}
|
||||
function append_dev(target, node) {
|
||||
dispatch_dev("SvelteDOMInsert", { target, node });
|
||||
append(target, node);
|
||||
}
|
||||
function insert_dev(target, node, anchor) {
|
||||
dispatch_dev("SvelteDOMInsert", { target, node, anchor });
|
||||
insert(target, node, anchor);
|
||||
}
|
||||
function detach_dev(node) {
|
||||
dispatch_dev("SvelteDOMRemove", { node });
|
||||
detach(node);
|
||||
}
|
||||
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
|
||||
const modifiers = options === true ? ["capture"] : options ? Array.from(Object.keys(options)) : [];
|
||||
if (has_prevent_default)
|
||||
modifiers.push('preventDefault');
|
||||
if (has_stop_propagation)
|
||||
modifiers.push('stopPropagation');
|
||||
dispatch_dev("SvelteDOMAddEventListener", { node, event, handler, modifiers });
|
||||
const dispose = listen(node, event, handler, options);
|
||||
return () => {
|
||||
dispatch_dev("SvelteDOMRemoveEventListener", { node, event, handler, modifiers });
|
||||
dispose();
|
||||
};
|
||||
}
|
||||
function attr_dev(node, attribute, value) {
|
||||
attr(node, attribute, value);
|
||||
if (value == null)
|
||||
dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute });
|
||||
else
|
||||
dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value });
|
||||
}
|
||||
function prop_dev(node, property, value) {
|
||||
node[property] = value;
|
||||
dispatch_dev("SvelteDOMSetProperty", { node, property, value });
|
||||
}
|
||||
function set_data_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.data === data)
|
||||
return;
|
||||
dispatch_dev("SvelteDOMSetData", { node: text, data });
|
||||
text.data = data;
|
||||
}
|
||||
function validate_slots(name, slot, keys) {
|
||||
for (const slot_key of Object.keys(slot)) {
|
||||
if (!~keys.indexOf(slot_key)) {
|
||||
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
|
||||
}
|
||||
}
|
||||
}
|
||||
class SvelteComponentDev extends SvelteComponent {
|
||||
constructor(options) {
|
||||
if (!options || (!options.target && !options.$$inline)) {
|
||||
throw new Error(`'target' is a required option`);
|
||||
}
|
||||
super();
|
||||
}
|
||||
$destroy() {
|
||||
super.$destroy();
|
||||
this.$destroy = () => {
|
||||
console.warn(`Component was already destroyed`); // eslint-disable-line no-console
|
||||
};
|
||||
}
|
||||
$capture_state() { }
|
||||
$inject_state() { }
|
||||
}
|
||||
|
||||
var axios = (function e(t){function r(e){return function(t,r){return a(t,Object.assign({method:e},r))}}function o(e){return function(t,r,o){return a(t,Object.assign({method:e,data:r},o))}}function n(e,t,r){if(Array.isArray(e))return e.concat(t);if(t&&"object"==typeof t){var o,a={};if(e)for(o in e)a[r?o.toLowerCase():o]=e[o];for(o in t){var i=r?o.toLowerCase():o;"headers"===i&&(r=!0),a[i]=o in a?n(a[i],t[o],r):t[o];}return a}return t}function a(e,r){"string"!=typeof e&&(e=(r=e).url);var o=n(t,r||{}),a=o.data;if(o.transformRequest)for(var i=0;i<o.transformRequest.length;i++){var s=o.transformRequest[i](a,o.headers);void 0!==s&&(a=s);}var u={};if(a&&"object"==typeof a&&(a=JSON.stringify(a),u["Content-Type"]="application/json"),o.xsrfCookieName)for(var f=document.cookie.split(/ *[;=] */),c=0;c<f.length;c+=2)if(f[c]==o.xsrfCookieName){u[o.xsrfHeaderName]=decodeURIComponent(f[c+1]);break}o.auth&&(u.Authorization=o.auth);var p={};return p.config=r,fetch(e,{method:o.method,body:a,headers:n(o.headers,u,!0)}).then(function(e){var t;for(t in e)"function"!=typeof e[t]&&(p[t]=e[t]);return (o.validateStatus?o.validateStatus(e.status):e.ok)?("stream"===o.responseType?Promise.resolve(e.body):e[o.responseType||"text"]()).then(function(e){return p.data=e,p}):Promise.reject(e)})}return t=t||{},a.request=a,a.get=r("get"),a.delete=r("delete"),a.options=r("options"),a.post=o("post"),a.put=o("put"),a.patch=o("patch"),a.all=Promise.all,a.spread=function(e){return function(t){return e.apply(this,t)}},a.CancelToken=self.AbortController||Object,a.create=e,a}());
|
||||
|
||||
/* src/App.svelte generated by Svelte v3.20.1 */
|
||||
|
||||
const { console: console_1 } = globals;
|
||||
const file = "src/App.svelte";
|
||||
|
||||
// (48:12) {#if link.length>0}
|
||||
function create_if_block(ctx) {
|
||||
let div1;
|
||||
let div0;
|
||||
let a;
|
||||
let t;
|
||||
|
||||
const block = {
|
||||
c: function create() {
|
||||
div1 = element("div");
|
||||
div0 = element("div");
|
||||
a = element("a");
|
||||
t = text(/*link*/ ctx[0]);
|
||||
attr_dev(a, "class", "result");
|
||||
attr_dev(a, "href", /*link*/ ctx[0]);
|
||||
add_location(a, file, 50, 24, 1655);
|
||||
attr_dev(div0, "class", "mui-col-lg-12");
|
||||
attr_dev(div0, "id", "link");
|
||||
add_location(div0, file, 49, 20, 1593);
|
||||
attr_dev(div1, "class", "mui-row");
|
||||
add_location(div1, file, 48, 16, 1551);
|
||||
},
|
||||
m: function mount(target, anchor) {
|
||||
insert_dev(target, div1, anchor);
|
||||
append_dev(div1, div0);
|
||||
append_dev(div0, a);
|
||||
append_dev(a, t);
|
||||
},
|
||||
p: function update(ctx, dirty) {
|
||||
if (dirty & /*link*/ 1) set_data_dev(t, /*link*/ ctx[0]);
|
||||
|
||||
if (dirty & /*link*/ 1) {
|
||||
attr_dev(a, "href", /*link*/ ctx[0]);
|
||||
}
|
||||
},
|
||||
d: function destroy(detaching) {
|
||||
if (detaching) detach_dev(div1);
|
||||
}
|
||||
};
|
||||
|
||||
dispatch_dev("SvelteRegisterBlock", {
|
||||
block,
|
||||
id: create_if_block.name,
|
||||
type: "if",
|
||||
source: "(48:12) {#if link.length>0}",
|
||||
ctx
|
||||
});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
function create_fragment(ctx) {
|
||||
let main;
|
||||
let div4;
|
||||
let div0;
|
||||
let t1;
|
||||
let div1;
|
||||
let t3;
|
||||
let div3;
|
||||
let div2;
|
||||
let input;
|
||||
let t4;
|
||||
let button;
|
||||
let t5;
|
||||
let button_disabled_value;
|
||||
let t6;
|
||||
let dispose;
|
||||
let if_block = /*link*/ ctx[0].length > 0 && create_if_block(ctx);
|
||||
|
||||
const block = {
|
||||
c: function create() {
|
||||
main = element("main");
|
||||
div4 = element("div");
|
||||
div0 = element("div");
|
||||
div0.textContent = "nURL";
|
||||
t1 = space();
|
||||
div1 = element("div");
|
||||
div1.textContent = "nurl.co";
|
||||
t3 = space();
|
||||
div3 = element("div");
|
||||
div2 = element("div");
|
||||
input = element("input");
|
||||
t4 = space();
|
||||
button = element("button");
|
||||
t5 = text("SHORTEN");
|
||||
t6 = space();
|
||||
if (if_block) if_block.c();
|
||||
attr_dev(div0, "class", "mui--text-display3");
|
||||
add_location(div0, file, 38, 8, 1008);
|
||||
attr_dev(div1, "class", "mui--text-subhead");
|
||||
add_location(div1, file, 39, 8, 1059);
|
||||
attr_dev(input, "id", "url-field");
|
||||
attr_dev(input, "placeholder", "Paste a link...");
|
||||
attr_dev(input, "type", "url");
|
||||
add_location(input, file, 42, 16, 1192);
|
||||
attr_dev(div2, "class", "mui-textfield");
|
||||
add_location(div2, file, 41, 12, 1148);
|
||||
attr_dev(button, "class", "mui-btn mui-btn--raised mui-btn--accent btn-shorten");
|
||||
attr_dev(button, "id", "btn-shorten");
|
||||
attr_dev(button, "type", "button");
|
||||
button.disabled = button_disabled_value = !/*canSubmit*/ ctx[2];
|
||||
add_location(button, file, 44, 12, 1309);
|
||||
attr_dev(div3, "class", "mui-panel");
|
||||
add_location(div3, file, 40, 8, 1112);
|
||||
attr_dev(div4, "class", "mui-container-fluid");
|
||||
add_location(div4, file, 37, 4, 966);
|
||||
add_location(main, file, 36, 0, 955);
|
||||
},
|
||||
l: function claim(nodes) {
|
||||
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
|
||||
},
|
||||
m: function mount(target, anchor, remount) {
|
||||
insert_dev(target, main, anchor);
|
||||
append_dev(main, div4);
|
||||
append_dev(div4, div0);
|
||||
append_dev(div4, t1);
|
||||
append_dev(div4, div1);
|
||||
append_dev(div4, t3);
|
||||
append_dev(div4, div3);
|
||||
append_dev(div3, div2);
|
||||
append_dev(div2, input);
|
||||
set_input_value(input, /*urlField*/ ctx[1]);
|
||||
append_dev(div3, t4);
|
||||
append_dev(div3, button);
|
||||
append_dev(button, t5);
|
||||
append_dev(div3, t6);
|
||||
if (if_block) if_block.m(div3, null);
|
||||
if (remount) run_all(dispose);
|
||||
|
||||
dispose = [
|
||||
listen_dev(input, "input", /*input_input_handler*/ ctx[6]),
|
||||
listen_dev(button, "click", /*shortenLink*/ ctx[3], false, false, false)
|
||||
];
|
||||
},
|
||||
p: function update(ctx, [dirty]) {
|
||||
if (dirty & /*urlField*/ 2) {
|
||||
set_input_value(input, /*urlField*/ ctx[1]);
|
||||
}
|
||||
|
||||
if (dirty & /*canSubmit*/ 4 && button_disabled_value !== (button_disabled_value = !/*canSubmit*/ ctx[2])) {
|
||||
prop_dev(button, "disabled", button_disabled_value);
|
||||
}
|
||||
|
||||
if (/*link*/ ctx[0].length > 0) {
|
||||
if (if_block) {
|
||||
if_block.p(ctx, dirty);
|
||||
} else {
|
||||
if_block = create_if_block(ctx);
|
||||
if_block.c();
|
||||
if_block.m(div3, null);
|
||||
}
|
||||
} else if (if_block) {
|
||||
if_block.d(1);
|
||||
if_block = null;
|
||||
}
|
||||
},
|
||||
i: noop,
|
||||
o: noop,
|
||||
d: function destroy(detaching) {
|
||||
if (detaching) detach_dev(main);
|
||||
if (if_block) if_block.d();
|
||||
run_all(dispose);
|
||||
}
|
||||
};
|
||||
|
||||
dispatch_dev("SvelteRegisterBlock", {
|
||||
block,
|
||||
id: create_fragment.name,
|
||||
type: "component",
|
||||
source: "",
|
||||
ctx
|
||||
});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
function instance($$self, $$props, $$invalidate) {
|
||||
let validateRegEx = /([a-z]{1,2}tps?):\/\/((?:(?!(?:\/|#|\?|&)).)+)(?:(\/(?:(?:(?:(?!(?:#|\?|&)).)+\/))?))?(?:((?:(?!(?:\.|$|\?|#)).)+))?(?:(\.(?:(?!(?:\?|$|#)).)+))?(?:(\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/i;
|
||||
let link = "";
|
||||
|
||||
async function doShortenLink(payload) {
|
||||
await axios.post("/api/v1/shorten", payload).then(response => {
|
||||
if (response.status === 200) {
|
||||
console.log(">> shortUrl", response.data.shortUrl);
|
||||
$$invalidate(0, link = response.data.shortUrl);
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
async function shortenLink() {
|
||||
console.log("Shorten...");
|
||||
const payload = { url: urlField };
|
||||
await doShortenLink(payload);
|
||||
}
|
||||
|
||||
const writable_props = [];
|
||||
|
||||
Object.keys($$props).forEach(key => {
|
||||
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console_1.warn(`<App> was created with unknown prop '${key}'`);
|
||||
});
|
||||
|
||||
let { $$slots = {}, $$scope } = $$props;
|
||||
validate_slots("App", $$slots, []);
|
||||
|
||||
function input_input_handler() {
|
||||
urlField = this.value;
|
||||
$$invalidate(1, urlField);
|
||||
}
|
||||
|
||||
$$self.$capture_state = () => ({
|
||||
axios,
|
||||
validateRegEx,
|
||||
link,
|
||||
doShortenLink,
|
||||
shortenLink,
|
||||
urlField,
|
||||
canSubmit
|
||||
});
|
||||
|
||||
$$self.$inject_state = $$props => {
|
||||
if ("validateRegEx" in $$props) $$invalidate(4, validateRegEx = $$props.validateRegEx);
|
||||
if ("link" in $$props) $$invalidate(0, link = $$props.link);
|
||||
if ("urlField" in $$props) $$invalidate(1, urlField = $$props.urlField);
|
||||
if ("canSubmit" in $$props) $$invalidate(2, canSubmit = $$props.canSubmit);
|
||||
};
|
||||
|
||||
let urlField;
|
||||
let canSubmit;
|
||||
|
||||
if ($$props && "$$inject" in $$props) {
|
||||
$$self.$inject_state($$props.$$inject);
|
||||
}
|
||||
|
||||
$$self.$$.update = () => {
|
||||
if ($$self.$$.dirty & /*urlField*/ 2) {
|
||||
$$invalidate(1, urlField = urlField.trim());
|
||||
}
|
||||
|
||||
if ($$self.$$.dirty & /*urlField*/ 2) {
|
||||
$$invalidate(2, canSubmit = validateRegEx.test(urlField));
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
link,
|
||||
urlField,
|
||||
canSubmit,
|
||||
shortenLink,
|
||||
validateRegEx,
|
||||
doShortenLink,
|
||||
input_input_handler
|
||||
];
|
||||
}
|
||||
|
||||
class App extends SvelteComponentDev {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
init(this, options, instance, create_fragment, safe_not_equal, {});
|
||||
|
||||
dispatch_dev("SvelteRegisterComponent", {
|
||||
component: this,
|
||||
tagName: "App",
|
||||
options,
|
||||
id: create_fragment.name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const app = new App({
|
||||
'target': document.body,
|
||||
'props': {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return app;
|
||||
|
||||
}());
|
||||
//# sourceMappingURL=bundle.js.map
|
1
public/build/bundle.js.map
Normal file
1
public/build/bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
17
public/index.html
Normal file
17
public/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
|
||||
<title>nUrl</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||
<link rel='stylesheet' href='/build/bundle.css'>
|
||||
|
||||
<script defer src='/build/bundle.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
95
rollup.config.js
Normal file
95
rollup.config.js
Normal file
@ -0,0 +1,95 @@
|
||||
import svelte from 'rollup-plugin-svelte';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import livereload from 'rollup-plugin-livereload';
|
||||
import replace from 'rollup-plugin-replace';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import sveltePreprocess from 'svelte-preprocess';
|
||||
import builtins from 'rollup-plugin-node-builtins';
|
||||
import globals from 'rollup-plugin-node-globals';
|
||||
import strip from '@rollup/plugin-strip';
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH;
|
||||
|
||||
const preprocess = sveltePreprocess({
|
||||
'scss': {
|
||||
'includePaths': ['src']
|
||||
},
|
||||
'postcss': {
|
||||
'plugins': [require('autoprefixer')]
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
'input': 'src/main.js',
|
||||
'output': {
|
||||
'sourcemap': (!production),
|
||||
'format': 'iife',
|
||||
'name': 'app',
|
||||
'file': 'public/build/bundle.js'
|
||||
},
|
||||
'plugins': [
|
||||
// globals(),
|
||||
// builtins(),
|
||||
strip({
|
||||
'debugger': !(production)
|
||||
}),
|
||||
svelte({
|
||||
// enable run-time checks when not in production
|
||||
'dev': !production,
|
||||
preprocess,
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
'css': css => {
|
||||
css.write('public/build/bundle.css');
|
||||
}
|
||||
}),
|
||||
|
||||
// If you have external dependencies installed from
|
||||
// npm, you'll most likely need these plugins. In
|
||||
// some cases you'll need additional configuration -
|
||||
// consult the documentation for details:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||
resolve({
|
||||
'browser': true,
|
||||
'dedupe': ['svelte']
|
||||
}),
|
||||
commonjs(),
|
||||
replace({
|
||||
'exclude': 'node_modules/**',
|
||||
'ENV': JSON.stringify(production ? 'production' : 'development')
|
||||
}),
|
||||
|
||||
// In dev mode, call `npm run start` once
|
||||
// the bundle has been generated
|
||||
!production && serve(),
|
||||
|
||||
// Watch the `public` directory and refresh the
|
||||
// browser on changes when not in production
|
||||
!production && livereload('public'),
|
||||
|
||||
// If we're building for production (npm run build
|
||||
// instead of npm run dev), minify
|
||||
production && terser()
|
||||
],
|
||||
'watch': {
|
||||
'clearScreen': false
|
||||
}
|
||||
};
|
||||
|
||||
function serve() {
|
||||
let started = false;
|
||||
|
||||
return {
|
||||
writeBundle() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
|
||||
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||
'stdio': ['ignore', 'inherit', 'inherit'],
|
||||
'shell': true
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
64
src/App.svelte
Normal file
64
src/App.svelte
Normal file
@ -0,0 +1,64 @@
|
||||
<script>
|
||||
import axios from 'redaxios';
|
||||
|
||||
let validateRegEx = /([a-z]{1,2}tps?):\/\/((?:(?!(?:\/|#|\?|&)).)+)(?:(\/(?:(?:(?:(?!(?:#|\?|&)).)+\/))?))?(?:((?:(?!(?:\.|$|\?|#)).)+))?(?:(\.(?:(?!(?:\?|$|#)).)+))?(?:(\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/i;
|
||||
let link = '';
|
||||
|
||||
$: urlField = urlField.trim();
|
||||
$: canSubmit = validateRegEx.test(urlField);
|
||||
|
||||
|
||||
async function doShortenLink(payload) {
|
||||
await axios.post('/api/v1/shorten', payload).then((response) => {
|
||||
if (response.status === 200) {
|
||||
console.log('>> shortUrl', response.data.shortUrl);
|
||||
link = response.data.shortUrl;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
async function shortenLink() {
|
||||
console.log('Shorten...');
|
||||
|
||||
const payload = {
|
||||
url: urlField
|
||||
};
|
||||
|
||||
await doShortenLink(payload);
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<div class="mui-container-fluid">
|
||||
<div class="mui--text-display3">nURL</div>
|
||||
<div class="mui--text-subhead">nurl.co</div>
|
||||
<div class="mui-panel">
|
||||
<div class="mui-textfield">
|
||||
<input id="url-field" bind:value={urlField} placeholder="Paste a link..." type="url">
|
||||
</div>
|
||||
<button class="mui-btn mui-btn--raised mui-btn--accent btn-shorten" id="btn-shorten" type="button" disabled={!canSubmit}
|
||||
on:click={shortenLink}>SHORTEN
|
||||
</button>
|
||||
{#if link.length>0}
|
||||
<div class="mui-row">
|
||||
<div class="mui-col-lg-12" id="link">
|
||||
<a class="result" href={link}>{link}</a>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Made with svelte -->
|
||||
|
||||
|
||||
<style lang="scss" global>
|
||||
@import "./css/custom.scss";
|
||||
</style>
|
114
src/css/custom.scss
Normal file
114
src/css/custom.scss
Normal file
@ -0,0 +1,114 @@
|
||||
// Import fonts
|
||||
@import "//fonts.googleapis.com/css2?family=Roboto+Condensed&family=Roboto+Slab&display=swap";
|
||||
|
||||
// import MUI colors
|
||||
@import "./node_modules/muicss/lib/sass/mui/colors";
|
||||
|
||||
// import MUI SASS
|
||||
@import "./node_modules/muicss/lib/sass/mui";
|
||||
|
||||
.btn:focus, .btn-shorten:focus{
|
||||
outline: 0 !important;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
background-color: #FFC107;
|
||||
}
|
||||
|
||||
body, main {
|
||||
color: #4A148C;
|
||||
text-align: center;
|
||||
font-family: 'Roboto Slab', sans-serif;
|
||||
}
|
||||
|
||||
.btn-shorten {
|
||||
color: #ffffff;
|
||||
// background-color: #F89406;
|
||||
border: none;
|
||||
font-family: 'Roboto Condensed', sans-serif;
|
||||
}
|
||||
|
||||
.btn-shorten:hover,
|
||||
.btn-shorten:focus,
|
||||
.btn-shorten:active,
|
||||
.btn-shorten.active {
|
||||
color: #ffffff;
|
||||
background-color: #FA8900;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.site-wrapper {
|
||||
display: table;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.site-wrapper-inner {
|
||||
display: table-cell;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.main-container {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
.inner {
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.inner h4 {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
.glyphicon-link {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.inner h1 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
#link {
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
#link a{
|
||||
color: #FF4081;
|
||||
font-size: 1.5em;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.main-container {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.main-container {
|
||||
width: 700px;
|
||||
}
|
||||
}
|
||||
|
||||
body, html{
|
||||
font-family: "Roboto", "Arial", sans-serif;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
h1{
|
||||
font-family: "Roboto Slab", monospace;
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
h2, h3, h4{
|
||||
font-family: "Ubuntu", sans-serif;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
10
src/main.js
Normal file
10
src/main.js
Normal file
@ -0,0 +1,10 @@
|
||||
import App from './App.svelte';
|
||||
|
||||
const app = new App({
|
||||
'target': document.body,
|
||||
'props': {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
export default app;
|
Loading…
Reference in New Issue
Block a user