@story-map/story-map-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yu-Zhi Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ import type { StoryLocation, StoryMedia, StorySlide } from './types.js';
2
+ export declare function parseWikiLinkRef(value: string): string;
3
+ export declare function coerceLocation(value: unknown, zoom?: unknown): StoryLocation | undefined;
4
+ export declare function coerceMedia(value: unknown): StoryMedia | undefined;
5
+ export declare function mergeResolvedSlide(base: StorySlide, resolved: Partial<StorySlide>): StorySlide;
6
+ export declare function validCoordinates(lat: number, lng: number): boolean;
7
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAStD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAkCxF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAkBlE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAY9F;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAElE"}
@@ -0,0 +1,78 @@
1
+ export function parseWikiLinkRef(value) {
2
+ let ref = value.trim();
3
+ if (ref.startsWith('!'))
4
+ ref = ref.slice(1).trim();
5
+ if (ref.startsWith('[[') && ref.endsWith(']]')) {
6
+ ref = ref.slice(2, -2);
7
+ }
8
+ ref = ref.split('|', 1)[0] ?? ref;
9
+ ref = ref.split('#', 1)[0] ?? ref;
10
+ return ref.trim();
11
+ }
12
+ export function coerceLocation(value, zoom) {
13
+ const parsedZoom = typeof zoom === 'number' && Number.isFinite(zoom) ? zoom : undefined;
14
+ if (Array.isArray(value) && value.length >= 2) {
15
+ const lat = Number(value[0]);
16
+ const lng = Number(value[1]);
17
+ if (validCoordinates(lat, lng)) {
18
+ return { lat, lng, ...(parsedZoom === undefined ? {} : { zoom: parsedZoom }) };
19
+ }
20
+ }
21
+ if (typeof value === 'string') {
22
+ const parts = value.split(',').map((part) => Number(part.trim()));
23
+ if (parts.length >= 2 && validCoordinates(parts[0], parts[1])) {
24
+ return {
25
+ lat: parts[0],
26
+ lng: parts[1],
27
+ ...(parsedZoom === undefined ? {} : { zoom: parsedZoom }),
28
+ };
29
+ }
30
+ }
31
+ if (value && typeof value === 'object') {
32
+ const record = value;
33
+ const lat = Number(record.lat ?? record.latitude);
34
+ const lng = Number(record.lng ?? record.long ?? record.longitude);
35
+ const objectZoom = Number(record.zoom);
36
+ if (validCoordinates(lat, lng)) {
37
+ const finalZoom = Number.isFinite(objectZoom) ? objectZoom : parsedZoom;
38
+ return { lat, lng, ...(finalZoom === undefined ? {} : { zoom: finalZoom }) };
39
+ }
40
+ }
41
+ return undefined;
42
+ }
43
+ export function coerceMedia(value) {
44
+ if (typeof value === 'string' && value.trim()) {
45
+ return { type: 'image', src: value.trim() };
46
+ }
47
+ if (value && typeof value === 'object') {
48
+ const record = value;
49
+ if (typeof record.src !== 'string' || !record.src.trim())
50
+ return undefined;
51
+ const type = record.type === 'video' || record.type === 'iframe' ? record.type : 'image';
52
+ return {
53
+ type,
54
+ src: record.src,
55
+ ...(typeof record.alt === 'string' ? { alt: record.alt } : {}),
56
+ ...(typeof record.caption === 'string' ? { caption: record.caption } : {}),
57
+ };
58
+ }
59
+ return undefined;
60
+ }
61
+ export function mergeResolvedSlide(base, resolved) {
62
+ const merged = { ...resolved, ...base };
63
+ const location = base.location ?? resolved.location;
64
+ const media = base.media ?? resolved.media;
65
+ if (location)
66
+ merged.location = location;
67
+ else
68
+ delete merged.location;
69
+ if (media)
70
+ merged.media = media;
71
+ else
72
+ delete merged.media;
73
+ return merged;
74
+ }
75
+ export function validCoordinates(lat, lng) {
76
+ return Number.isFinite(lat) && Number.isFinite(lng) && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;
77
+ }
78
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,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GAAG,IAAI,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC;IAE3C,IAAI,QAAQ;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;;QACpC,OAAO,MAAM,CAAC,QAAQ,CAAC;IAE5B,IAAI,KAAK;QAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,GAAW;IACvD,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;AAC9G,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './types.js';
2
+ export * from './schema.js';
3
+ export * from './helpers.js';
4
+ export * from './parser.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './types.js';
2
+ export * from './schema.js';
3
+ export * from './helpers.js';
4
+ export * from './parser.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { StoryMapConfig } from './types.js';
2
+ export declare class StoryMapParseError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ export declare function normalizeStoryMapInput(value: unknown): unknown;
6
+ export declare function parseStoryMapObject(value: unknown): StoryMapConfig;
7
+ export declare function parseStoryMapYaml(source: string): StoryMapConfig;
8
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AA0BD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA+B9D;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAElE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAEhE"}
package/dist/parser.js ADDED
@@ -0,0 +1,64 @@
1
+ import { load } from 'js-yaml';
2
+ import { storyMapSchema } from './schema.js';
3
+ import { coerceLocation, coerceMedia, validCoordinates } from './helpers.js';
4
+ export class StoryMapParseError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'StoryMapParseError';
8
+ }
9
+ }
10
+ function asRecord(value) {
11
+ if (!value || typeof value !== 'object' || Array.isArray(value))
12
+ return {};
13
+ return value;
14
+ }
15
+ function normalizeSlide(value, index) {
16
+ const slide = { ...asRecord(value) };
17
+ const hasLocation = slide.location !== undefined;
18
+ const location = coerceLocation(slide.location, slide.zoom);
19
+ const media = coerceMedia(slide.media);
20
+ if (hasLocation && !location) {
21
+ throw new StoryMapParseError(`slides[${index}].location is not a valid [lat, lng] coordinate pair.`);
22
+ }
23
+ if (location)
24
+ slide.location = location;
25
+ if (media)
26
+ slide.media = media;
27
+ delete slide.zoom;
28
+ return slide;
29
+ }
30
+ export function normalizeStoryMapInput(value) {
31
+ const input = { ...asRecord(value) };
32
+ const map = { ...asRecord(input.map) };
33
+ const hasLat = input.lat !== undefined;
34
+ const hasLng = input.long !== undefined || input.lng !== undefined;
35
+ if (hasLat || hasLng) {
36
+ const lat = Number(input.lat);
37
+ const lng = Number(input.long ?? input.lng);
38
+ if (!hasLat || !hasLng || !validCoordinates(lat, lng)) {
39
+ throw new StoryMapParseError('Root coordinates are invalid. Provide both lat and long (or lng) within valid ranges.');
40
+ }
41
+ if (!map.center)
42
+ map.center = [lat, lng];
43
+ }
44
+ if (map.zoom === undefined && input.defaultZoom !== undefined)
45
+ map.zoom = Number(input.defaultZoom);
46
+ if (map.tileUrl === undefined && input.tileServer !== undefined)
47
+ map.tileUrl = input.tileServer;
48
+ input.map = map;
49
+ if (Array.isArray(input.slides))
50
+ input.slides = input.slides.map(normalizeSlide);
51
+ delete input.lat;
52
+ delete input.long;
53
+ delete input.lng;
54
+ delete input.defaultZoom;
55
+ delete input.tileServer;
56
+ return input;
57
+ }
58
+ export function parseStoryMapObject(value) {
59
+ return storyMapSchema.parse(normalizeStoryMapInput(value));
60
+ }
61
+ export function parseStoryMapYaml(source) {
62
+ return parseStoryMapObject(load(source));
63
+ }
64
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG7E,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;Q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CAAC,KAAc;IAChD,OAAO,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAmB,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { z } from 'zod';
2
+ export declare const storySlideSchema: z.ZodObject<{
3
+ id: z.ZodOptional<z.ZodString>;
4
+ note: z.ZodOptional<z.ZodString>;
5
+ title: z.ZodOptional<z.ZodString>;
6
+ text: z.ZodOptional<z.ZodString>;
7
+ location: z.ZodOptional<z.ZodObject<{
8
+ lat: z.ZodNumber;
9
+ lng: z.ZodNumber;
10
+ zoom: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$strip>>;
12
+ media: z.ZodOptional<z.ZodObject<{
13
+ type: z.ZodEnum<{
14
+ iframe: "iframe";
15
+ image: "image";
16
+ video: "video";
17
+ }>;
18
+ src: z.ZodString;
19
+ alt: z.ZodOptional<z.ZodString>;
20
+ caption: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>>;
22
+ mapmarker: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export declare const storyMapSchema: z.ZodObject<{
25
+ schema: z.ZodDefault<z.ZodLiteral<"storymap/v1">>;
26
+ id: z.ZodOptional<z.ZodString>;
27
+ title: z.ZodOptional<z.ZodString>;
28
+ height: z.ZodDefault<z.ZodString>;
29
+ map: z.ZodDefault<z.ZodObject<{
30
+ center: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
31
+ zoom: z.ZodDefault<z.ZodNumber>;
32
+ minZoom: z.ZodOptional<z.ZodNumber>;
33
+ maxZoom: z.ZodOptional<z.ZodNumber>;
34
+ tileUrl: z.ZodDefault<z.ZodString>;
35
+ attribution: z.ZodDefault<z.ZodString>;
36
+ showPath: z.ZodDefault<z.ZodBoolean>;
37
+ }, z.core.$strip>>;
38
+ slides: z.ZodArray<z.ZodObject<{
39
+ id: z.ZodOptional<z.ZodString>;
40
+ note: z.ZodOptional<z.ZodString>;
41
+ title: z.ZodOptional<z.ZodString>;
42
+ text: z.ZodOptional<z.ZodString>;
43
+ location: z.ZodOptional<z.ZodObject<{
44
+ lat: z.ZodNumber;
45
+ lng: z.ZodNumber;
46
+ zoom: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strip>>;
48
+ media: z.ZodOptional<z.ZodObject<{
49
+ type: z.ZodEnum<{
50
+ iframe: "iframe";
51
+ image: "image";
52
+ video: "video";
53
+ }>;
54
+ src: z.ZodString;
55
+ alt: z.ZodOptional<z.ZodString>;
56
+ caption: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>>;
58
+ mapmarker: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>>;
60
+ }, z.core.$strip>;
61
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;iBAQ3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBzB,CAAC"}
package/dist/schema.js ADDED
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ const locationSchema = z.object({
3
+ lat: z.number().min(-90).max(90),
4
+ lng: z.number().min(-180).max(180),
5
+ zoom: z.number().min(0).max(24).optional(),
6
+ });
7
+ const mediaSchema = z.object({
8
+ type: z.enum(['image', 'video', 'iframe']),
9
+ src: z.string().min(1),
10
+ alt: z.string().optional(),
11
+ caption: z.string().optional(),
12
+ });
13
+ export const storySlideSchema = z.object({
14
+ id: z.string().optional(),
15
+ note: z.string().optional(),
16
+ title: z.string().optional(),
17
+ text: z.string().optional(),
18
+ location: locationSchema.optional(),
19
+ media: mediaSchema.optional(),
20
+ mapmarker: z.string().optional(),
21
+ });
22
+ export const storyMapSchema = z.object({
23
+ schema: z.literal('storymap/v1').default('storymap/v1'),
24
+ id: z.string().optional(),
25
+ title: z.string().optional(),
26
+ height: z.string().default('520px'),
27
+ map: z.object({
28
+ center: z.tuple([
29
+ z.number().min(-90).max(90),
30
+ z.number().min(-180).max(180),
31
+ ]).optional(),
32
+ zoom: z.number().min(0).max(24).default(6),
33
+ minZoom: z.number().min(0).max(24).optional(),
34
+ maxZoom: z.number().min(0).max(24).optional(),
35
+ tileUrl: z.string().min(1).default('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),
36
+ attribution: z.string().default('© OpenStreetMap contributors'),
37
+ showPath: z.boolean().default(true),
38
+ }).default({
39
+ zoom: 6,
40
+ tileUrl: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
41
+ attribution: '© OpenStreetMap contributors',
42
+ showPath: true,
43
+ }),
44
+ slides: z.array(storySlideSchema).min(1),
45
+ });
46
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAA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
+ zoom?: number;
6
+ }
7
+ export type StoryMediaType = 'image' | 'video' | 'iframe';
8
+ export interface StoryMedia {
9
+ type: StoryMediaType;
10
+ src: string;
11
+ alt?: string;
12
+ caption?: string;
13
+ }
14
+ export interface StorySlide {
15
+ id?: string;
16
+ note?: string;
17
+ title?: string;
18
+ text?: string;
19
+ location?: StoryLocation;
20
+ media?: StoryMedia;
21
+ mapmarker?: string;
22
+ }
23
+ export interface StoryMapOptions {
24
+ center?: LatLngTuple;
25
+ zoom: number;
26
+ minZoom?: number;
27
+ maxZoom?: number;
28
+ tileUrl: string;
29
+ attribution: string;
30
+ showPath: boolean;
31
+ }
32
+ export interface StoryMapConfig {
33
+ schema: 'storymap/v1';
34
+ id?: string;
35
+ title?: string;
36
+ height: string;
37
+ map: StoryMapOptions;
38
+ slides: StorySlide[];
39
+ }
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@story-map/story-map-core",
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic schema, parser, and helpers for StoryMap v1.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kywk/story-map-monorepo.git",
9
+ "directory": "packages/story-map-core"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "js-yaml": "^5.4.2",
29
+ "zod": "^4.6.5"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -b",
33
+ "typecheck": "tsc -b",
34
+ "test": "vitest run",
35
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
36
+ }
37
+ }