@deck.gl-community/graph-layers 9.2.0-beta.5 → 9.2.0-beta.8

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.
Files changed (44) hide show
  1. package/dist/core/graph-engine.d.ts +3 -2
  2. package/dist/core/graph-engine.d.ts.map +1 -1
  3. package/dist/core/graph-engine.js +1 -0
  4. package/dist/core/graph-engine.js.map +1 -1
  5. package/dist/graph-style-schema.cdn.js +1 -1
  6. package/dist/graph-style-schema.json +1 -1
  7. package/dist/index.cjs +307 -202
  8. package/dist/index.cjs.map +4 -4
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/layers/edge-attachment-helper.d.ts.map +1 -1
  13. package/dist/layers/edge-attachment-helper.js.map +1 -1
  14. package/dist/layers/graph-layer.d.ts +4 -3
  15. package/dist/layers/graph-layer.d.ts.map +1 -1
  16. package/dist/layers/graph-layer.js +11 -6
  17. package/dist/layers/graph-layer.js.map +1 -1
  18. package/dist/loaders/dot-graph-loader.js +1 -1
  19. package/dist/loaders/json-graph-loader.js +1 -1
  20. package/dist/style/graph-layer-stylesheet.d.ts +14 -5
  21. package/dist/style/graph-layer-stylesheet.d.ts.map +1 -1
  22. package/dist/style/graph-layer-stylesheet.js +9 -3
  23. package/dist/style/graph-layer-stylesheet.js.map +1 -1
  24. package/dist/style/graph-style-engine.d.ts +4 -4
  25. package/dist/style/graph-style-engine.d.ts.map +1 -1
  26. package/dist/style/graph-style-engine.js +4 -4
  27. package/dist/style/graph-style-engine.js.map +1 -1
  28. package/dist/style/graph-stylesheet-schema.d.ts +13211 -0
  29. package/dist/style/graph-stylesheet-schema.d.ts.map +1 -0
  30. package/dist/style/graph-stylesheet-schema.js +354 -0
  31. package/dist/style/graph-stylesheet-schema.js.map +1 -0
  32. package/package.json +2 -2
  33. package/src/core/graph-engine.ts +7 -2
  34. package/src/index.ts +2 -1
  35. package/src/layers/edge-attachment-helper.ts +2 -5
  36. package/src/layers/graph-layer.ts +25 -19
  37. package/src/style/graph-layer-stylesheet.ts +16 -9
  38. package/src/style/graph-style-engine.ts +21 -13
  39. package/src/style/graph-stylesheet-schema.ts +538 -0
  40. package/dist/style/graph-stylesheet.schema.d.ts +0 -311
  41. package/dist/style/graph-stylesheet.schema.d.ts.map +0 -1
  42. package/dist/style/graph-stylesheet.schema.js +0 -238
  43. package/dist/style/graph-stylesheet.schema.js.map +0 -1
  44. package/src/style/graph-stylesheet.schema.ts +0 -344
package/dist/index.cjs CHANGED
@@ -2249,56 +2249,10 @@ var StylesheetEngine = class {
2249
2249
  }
2250
2250
  };
2251
2251
 
2252
- // dist/style/graph-stylesheet.schema.js
2252
+ // dist/style/graph-stylesheet-schema.js
2253
2253
  var import_zod = require("zod");
2254
- var GraphStylePrimitiveSchema = import_zod.z.union([
2255
- import_zod.z.string(),
2256
- import_zod.z.number(),
2257
- import_zod.z.boolean(),
2258
- import_zod.z.null(),
2259
- import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
2260
- ]);
2261
- var GraphStyleFunctionSchema = import_zod.z.custom((value) => typeof value === "function", {
2262
- message: "Style functions must be callable."
2263
- });
2264
- var GraphStyleScaleTypeEnum = import_zod.z.enum([
2265
- "linear",
2266
- "log",
2267
- "pow",
2268
- "sqrt",
2269
- "quantize",
2270
- "quantile",
2271
- "ordinal"
2272
- ]);
2273
- var GraphStyleScaleSchema = import_zod.z.object({
2274
- type: GraphStyleScaleTypeEnum.optional(),
2275
- domain: import_zod.z.array(import_zod.z.union([import_zod.z.number(), import_zod.z.string()])).optional(),
2276
- range: import_zod.z.array(import_zod.z.any()).optional(),
2277
- clamp: import_zod.z.boolean().optional(),
2278
- nice: import_zod.z.union([import_zod.z.boolean(), import_zod.z.number()]).optional(),
2279
- base: import_zod.z.number().optional(),
2280
- exponent: import_zod.z.number().optional(),
2281
- unknown: import_zod.z.any().optional()
2282
- }).strict();
2283
- var GraphStyleAttributeReferenceSchema = import_zod.z.union([
2284
- import_zod.z.string().regex(/^@.+/, 'Attribute reference strings must start with "@" and include an attribute name.'),
2285
- import_zod.z.object({
2286
- attribute: import_zod.z.string().min(1, "Attribute name is required."),
2287
- fallback: GraphStylePrimitiveSchema.optional(),
2288
- scale: import_zod.z.union([GraphStyleScaleSchema, GraphStyleFunctionSchema]).optional()
2289
- }).strict()
2290
- ]);
2291
- var GraphStyleLeafValueSchema = import_zod.z.union([
2292
- GraphStylePrimitiveSchema,
2293
- GraphStyleAttributeReferenceSchema,
2294
- GraphStyleFunctionSchema
2295
- ]);
2296
- var RESERVED_STATE_KEYS = /* @__PURE__ */ new Set(["attribute", "fallback", "scale"]);
2297
- var GraphStyleStateMapSchema = import_zod.z.record(import_zod.z.string().refine((key) => !RESERVED_STATE_KEYS.has(key), "State overrides must not use reserved keys."), GraphStyleLeafValueSchema);
2298
- var GraphStyleValueSchema = import_zod.z.union([
2299
- GraphStyleLeafValueSchema,
2300
- GraphStyleStateMapSchema
2301
- ]);
2254
+
2255
+ // dist/style/graph-style-accessor-map.js
2302
2256
  var COMMON_DECKGL_PROPS = {
2303
2257
  getOffset: "offset",
2304
2258
  opacity: "opacity"
@@ -2389,32 +2343,69 @@ var GRAPH_DECKGL_ACCESSOR_MAP = {
2389
2343
  getOffset: "offset"
2390
2344
  }
2391
2345
  };
2346
+
2347
+ // dist/style/graph-stylesheet-schema.js
2348
+ var GraphStylePrimitiveSchema = import_zod.z.union([
2349
+ import_zod.z.string(),
2350
+ import_zod.z.number(),
2351
+ import_zod.z.boolean(),
2352
+ import_zod.z.null(),
2353
+ import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
2354
+ ]);
2355
+ var GraphStyleFunctionSchema = import_zod.z.custom((value) => typeof value === "function", {
2356
+ message: "Style functions must be callable."
2357
+ });
2358
+ var GraphStyleScaleTypeEnum = import_zod.z.enum([
2359
+ "linear",
2360
+ "log",
2361
+ "pow",
2362
+ "sqrt",
2363
+ "quantize",
2364
+ "quantile",
2365
+ "ordinal"
2366
+ ]);
2367
+ var GraphStyleScaleSchema = import_zod.z.object({
2368
+ type: GraphStyleScaleTypeEnum.optional(),
2369
+ domain: import_zod.z.array(import_zod.z.union([import_zod.z.number(), import_zod.z.string()])).optional(),
2370
+ range: import_zod.z.array(import_zod.z.any()).optional(),
2371
+ clamp: import_zod.z.boolean().optional(),
2372
+ nice: import_zod.z.union([import_zod.z.boolean(), import_zod.z.number()]).optional(),
2373
+ base: import_zod.z.number().optional(),
2374
+ exponent: import_zod.z.number().optional(),
2375
+ unknown: import_zod.z.any().optional()
2376
+ }).strict();
2377
+ var GraphStyleAttributeReferenceSchema = import_zod.z.union([
2378
+ import_zod.z.string().regex(/^@.+/, 'Attribute reference strings must start with "@" and include an attribute name.'),
2379
+ import_zod.z.object({
2380
+ attribute: import_zod.z.string().min(1, "Attribute name is required."),
2381
+ fallback: GraphStylePrimitiveSchema.optional(),
2382
+ scale: import_zod.z.union([GraphStyleScaleSchema, GraphStyleFunctionSchema]).optional()
2383
+ }).strict()
2384
+ ]);
2385
+ var GraphStyleLeafValueSchema = import_zod.z.union([
2386
+ GraphStylePrimitiveSchema,
2387
+ GraphStyleAttributeReferenceSchema,
2388
+ GraphStyleFunctionSchema
2389
+ ]);
2390
+ var RESERVED_STATE_KEYS = /* @__PURE__ */ new Set(["attribute", "fallback", "scale"]);
2391
+ var GraphStyleStateMapSchema = import_zod.z.record(import_zod.z.string().refine((key) => !RESERVED_STATE_KEYS.has(key), "State overrides must not use reserved keys."), GraphStyleLeafValueSchema);
2392
+ var GraphStyleValueSchema = import_zod.z.union([
2393
+ GraphStyleLeafValueSchema,
2394
+ GraphStyleStateMapSchema
2395
+ ]);
2392
2396
  var GraphStyleSelectorKeySchema = import_zod.z.string().regex(/^:[^\s]+/, 'Selectors must start with ":".');
2393
- function createPropertiesSchema(keys) {
2394
- const shape = keys.reduce((acc, key) => {
2395
- acc[key] = GraphStyleValueSchema.optional();
2396
- return acc;
2397
- }, {});
2398
- return import_zod.z.object(shape).partial().strict();
2399
- }
2400
- var GraphStylesheetVariants = Object.entries(GRAPH_DECKGL_ACCESSOR_MAP).map(([type, accessors]) => {
2401
- const propertyKeys = Object.values(accessors);
2402
- const propertyKeySet = new Set(propertyKeys);
2403
- const propertiesSchema = createPropertiesSchema(propertyKeys);
2404
- const baseShape = {
2405
- type: import_zod.z.literal(type)
2406
- };
2407
- for (const key of propertyKeys) {
2408
- baseShape[key] = GraphStyleValueSchema.optional();
2409
- }
2410
- return import_zod.z.object(baseShape).catchall(import_zod.z.unknown()).superRefine((value, ctx) => {
2411
- for (const key of Object.keys(value)) {
2412
- if (key === "type") {
2397
+ function createSelectorRefinement(allowedKeys, propertiesSchema) {
2398
+ const allowedKeySet = new Set(allowedKeys);
2399
+ return (value, ctx) => {
2400
+ if (typeof value !== "object" || value === null) {
2401
+ return;
2402
+ }
2403
+ const record = value;
2404
+ for (const key of Object.keys(record)) {
2405
+ if (key === "type")
2413
2406
  continue;
2414
- }
2415
- if (propertyKeySet.has(key)) {
2407
+ if (allowedKeySet.has(key))
2416
2408
  continue;
2417
- }
2418
2409
  if (!key.startsWith(":")) {
2419
2410
  ctx.addIssue({
2420
2411
  code: import_zod.z.ZodIssueCode.custom,
@@ -2431,7 +2422,7 @@ var GraphStylesheetVariants = Object.entries(GRAPH_DECKGL_ACCESSOR_MAP).map(([ty
2431
2422
  });
2432
2423
  continue;
2433
2424
  }
2434
- const selectorResult = propertiesSchema.safeParse(value[key]);
2425
+ const selectorResult = propertiesSchema.safeParse(record[key]);
2435
2426
  if (!selectorResult.success) {
2436
2427
  for (const issue of selectorResult.error.issues) {
2437
2428
  ctx.addIssue({
@@ -2441,101 +2432,189 @@ var GraphStylesheetVariants = Object.entries(GRAPH_DECKGL_ACCESSOR_MAP).map(([ty
2441
2432
  }
2442
2433
  }
2443
2434
  }
2444
- });
2445
- });
2446
- var GraphStylesheetSchema = import_zod.z.discriminatedUnion("type", GraphStylesheetVariants);
2447
-
2448
- // dist/style/graph-style-accessor-map.js
2449
- var COMMON_DECKGL_PROPS2 = {
2450
- getOffset: "offset",
2451
- opacity: "opacity"
2435
+ };
2436
+ }
2437
+ var CircleShape = {
2438
+ offset: GraphStyleValueSchema.optional(),
2439
+ opacity: GraphStyleValueSchema.optional(),
2440
+ fill: GraphStyleValueSchema.optional(),
2441
+ stroke: GraphStyleValueSchema.optional(),
2442
+ strokeWidth: GraphStyleValueSchema.optional(),
2443
+ radius: GraphStyleValueSchema.optional()
2452
2444
  };
2453
- var GRAPH_DECKGL_ACCESSOR_MAP2 = {
2454
- circle: {
2455
- ...COMMON_DECKGL_PROPS2,
2456
- getFillColor: "fill",
2457
- getLineColor: "stroke",
2458
- getLineWidth: "strokeWidth",
2459
- getRadius: "radius"
2460
- },
2461
- rectangle: {
2462
- ...COMMON_DECKGL_PROPS2,
2463
- getWidth: "width",
2464
- getHeight: "height",
2465
- getFillColor: "fill",
2466
- getLineColor: "stroke",
2467
- getLineWidth: "strokeWidth"
2468
- },
2469
- "rounded-rectangle": {
2470
- ...COMMON_DECKGL_PROPS2,
2471
- getCornerRadius: "cornerRadius",
2472
- getRadius: "radius",
2473
- getWidth: "width",
2474
- getHeight: "height",
2475
- getFillColor: "fill",
2476
- getLineColor: "stroke",
2477
- getLineWidth: "strokeWidth"
2478
- },
2479
- "path-rounded-rectangle": {
2480
- ...COMMON_DECKGL_PROPS2,
2481
- getWidth: "width",
2482
- getHeight: "height",
2483
- getFillColor: "fill",
2484
- getLineColor: "stroke",
2485
- getLineWidth: "strokeWidth",
2486
- getCornerRadius: "cornerRadius"
2487
- },
2488
- label: {
2489
- ...COMMON_DECKGL_PROPS2,
2490
- getColor: "color",
2491
- getText: "text",
2492
- getSize: "fontSize",
2493
- getTextAnchor: "textAnchor",
2494
- getAlignmentBaseline: "alignmentBaseline",
2495
- getAngle: "angle",
2496
- scaleWithZoom: "scaleWithZoom",
2497
- textMaxWidth: "textMaxWidth",
2498
- textWordBreak: "textWordBreak",
2499
- textSizeMinPixels: "textSizeMinPixels"
2500
- },
2501
- marker: {
2502
- ...COMMON_DECKGL_PROPS2,
2503
- getColor: "fill",
2504
- getSize: "size",
2505
- getMarker: "marker",
2506
- scaleWithZoom: "scaleWithZoom"
2507
- },
2508
- Edge: {
2509
- getColor: "stroke",
2510
- getWidth: "strokeWidth"
2511
- },
2512
- edge: {
2513
- getColor: "stroke",
2514
- getWidth: "strokeWidth"
2515
- },
2516
- "edge-label": {
2517
- getColor: "color",
2518
- getText: "text",
2519
- getSize: "fontSize",
2520
- getTextAnchor: "textAnchor",
2521
- getAlignmentBaseline: "alignmentBaseline",
2522
- scaleWithZoom: "scaleWithZoom",
2523
- textMaxWidth: "textMaxWidth",
2524
- textWordBreak: "textWordBreak",
2525
- textSizeMinPixels: "textSizeMinPixels"
2526
- },
2527
- flow: {
2528
- getColor: "color",
2529
- getWidth: "width",
2530
- getSpeed: "speed",
2531
- getTailLength: "tailLength"
2532
- },
2533
- arrow: {
2534
- getColor: "color",
2535
- getSize: "size",
2536
- getOffset: "offset"
2537
- }
2445
+ var CirclePropertiesSchema = import_zod.z.object(CircleShape).partial().strict();
2446
+ var CircleStylesheetSchema = import_zod.z.object({
2447
+ type: import_zod.z.literal("circle"),
2448
+ ...CircleShape
2449
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(CircleShape), CirclePropertiesSchema));
2450
+ var RectangleShape = {
2451
+ offset: GraphStyleValueSchema.optional(),
2452
+ opacity: GraphStyleValueSchema.optional(),
2453
+ width: GraphStyleValueSchema.optional(),
2454
+ height: GraphStyleValueSchema.optional(),
2455
+ fill: GraphStyleValueSchema.optional(),
2456
+ stroke: GraphStyleValueSchema.optional(),
2457
+ strokeWidth: GraphStyleValueSchema.optional()
2458
+ };
2459
+ var RectanglePropertiesSchema = import_zod.z.object(RectangleShape).partial().strict();
2460
+ var RectangleStylesheetSchema = import_zod.z.object({
2461
+ type: import_zod.z.literal("rectangle"),
2462
+ ...RectangleShape
2463
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(RectangleShape), RectanglePropertiesSchema));
2464
+ var RoundedRectangleShape = {
2465
+ offset: GraphStyleValueSchema.optional(),
2466
+ opacity: GraphStyleValueSchema.optional(),
2467
+ cornerRadius: GraphStyleValueSchema.optional(),
2468
+ radius: GraphStyleValueSchema.optional(),
2469
+ width: GraphStyleValueSchema.optional(),
2470
+ height: GraphStyleValueSchema.optional(),
2471
+ fill: GraphStyleValueSchema.optional(),
2472
+ stroke: GraphStyleValueSchema.optional(),
2473
+ strokeWidth: GraphStyleValueSchema.optional()
2474
+ };
2475
+ var RoundedRectanglePropertiesSchema = import_zod.z.object(RoundedRectangleShape).partial().strict();
2476
+ var RoundedRectangleStylesheetSchema = import_zod.z.object({
2477
+ type: import_zod.z.literal("rounded-rectangle"),
2478
+ ...RoundedRectangleShape
2479
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(RoundedRectangleShape), RoundedRectanglePropertiesSchema));
2480
+ var PathRoundedRectangleShape = {
2481
+ offset: GraphStyleValueSchema.optional(),
2482
+ opacity: GraphStyleValueSchema.optional(),
2483
+ width: GraphStyleValueSchema.optional(),
2484
+ height: GraphStyleValueSchema.optional(),
2485
+ fill: GraphStyleValueSchema.optional(),
2486
+ stroke: GraphStyleValueSchema.optional(),
2487
+ strokeWidth: GraphStyleValueSchema.optional(),
2488
+ cornerRadius: GraphStyleValueSchema.optional()
2489
+ };
2490
+ var PathRoundedRectanglePropertiesSchema = import_zod.z.object(PathRoundedRectangleShape).partial().strict();
2491
+ var PathRoundedRectangleStylesheetSchema = import_zod.z.object({
2492
+ type: import_zod.z.literal("path-rounded-rectangle"),
2493
+ ...PathRoundedRectangleShape
2494
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(PathRoundedRectangleShape), PathRoundedRectanglePropertiesSchema));
2495
+ var LabelShape = {
2496
+ offset: GraphStyleValueSchema.optional(),
2497
+ opacity: GraphStyleValueSchema.optional(),
2498
+ color: GraphStyleValueSchema.optional(),
2499
+ text: GraphStyleValueSchema.optional(),
2500
+ fontSize: GraphStyleValueSchema.optional(),
2501
+ textAnchor: GraphStyleValueSchema.optional(),
2502
+ alignmentBaseline: GraphStyleValueSchema.optional(),
2503
+ angle: GraphStyleValueSchema.optional(),
2504
+ scaleWithZoom: GraphStyleValueSchema.optional(),
2505
+ textMaxWidth: GraphStyleValueSchema.optional(),
2506
+ textWordBreak: GraphStyleValueSchema.optional(),
2507
+ textSizeMinPixels: GraphStyleValueSchema.optional()
2508
+ };
2509
+ var LabelPropertiesSchema = import_zod.z.object(LabelShape).partial().strict();
2510
+ var LabelStylesheetSchema = import_zod.z.object({
2511
+ type: import_zod.z.literal("label"),
2512
+ ...LabelShape
2513
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(LabelShape), LabelPropertiesSchema));
2514
+ var MarkerShape = {
2515
+ offset: GraphStyleValueSchema.optional(),
2516
+ opacity: GraphStyleValueSchema.optional(),
2517
+ fill: GraphStyleValueSchema.optional(),
2518
+ size: GraphStyleValueSchema.optional(),
2519
+ marker: GraphStyleValueSchema.optional(),
2520
+ scaleWithZoom: GraphStyleValueSchema.optional()
2521
+ };
2522
+ var MarkerPropertiesSchema = import_zod.z.object(MarkerShape).partial().strict();
2523
+ var MarkerStylesheetSchema = import_zod.z.object({
2524
+ type: import_zod.z.literal("marker"),
2525
+ ...MarkerShape
2526
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(MarkerShape), MarkerPropertiesSchema));
2527
+ var EdgeUpperShape = {
2528
+ stroke: GraphStyleValueSchema.optional(),
2529
+ strokeWidth: GraphStyleValueSchema.optional()
2530
+ };
2531
+ var EdgeUpperPropertiesSchema = import_zod.z.object(EdgeUpperShape).partial().strict();
2532
+ var EdgeUpperStylesheetSchema = import_zod.z.object({
2533
+ type: import_zod.z.literal("Edge"),
2534
+ ...EdgeUpperShape
2535
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(EdgeUpperShape), EdgeUpperPropertiesSchema));
2536
+ var EdgeLowerShape = {
2537
+ stroke: GraphStyleValueSchema.optional(),
2538
+ strokeWidth: GraphStyleValueSchema.optional()
2539
+ };
2540
+ var EdgeLowerPropertiesSchema = import_zod.z.object(EdgeLowerShape).partial().strict();
2541
+ var EdgeLowerStylesheetSchema = import_zod.z.object({
2542
+ type: import_zod.z.literal("edge"),
2543
+ ...EdgeLowerShape
2544
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(EdgeLowerShape), EdgeLowerPropertiesSchema));
2545
+ var EdgeLabelShape = {
2546
+ color: GraphStyleValueSchema.optional(),
2547
+ text: GraphStyleValueSchema.optional(),
2548
+ fontSize: GraphStyleValueSchema.optional(),
2549
+ textAnchor: GraphStyleValueSchema.optional(),
2550
+ alignmentBaseline: GraphStyleValueSchema.optional(),
2551
+ scaleWithZoom: GraphStyleValueSchema.optional(),
2552
+ textMaxWidth: GraphStyleValueSchema.optional(),
2553
+ textWordBreak: GraphStyleValueSchema.optional(),
2554
+ textSizeMinPixels: GraphStyleValueSchema.optional()
2555
+ };
2556
+ var EdgeLabelPropertiesSchema = import_zod.z.object(EdgeLabelShape).partial().strict();
2557
+ var EdgeLabelStylesheetSchema = import_zod.z.object({
2558
+ type: import_zod.z.literal("edge-label"),
2559
+ ...EdgeLabelShape
2560
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(EdgeLabelShape), EdgeLabelPropertiesSchema));
2561
+ var FlowShape = {
2562
+ color: GraphStyleValueSchema.optional(),
2563
+ width: GraphStyleValueSchema.optional(),
2564
+ speed: GraphStyleValueSchema.optional(),
2565
+ tailLength: GraphStyleValueSchema.optional()
2566
+ };
2567
+ var FlowPropertiesSchema = import_zod.z.object(FlowShape).partial().strict();
2568
+ var FlowStylesheetSchema = import_zod.z.object({
2569
+ type: import_zod.z.literal("flow"),
2570
+ ...FlowShape
2571
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(FlowShape), FlowPropertiesSchema));
2572
+ var ArrowShape = {
2573
+ color: GraphStyleValueSchema.optional(),
2574
+ size: GraphStyleValueSchema.optional(),
2575
+ offset: GraphStyleValueSchema.optional()
2538
2576
  };
2577
+ var ArrowPropertiesSchema = import_zod.z.object(ArrowShape).partial().strict();
2578
+ var ArrowStylesheetSchema = import_zod.z.object({
2579
+ type: import_zod.z.literal("arrow"),
2580
+ ...ArrowShape
2581
+ }).catchall(import_zod.z.unknown()).superRefine(createSelectorRefinement(Object.keys(ArrowShape), ArrowPropertiesSchema));
2582
+ var GraphNodeStylesheetVariants = [
2583
+ CircleStylesheetSchema,
2584
+ RectangleStylesheetSchema,
2585
+ RoundedRectangleStylesheetSchema,
2586
+ PathRoundedRectangleStylesheetSchema,
2587
+ LabelStylesheetSchema,
2588
+ MarkerStylesheetSchema
2589
+ ];
2590
+ var GraphEdgeStylesheetVariants = [
2591
+ EdgeUpperStylesheetSchema,
2592
+ EdgeLowerStylesheetSchema,
2593
+ EdgeLabelStylesheetSchema,
2594
+ FlowStylesheetSchema,
2595
+ ArrowStylesheetSchema
2596
+ ];
2597
+ var GraphStyleRuleVariants = [
2598
+ ...GraphNodeStylesheetVariants,
2599
+ ...GraphEdgeStylesheetVariants
2600
+ ];
2601
+ var GraphStyleRuleSchema = import_zod.z.discriminatedUnion("type", GraphStyleRuleVariants);
2602
+ var GraphNodeStyleRuleSchema = import_zod.z.discriminatedUnion("type", GraphNodeStylesheetVariants);
2603
+ var GraphEdgeDecoratorRuleSchema = import_zod.z.discriminatedUnion("type", [EdgeLabelStylesheetSchema, FlowStylesheetSchema, ArrowStylesheetSchema]);
2604
+ var EdgeUpperWithDecoratorsSchema = EdgeUpperStylesheetSchema.safeExtend({
2605
+ decorators: import_zod.z.array(GraphEdgeDecoratorRuleSchema).optional()
2606
+ });
2607
+ var EdgeLowerWithDecoratorsSchema = EdgeLowerStylesheetSchema.safeExtend({
2608
+ decorators: import_zod.z.array(GraphEdgeDecoratorRuleSchema).optional()
2609
+ });
2610
+ var GraphEdgeRuleWithDecoratorsSchema = import_zod.z.discriminatedUnion("type", [
2611
+ EdgeUpperWithDecoratorsSchema,
2612
+ EdgeLowerWithDecoratorsSchema
2613
+ ]);
2614
+ var GraphStylesheetSchema = import_zod.z.object({
2615
+ nodes: import_zod.z.array(GraphNodeStyleRuleSchema).optional(),
2616
+ edges: import_zod.z.array(GraphEdgeRuleWithDecoratorsSchema).optional()
2617
+ }).strict();
2539
2618
 
2540
2619
  // dist/style/graph-style-engine.js
2541
2620
  var GRAPH_DECKGL_UPDATE_TRIGGERS = {
@@ -2561,10 +2640,10 @@ ${details}`;
2561
2640
  }
2562
2641
  var GraphStylesheetEngine = class extends StylesheetEngine {
2563
2642
  constructor(style, { stateUpdateTrigger } = {}) {
2564
- const result = GraphStylesheetSchema.safeParse(style);
2643
+ const result = GraphStyleRuleSchema.safeParse(style);
2565
2644
  const parsedStyle = result.success ? result.data : sanitizeStylesheet(style, result.error.issues);
2566
2645
  super(parsedStyle, {
2567
- deckglAccessorMap: GRAPH_DECKGL_ACCESSOR_MAP2,
2646
+ deckglAccessorMap: GRAPH_DECKGL_ACCESSOR_MAP,
2568
2647
  deckglUpdateTriggers: GRAPH_DECKGL_UPDATE_TRIGGERS,
2569
2648
  stateUpdateTrigger
2570
2649
  });
@@ -2606,7 +2685,7 @@ function sanitizeStylesheet(style, issues) {
2606
2685
  }
2607
2686
  delete sanitized[rootKey];
2608
2687
  }
2609
- const result = GraphStylesheetSchema.safeParse(sanitized);
2688
+ const result = GraphStyleRuleSchema.safeParse(sanitized);
2610
2689
  if (result.success) {
2611
2690
  return result.data;
2612
2691
  }
@@ -2756,6 +2835,7 @@ var GraphEngine = class {
2756
2835
  var _a, _b, _c, _d;
2757
2836
  return ((_b = (_a = this._graph).findNode) == null ? void 0 : _b.call(_a, nodeId)) ?? ((_d = (_c = this._graph).findNodeById) == null ? void 0 : _d.call(_c, nodeId));
2758
2837
  }
2838
+ /** Creates a stylesheet engine for a single validated or raw style rule. */
2759
2839
  createStylesheetEngine(style, options = {}) {
2760
2840
  return new GraphStylesheetEngine(style, options);
2761
2841
  }
@@ -4633,10 +4713,16 @@ var import_core18 = require("@deck.gl/core");
4633
4713
  var import_layers13 = require("@deck.gl/layers");
4634
4714
 
4635
4715
  // dist/style/graph-layer-stylesheet.js
4716
+ var DEFAULT_GRAPH_LAYER_STYLESHEET_INPUT = {
4717
+ nodes: [],
4718
+ edges: [{
4719
+ type: "edge",
4720
+ stroke: "black",
4721
+ strokeWidth: 1
4722
+ }]
4723
+ };
4636
4724
  var DEFAULT_EDGE_STYLE = {
4637
- type: "edge",
4638
- stroke: "black",
4639
- strokeWidth: 1,
4725
+ ...DEFAULT_GRAPH_LAYER_STYLESHEET_INPUT.edges[0],
4640
4726
  decorators: []
4641
4727
  };
4642
4728
  var DEFAULT_GRAPH_LAYER_STYLESHEET = {
@@ -6667,31 +6753,6 @@ __publicField(GridLayer, "defaultProps", {
6667
6753
  labelOffset: DEFAULT_OFFSET
6668
6754
  });
6669
6755
 
6670
- // dist/loaders/json-graph-loader.js
6671
- var VERSION = true ? "9.2.0-beta.5" : "latest";
6672
- var JSONGraphLoader = {
6673
- dataType: null,
6674
- batchType: null,
6675
- name: "DOT Graph",
6676
- id: "dot-graph",
6677
- module: "graph-layers",
6678
- version: VERSION,
6679
- worker: false,
6680
- extensions: ["json"],
6681
- mimeTypes: ["application/json"],
6682
- text: true,
6683
- options: {
6684
- "jsongraph": {}
6685
- },
6686
- parse: async (arrayBuffer, options) => {
6687
- const text = new TextDecoder().decode(arrayBuffer);
6688
- return Promise.resolve(JSONGraphLoader.parseTextSync(text, options));
6689
- },
6690
- parseTextSync: (text, options) => {
6691
- throw new Error("JSONGraphLoader.parseTextSync not implemented");
6692
- }
6693
- };
6694
-
6695
6756
  // dist/utils/layer-utils.js
6696
6757
  var mixedGetPosition = (getPosition, getOffset2) => {
6697
6758
  if (!getOffset2) {
@@ -7382,6 +7443,20 @@ function selectRankLines(ranks, { yMin, yMax, maxCount = 8 }) {
7382
7443
  return selected.map((index) => filtered[index]);
7383
7444
  }
7384
7445
 
7446
+ // dist/graph-data/graph-data.js
7447
+ function isArrowGraphData(value) {
7448
+ const candidate = value;
7449
+ return typeof value === "object" && (candidate == null ? void 0 : candidate.shape) === "arrow-graph-data";
7450
+ }
7451
+
7452
+ // dist/graph/functions/create-graph-from-data.js
7453
+ function createGraphFromData(data, props = {}) {
7454
+ if (isArrowGraphData(data)) {
7455
+ return new ArrowGraph({ ...props, data });
7456
+ }
7457
+ return new ClassicGraph({ ...props, data });
7458
+ }
7459
+
7385
7460
  // dist/layers/graph-layer.js
7386
7461
  var NODE_LAYER_MAP = {
7387
7462
  "rectangle": RectangleLayer,
@@ -7411,6 +7486,12 @@ var NODE_STYLE_DEPRECATION_WARNED = false;
7411
7486
  var EDGE_STYLE_DEPRECATION_WARNED = false;
7412
7487
  var GRAPH_PROP_DEPRECATION_WARNED = false;
7413
7488
  var LAYOUT_REQUIRED_WARNED = false;
7489
+ var DEFAULT_GRAPH_LOADER = ({ json }) => {
7490
+ if (!json || typeof json !== "object") {
7491
+ return null;
7492
+ }
7493
+ return createGraphFromData(json);
7494
+ };
7414
7495
  var _GraphLayer = class extends import_core18.CompositeLayer {
7415
7496
  // @ts-expect-error Some typescript confusion due to override of base class state
7416
7497
  state;
@@ -7605,7 +7686,7 @@ var _GraphLayer = class extends import_core18.CompositeLayer {
7605
7686
  return void 0;
7606
7687
  }
7607
7688
  if (Array.isArray(data) || isPlainObject(data)) {
7608
- const loader = props.graphLoader ?? JSONGraphLoader;
7689
+ const loader = props.graphLoader ?? DEFAULT_GRAPH_LOADER;
7609
7690
  const graph = loader({ json: data });
7610
7691
  if (!graph) {
7611
7692
  return null;
@@ -8090,12 +8171,11 @@ var GraphLayer = _GraphLayer;
8090
8171
  __publicField(GraphLayer, "layerName", "GraphLayer");
8091
8172
  __publicField(GraphLayer, "defaultProps", {
8092
8173
  // Composite layer props
8093
- // @ts-expect-error composite layer props
8094
8174
  pickable: true,
8095
8175
  data: { type: "object", value: null, async: true },
8096
8176
  // Graph props
8097
- graphLoader: JSONGraphLoader,
8098
- stylesheet: DEFAULT_GRAPH_LAYER_STYLESHEET,
8177
+ graphLoader: DEFAULT_GRAPH_LOADER,
8178
+ stylesheet: DEFAULT_GRAPH_LAYER_STYLESHEET_INPUT,
8099
8179
  nodeStyle: void 0,
8100
8180
  nodeEvents: {
8101
8181
  onMouseLeave: () => {
@@ -8128,8 +8208,33 @@ function isPlainObject(value) {
8128
8208
  return prototype === Object.prototype || prototype === null;
8129
8209
  }
8130
8210
 
8211
+ // dist/loaders/json-graph-loader.js
8212
+ var VERSION = true ? "9.2.0-beta.8" : "latest";
8213
+ var JSONGraphLoader = {
8214
+ dataType: null,
8215
+ batchType: null,
8216
+ name: "DOT Graph",
8217
+ id: "dot-graph",
8218
+ module: "graph-layers",
8219
+ version: VERSION,
8220
+ worker: false,
8221
+ extensions: ["json"],
8222
+ mimeTypes: ["application/json"],
8223
+ text: true,
8224
+ options: {
8225
+ "jsongraph": {}
8226
+ },
8227
+ parse: async (arrayBuffer, options) => {
8228
+ const text = new TextDecoder().decode(arrayBuffer);
8229
+ return Promise.resolve(JSONGraphLoader.parseTextSync(text, options));
8230
+ },
8231
+ parseTextSync: (text, options) => {
8232
+ throw new Error("JSONGraphLoader.parseTextSync not implemented");
8233
+ }
8234
+ };
8235
+
8131
8236
  // dist/loaders/dot-graph-loader.js
8132
- var VERSION2 = true ? "9.2.0-beta.5" : "latest";
8237
+ var VERSION2 = true ? "9.2.0-beta.8" : "latest";
8133
8238
  var DOTGraphLoader = {
8134
8239
  dataType: null,
8135
8240
  batchType: null,