venue-js 1.0.0-2 → 1.0.0-next.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/dist/index.d.mts CHANGED
@@ -655,6 +655,7 @@ interface VenueDataClient {
655
655
  projectId: string;
656
656
  queryClient: QueryClient;
657
657
  registerObserver: (featureType: FeatureType, refetchInterval: number) => QueryObserver;
658
+ destroyObserver: (featureType: FeatureType) => void;
658
659
  destroyObservers: () => void;
659
660
  createFilterByTypeQueryOptions: <T extends FeatureType = FeatureType>(featureType: T, params: FilterParams, options: FeatureQueryOptions) => EnsureQueryDataOptions<FeatureResponseMap[T][] | FeaturePopulatedResponseMap[T][]>;
660
661
  createFindByIdQueryOptions: <T extends FeatureType = FeatureType>(featureType: T, id: string, params: FindParams, options: FeatureQueryOptions) => EnsureQueryDataOptions<FeatureResponseMap[T] | FeaturePopulatedResponseMap[T]>;
package/dist/index.d.ts CHANGED
@@ -655,6 +655,7 @@ interface VenueDataClient {
655
655
  projectId: string;
656
656
  queryClient: QueryClient;
657
657
  registerObserver: (featureType: FeatureType, refetchInterval: number) => QueryObserver;
658
+ destroyObserver: (featureType: FeatureType) => void;
658
659
  destroyObservers: () => void;
659
660
  createFilterByTypeQueryOptions: <T extends FeatureType = FeatureType>(featureType: T, params: FilterParams, options: FeatureQueryOptions) => EnsureQueryDataOptions<FeatureResponseMap[T][] | FeaturePopulatedResponseMap[T][]>;
660
661
  createFindByIdQueryOptions: <T extends FeatureType = FeatureType>(featureType: T, id: string, params: FindParams, options: FeatureQueryOptions) => EnsureQueryDataOptions<FeatureResponseMap[T] | FeaturePopulatedResponseMap[T]>;
package/dist/index.js CHANGED
@@ -481,23 +481,33 @@ var getDataClient = (options) => {
481
481
  };
482
482
  const populator = createPopulator({ internalFindById, internalFilterByType });
483
483
  const registerObserver = (featureType, refetchInterval) => {
484
- let observer = observers.get(featureType);
485
- if (!observer) {
486
- const options2 = createDeliveryApiQueryOptions(featureType);
487
- observer = new import_query_core.QueryObserver(queryClient, {
488
- ...options2,
489
- refetchInterval
490
- });
491
- observers.set(featureType, observer);
492
- } else {
493
- console.warn(
494
- `An observer for featureType ${featureType} already exists, fail to register new one`
495
- );
484
+ if (observers.has(featureType)) {
485
+ console.warn(`Observer for ${featureType} already exists`);
486
+ const record = observers.get(featureType);
487
+ return record.observer;
496
488
  }
489
+ const options2 = createDeliveryApiQueryOptions(featureType);
490
+ const observer = new import_query_core.QueryObserver(queryClient, {
491
+ ...options2,
492
+ refetchInterval
493
+ });
494
+ const unsubscribe = observer.subscribe(() => {
495
+ console.log(`[venue-js] Listening to ${featureType} changes (interval = ${refetchInterval}ms)`);
496
+ });
497
+ observers.set(featureType, { observer, unsubscribe });
497
498
  return observer;
498
499
  };
500
+ const destroyObserver = (featureType) => {
501
+ const record = observers.get(featureType);
502
+ if (!record) return;
503
+ record.unsubscribe();
504
+ observers.delete(featureType);
505
+ };
499
506
  const destroyObservers = () => {
500
- observers.forEach((o) => o.destroy());
507
+ observers.forEach(({ observer, unsubscribe }) => {
508
+ unsubscribe();
509
+ observer.destroy();
510
+ });
501
511
  observers.clear();
502
512
  };
503
513
  const createFilterByTypeQueryOptions = (featureType, params = {}, options2 = {}) => ({
@@ -537,6 +547,7 @@ var getDataClient = (options) => {
537
547
  projectId,
538
548
  queryClient,
539
549
  registerObserver,
550
+ destroyObserver,
540
551
  destroyObservers,
541
552
  createFilterByTypeQueryOptions,
542
553
  createFindByIdQueryOptions,
@@ -3371,9 +3382,11 @@ var createSVGPathFromMarkerSymbol2 = (style) => {
3371
3382
  fill = "#000000"
3372
3383
  } = style;
3373
3384
  const scale2 = markerWidth / 24;
3385
+ const strokeWidth = 2;
3386
+ const halfStrokeWidth = 0.5 * strokeWidth;
3374
3387
  if (Array.isArray(markerPath)) {
3375
3388
  return markerPath.map(
3376
- ({ path, fill: fill2 }) => `<path d="${path}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill2}"/>`
3389
+ ({ path, fill: fill2 }) => `<path d="${path}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill2}" stroke="#ffffff" stroke-width="${strokeWidth}" />`
3377
3390
  );
3378
3391
  }
3379
3392
  return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill}" />`;
@@ -3388,7 +3401,6 @@ var createSpriteMaterialByLabelSymbol2 = (labelSymbol) => {
3388
3401
  const baseSVG = createSVGPathFromMarkerSymbol2(base);
3389
3402
  const iconSVG = icon ? createSVGPathFromMarkerSymbol2(icon) : "";
3390
3403
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${viewBoxDimension}" height="${viewBoxDimension}">${baseSVG}${iconSVG}</svg>`;
3391
- console.log(svg);
3392
3404
  const textureLoader = new import_three7.TextureLoader();
3393
3405
  const scaleFactor = 200 / 24;
3394
3406
  svgToDataURL(svg, scaleFactor).then((png) => {
@@ -3478,14 +3490,12 @@ var Element3DRenderer = class extends EventTarget {
3478
3490
  markerType: "path",
3479
3491
  markerPath: [
3480
3492
  {
3481
- path: "M21.75 0H0.25V21.5H8.35L11.3 24L14.2 21.5H21.75V0Z",
3493
+ path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3482
3494
  fill: "#ff0000"
3483
3495
  }
3484
3496
  ],
3485
3497
  markerPathWidth: 24,
3486
- markerPathHeight: 24,
3487
- markerWidth: 30,
3488
- markerHeight: 30
3498
+ markerPathHeight: 24
3489
3499
  };
3490
3500
  const markerSymbol = {
3491
3501
  markerType: "path",