@maplibre-yaml/core 0.1.2 → 0.1.3-beta.1
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/README.md +185 -952
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +101 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +101 -1
- package/dist/index.js.map +1 -1
- package/dist/{map-renderer-DOLO9y-3.d.ts → map-renderer-IvxniEQy.d.ts} +72 -2
- package/dist/{page.schema-CzdCyPFI.d.ts → page.schema-VBytF9l5.d.ts} +544 -6
- package/dist/register.browser.js +101 -1
- package/dist/register.browser.js.map +1 -1
- package/dist/register.d.ts +2 -2
- package/dist/register.js +101 -1
- package/dist/register.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -483
- package/dist/schemas/index.js +3 -1
- package/dist/schemas/index.js.map +1 -1
- package/package.json +1 -1
package/dist/register.browser.js
CHANGED
|
@@ -11836,7 +11836,9 @@ var MapConfigSchema = external_exports.object({
|
|
|
11836
11836
|
// Required
|
|
11837
11837
|
center: LngLatSchema.describe("Initial map center [longitude, latitude]"),
|
|
11838
11838
|
zoom: ZoomLevelSchema.describe("Initial zoom level (0-24)"),
|
|
11839
|
-
mapStyle: external_exports.union([external_exports.string().url(), external_exports.any()]).describe(
|
|
11839
|
+
mapStyle: external_exports.union([external_exports.string().url(), external_exports.any()]).optional().describe(
|
|
11840
|
+
"MapLibre style URL or style object. Optional when global config.defaultMapStyle is set."
|
|
11841
|
+
),
|
|
11840
11842
|
// View
|
|
11841
11843
|
pitch: external_exports.number().min(0).max(85).default(0).describe("Camera pitch angle in degrees (0-85)"),
|
|
11842
11844
|
bearing: external_exports.number().min(-180).max(180).default(0).describe("Camera bearing (rotation) in degrees (-180 to 180)"),
|
|
@@ -12216,6 +12218,104 @@ var YAMLParser = class {
|
|
|
12216
12218
|
};
|
|
12217
12219
|
}
|
|
12218
12220
|
}
|
|
12221
|
+
/**
|
|
12222
|
+
* Parse YAML string for a scrollytelling block and validate against ScrollytellingBlockSchema
|
|
12223
|
+
*
|
|
12224
|
+
* @param yaml - YAML string to parse (should be a scrollytelling block, not a full document)
|
|
12225
|
+
* @returns Validated scrollytelling block object
|
|
12226
|
+
* @throws {Error} If YAML syntax is invalid
|
|
12227
|
+
* @throws {ZodError} If validation fails
|
|
12228
|
+
*
|
|
12229
|
+
* @remarks
|
|
12230
|
+
* This method is specifically for parsing individual scrollytelling blocks (e.g., in documentation
|
|
12231
|
+
* or component usage). Unlike {@link parse}, it validates against ScrollytellingBlockSchema rather
|
|
12232
|
+
* than RootSchema, so it expects a single scrollytelling configuration without the pages array wrapper.
|
|
12233
|
+
*
|
|
12234
|
+
* @example
|
|
12235
|
+
* ```typescript
|
|
12236
|
+
* const yaml = `
|
|
12237
|
+
* type: scrollytelling
|
|
12238
|
+
* id: story
|
|
12239
|
+
* config:
|
|
12240
|
+
* center: [0, 0]
|
|
12241
|
+
* zoom: 2
|
|
12242
|
+
* mapStyle: "https://example.com/style.json"
|
|
12243
|
+
* chapters:
|
|
12244
|
+
* - id: intro
|
|
12245
|
+
* title: "Introduction"
|
|
12246
|
+
* center: [0, 0]
|
|
12247
|
+
* zoom: 3
|
|
12248
|
+
* description: "Welcome to our story."
|
|
12249
|
+
* - id: chapter2
|
|
12250
|
+
* title: "Chapter 2"
|
|
12251
|
+
* center: [10, 10]
|
|
12252
|
+
* zoom: 5
|
|
12253
|
+
* description: "The story continues."
|
|
12254
|
+
* `;
|
|
12255
|
+
*
|
|
12256
|
+
* const scrollyBlock = YAMLParser.parseScrollytellingBlock(yaml);
|
|
12257
|
+
* ```
|
|
12258
|
+
*/
|
|
12259
|
+
static parseScrollytellingBlock(yaml) {
|
|
12260
|
+
let parsed;
|
|
12261
|
+
try {
|
|
12262
|
+
parsed = (0, import_yaml.parse)(yaml);
|
|
12263
|
+
} catch (error) {
|
|
12264
|
+
throw new Error(
|
|
12265
|
+
`YAML syntax error: ${error instanceof Error ? error.message : String(error)}`
|
|
12266
|
+
);
|
|
12267
|
+
}
|
|
12268
|
+
return ScrollytellingBlockSchema.parse(parsed);
|
|
12269
|
+
}
|
|
12270
|
+
/**
|
|
12271
|
+
* Parse YAML string for a scrollytelling block, returning a result object
|
|
12272
|
+
*
|
|
12273
|
+
* @param yaml - YAML string to parse (should be a scrollytelling block, not a full document)
|
|
12274
|
+
* @returns Result object with success flag and either data or errors
|
|
12275
|
+
*
|
|
12276
|
+
* @remarks
|
|
12277
|
+
* This is the non-throwing version of {@link parseScrollytellingBlock}. Instead of throwing
|
|
12278
|
+
* errors, it returns a result object that indicates success or failure.
|
|
12279
|
+
* Use this when you want to handle errors gracefully without try/catch.
|
|
12280
|
+
*
|
|
12281
|
+
* @example
|
|
12282
|
+
* ```typescript
|
|
12283
|
+
* const result = YAMLParser.safeParseScrollytellingBlock(yamlString);
|
|
12284
|
+
* if (result.success) {
|
|
12285
|
+
* console.log('Scrollytelling config:', result.data);
|
|
12286
|
+
* } else {
|
|
12287
|
+
* result.errors.forEach(err => {
|
|
12288
|
+
* console.error(`Error at ${err.path}: ${err.message}`);
|
|
12289
|
+
* });
|
|
12290
|
+
* }
|
|
12291
|
+
* ```
|
|
12292
|
+
*/
|
|
12293
|
+
static safeParseScrollytellingBlock(yaml) {
|
|
12294
|
+
try {
|
|
12295
|
+
const data = this.parseScrollytellingBlock(yaml);
|
|
12296
|
+
return {
|
|
12297
|
+
success: true,
|
|
12298
|
+
data,
|
|
12299
|
+
errors: []
|
|
12300
|
+
};
|
|
12301
|
+
} catch (error) {
|
|
12302
|
+
if (error instanceof ZodError) {
|
|
12303
|
+
return {
|
|
12304
|
+
success: false,
|
|
12305
|
+
errors: this.formatZodErrors(error)
|
|
12306
|
+
};
|
|
12307
|
+
}
|
|
12308
|
+
return {
|
|
12309
|
+
success: false,
|
|
12310
|
+
errors: [
|
|
12311
|
+
{
|
|
12312
|
+
path: "",
|
|
12313
|
+
message: error instanceof Error ? error.message : String(error)
|
|
12314
|
+
}
|
|
12315
|
+
]
|
|
12316
|
+
};
|
|
12317
|
+
}
|
|
12318
|
+
}
|
|
12219
12319
|
/**
|
|
12220
12320
|
* Resolve $ref references to global layers and sources
|
|
12221
12321
|
*
|