Skip to content

Commit

Permalink
Merge pull request #40 from jerch/fix_bundling
Browse files Browse the repository at this point in the history
expose .svelte files in bundle
  • Loading branch information
ngyewch authored Mar 17, 2024
2 parents 570f71c + 5944055 commit d2a3f89
Show file tree
Hide file tree
Showing 43 changed files with 1,223 additions and 2,595 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
/build/

.DS_Store

.svelte-kit
package-lock.json

64 changes: 64 additions & 0 deletions dist/components/Circle.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script>import { createEventDispatcher, getContext, onDestroy, setContext } from "svelte";
import {
Circle,
Layer,
Map
} from "leaflet";
import EventBridge from "../lib/EventBridge.js";
const dispatch = createEventDispatcher();
const mapProvider = getContext(Map);
export let latLng;
export let radius = 10;
export let color = "#3388ff";
export let weight = 3;
export let opacity = 1;
export let lineCap = "round";
export let lineJoin = "round";
export let dashArray = void 0;
export let dashOffset = void 0;
export let fill = true;
export let fillColor = "#3388ff";
export let fillOpacity = 0.2;
export let fillRule = "evenodd";
export let options = {
radius: void 0
};
export let events = [];
let circle;
let eventBridge;
setContext(Layer, () => circle);
$: {
if (!circle) {
circle = new Circle(latLng, { ...options, ...{ radius } }).addTo(mapProvider());
eventBridge = new EventBridge(circle, dispatch, events);
}
circle.setLatLng(latLng);
circle.setRadius(radius);
circle.setStyle({
color,
weight,
opacity,
lineCap,
lineJoin,
dashArray,
dashOffset,
fill,
fillColor,
fillOpacity,
fillRule
});
}
onDestroy(() => {
eventBridge.unregister();
circle.removeFrom(mapProvider());
});
export function getCircle() {
return circle;
}
</script>

<div>
{#if circle}
<slot/>
{/if}
</div>
35 changes: 35 additions & 0 deletions dist/components/Circle.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SvelteComponent } from "svelte";
import { Circle, type CircleOptions, type FillRule, type LatLngExpression, type LineCapShape, type LineJoinShape } from 'leaflet';
declare const __propDef: {
props: {
latLng: LatLngExpression;
radius?: number | undefined;
color?: string | undefined;
weight?: number | undefined;
opacity?: number | undefined;
lineCap?: LineCapShape | undefined;
lineJoin?: LineJoinShape | undefined;
dashArray?: string | number[] | undefined;
dashOffset?: string | undefined;
fill?: boolean | undefined;
fillColor?: string | undefined;
fillOpacity?: number | undefined;
fillRule?: FillRule | undefined;
options?: CircleOptions | undefined;
events?: string[] | undefined;
getCircle?: (() => Circle | undefined) | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {};
};
};
export type CircleProps = typeof __propDef.props;
export type CircleEvents = typeof __propDef.events;
export type CircleSlots = typeof __propDef.slots;
export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
get getCircle(): () => Circle<any> | undefined;
}
export {};
62 changes: 62 additions & 0 deletions dist/components/CircleMarker.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script>import { createEventDispatcher, getContext, onDestroy, setContext } from "svelte";
import {
CircleMarker,
Layer,
Map
} from "leaflet";
import EventBridge from "../lib/EventBridge.js";
const dispatch = createEventDispatcher();
const mapProvider = getContext(Map);
export let latLng;
export let radius = 10;
export let color = "#3388ff";
export let weight = 3;
export let opacity = 1;
export let lineCap = "round";
export let lineJoin = "round";
export let dashArray = void 0;
export let dashOffset = void 0;
export let fill = true;
export let fillColor = "#3388ff";
export let fillOpacity = 0.2;
export let fillRule = "evenodd";
export let options = {};
export let events = [];
let circleMarker;
let eventBridge;
setContext(Layer, () => circleMarker);
$: {
if (!circleMarker) {
circleMarker = new CircleMarker(latLng, options).addTo(mapProvider());
eventBridge = new EventBridge(circleMarker, dispatch, events);
}
circleMarker.setLatLng(latLng);
circleMarker.setRadius(radius);
circleMarker.setStyle({
color,
weight,
opacity,
lineCap,
lineJoin,
dashArray,
dashOffset,
fill,
fillColor,
fillOpacity,
fillRule
});
}
onDestroy(() => {
eventBridge.unregister();
circleMarker.removeFrom(mapProvider());
});
export function getCircleMarker() {
return circleMarker;
}
</script>

<div>
{#if circleMarker}
<slot/>
{/if}
</div>
35 changes: 35 additions & 0 deletions dist/components/CircleMarker.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SvelteComponent } from "svelte";
import { CircleMarker, type CircleMarkerOptions, type FillRule, type LatLngExpression, type LineCapShape, type LineJoinShape } from 'leaflet';
declare const __propDef: {
props: {
latLng: LatLngExpression;
radius?: number | undefined;
color?: string | undefined;
weight?: number | undefined;
opacity?: number | undefined;
lineCap?: LineCapShape | undefined;
lineJoin?: LineJoinShape | undefined;
dashArray?: string | number[] | undefined;
dashOffset?: string | undefined;
fill?: boolean | undefined;
fillColor?: string | undefined;
fillOpacity?: number | undefined;
fillRule?: FillRule | undefined;
options?: CircleMarkerOptions | undefined;
events?: string[] | undefined;
getCircleMarker?: (() => CircleMarker | undefined) | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {};
};
};
export type CircleMarkerProps = typeof __propDef.props;
export type CircleMarkerEvents = typeof __propDef.events;
export type CircleMarkerSlots = typeof __propDef.slots;
export default class CircleMarker extends SvelteComponent<CircleMarkerProps, CircleMarkerEvents, CircleMarkerSlots> {
get getCircleMarker(): () => CircleMarker<any> | undefined;
}
export {};
22 changes: 22 additions & 0 deletions dist/components/DivIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script>import { getContext } from "svelte";
import { DivIcon, Marker } from "leaflet";
const markerProvider = getContext(Marker);
export let options = {};
let icon;
let element;
$: {
let adjustedOptions = options;
if (!adjustedOptions.html) {
adjustedOptions.html = element;
}
icon = new DivIcon(adjustedOptions);
markerProvider().setIcon(icon);
}
export function getDivIcon() {
return icon;
}
</script>

<div bind:this={element}>
<slot></slot>
</div>
21 changes: 21 additions & 0 deletions dist/components/DivIcon.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SvelteComponent } from "svelte";
import { DivIcon, type DivIconOptions } from 'leaflet';
declare const __propDef: {
props: {
options?: DivIconOptions | undefined;
getDivIcon?: (() => DivIcon | undefined) | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {};
};
};
export type DivIconProps = typeof __propDef.props;
export type DivIconEvents = typeof __propDef.events;
export type DivIconSlots = typeof __propDef.slots;
export default class DivIcon extends SvelteComponent<DivIconProps, DivIconEvents, DivIconSlots> {
get getDivIcon(): () => DivIcon | undefined;
}
export {};
34 changes: 34 additions & 0 deletions dist/components/GeoJSON.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script>import { createEventDispatcher, getContext, onDestroy, setContext } from "svelte";
import { GeoJSON, Layer, Map } from "leaflet";
import EventBridge from "../lib/EventBridge.js";
const dispatch = createEventDispatcher();
const mapProvider = getContext(Map);
export let data = void 0;
export let options = {};
export let events = [];
let geojson;
let eventBridge;
setContext(Layer, () => geojson);
$: {
if (!geojson) {
geojson = new GeoJSON(data, options).addTo(mapProvider());
eventBridge = new EventBridge(geojson, dispatch, events);
} else if (data) {
geojson.clearLayers();
geojson.addData(data);
}
}
onDestroy(() => {
eventBridge.unregister();
geojson.removeFrom(mapProvider());
});
export function getGeoJSON() {
return geojson;
}
</script>

<div>
{#if geojson}
<slot/>
{/if}
</div>
24 changes: 24 additions & 0 deletions dist/components/GeoJSON.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { SvelteComponent } from "svelte";
import { GeoJSON, type GeoJSONOptions } from 'leaflet';
import type { GeoJsonObject } from 'geojson';
declare const __propDef: {
props: {
data?: GeoJsonObject | undefined;
options?: GeoJSONOptions<any, import("geojson").Geometry> | undefined;
events?: string[] | undefined;
getGeoJSON?: (() => GeoJSON | undefined) | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {};
};
};
export type GeoJsonProps = typeof __propDef.props;
export type GeoJsonEvents = typeof __propDef.events;
export type GeoJsonSlots = typeof __propDef.slots;
export default class GeoJson extends SvelteComponent<GeoJsonProps, GeoJsonEvents, GeoJsonSlots> {
get getGeoJSON(): () => GeoJSON<any, import("geojson").Geometry> | undefined;
}
export {};
20 changes: 20 additions & 0 deletions dist/components/Icon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script>import { getContext } from "svelte";
import { Icon, Marker } from "leaflet";
const markerProvider = getContext(Marker);
export let iconUrl;
export let options = {};
let icon;
$: {
if (!icon) {
const adjustedOptions = {
...options,
iconUrl
};
icon = new Icon(adjustedOptions);
markerProvider().setIcon(icon);
}
}
export function getIcon() {
return icon;
}
</script>
20 changes: 20 additions & 0 deletions dist/components/Icon.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SvelteComponent } from "svelte";
import { Icon, type BaseIconOptions, type IconOptions } from 'leaflet';
declare const __propDef: {
props: {
iconUrl: string;
options?: BaseIconOptions | undefined;
getIcon?: (() => Icon | undefined) | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {};
};
export type IconProps = typeof __propDef.props;
export type IconEvents = typeof __propDef.events;
export type IconSlots = typeof __propDef.slots;
export default class Icon extends SvelteComponent<IconProps, IconEvents, IconSlots> {
get getIcon(): () => Icon<IconOptions> | undefined;
}
export {};
30 changes: 30 additions & 0 deletions dist/components/ImageOverlay.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script>import { createEventDispatcher, getContext, onDestroy } from "svelte";
import { ImageOverlay, Map } from "leaflet";
import EventBridge from "../lib/EventBridge.js";
const dispatch = createEventDispatcher();
const mapProvider = getContext(Map);
export let imageUrl;
export let bounds;
export let opacity = 1;
export let zIndex = 1;
export let options = {};
export let events = [];
let imageOverlay;
let eventBridge;
$: {
if (!imageOverlay) {
imageOverlay = new ImageOverlay(imageUrl, bounds, options).addTo(mapProvider());
eventBridge = new EventBridge(imageOverlay, dispatch, events);
}
imageOverlay.setUrl(imageUrl);
imageOverlay.setOpacity(opacity);
imageOverlay.setZIndex(zIndex);
}
onDestroy(() => {
eventBridge.unregister();
imageOverlay.removeFrom(mapProvider());
});
export function getImageOverlay() {
return imageOverlay;
}
</script>
Loading

0 comments on commit d2a3f89

Please sign in to comment.