@geoalgeria/buses 2.2.2 → 2.3.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.
@@ -20,7 +20,7 @@
20
20
  "box": "35.290352 0.078075 36.817264 5.495723"
21
21
  }
22
22
  },
23
- "variableMeasured": "1787 records, 18 wilayas",
23
+ "variableMeasured": "1783 records, 18 wilayas",
24
24
  "distribution": [
25
25
  {
26
26
  "@type": "DataDownload",
@@ -53,7 +53,7 @@
53
53
  "contentUrl": "https://cdn.jsdelivr.net/npm/@geoalgeria/buses/data/geojson/stations.geojson"
54
54
  }
55
55
  ],
56
- "dateModified": "2026-09-27",
56
+ "dateModified": "2026-11-19",
57
57
  "url": "https://geoalgeria.com",
58
58
  "sameAs": "https://github.com/yasserstudio/geoalgeria",
59
59
  "citation": [
package/index.js CHANGED
@@ -1,10 +1,7 @@
1
1
  // @geoalgeria/buses: loaders for Algeria's reviewed urban/suburban bus networks.
2
- import { readFileSync } from "node:fs";
3
- import { fileURLToPath } from "node:url";
4
- import { dirname, join } from "node:path";
5
-
6
- const DATA = join(dirname(fileURLToPath(import.meta.url)), "data");
7
- const load = (p) => JSON.parse(readFileSync(join(DATA, p), "utf-8"));
2
+ // `load` reaches each data file by a literal path a bundler can follow; a path
3
+ // built at runtime builds fine and then throws ENOENT (loaders.cjs, #290).
4
+ import load from "./loaders.cjs";
8
5
 
9
6
  export const lines = () => load("lines.json"); // urban bus lines (v1: ETUSA/Alger)
10
7
  export const lineById = (id) => lines().find((l) => l.id === id) ?? null;
package/loaders.cjs ADDED
@@ -0,0 +1,38 @@
1
+ // GENERATED by scripts/generate-loaders.mjs. Do not edit by hand.
2
+ //
3
+ // One loader per data file, each with a literal path a bundler can follow. The
4
+ // package is ESM, where there is no lazy synchronous JSON import, so the
5
+ // requires live here in CommonJS: `index.js` imports this as its `load`
6
+ // helper and its call sites are unchanged. A `require` inside a function stays
7
+ // lazy, so importing @geoalgeria/buses still parses nothing.
8
+ //
9
+ // Why, and what each bundler does with it: scripts/check-bundlers.mjs
10
+ // (issues #276 and #290).
11
+
12
+ const LOADERS = {
13
+ "directions.json": () => require("./data/directions.json"),
14
+ "lines.json": () => require("./data/lines.json"),
15
+ "metadata.json": () => require("./data/metadata.json"),
16
+ "operators.json": () => require("./data/operators.json"),
17
+ "shapes.json": () => require("./data/shapes.json"),
18
+ "station-memberships.json": () => require("./data/station-memberships.json"),
19
+ "stations.json": () => require("./data/stations.json"),
20
+ };
21
+
22
+ /**
23
+ * Read one of this package's data files.
24
+ *
25
+ * Every call answers with a fresh copy, exactly as the `JSON.parse` this
26
+ * replaced did, so a caller that sorts or splices what it gets cannot reorder
27
+ * another caller's data. The copy is what makes that true: the `require` cache
28
+ * holds one parse of the file, and a bundler inlines it as a single shared
29
+ * object, so handing that out directly would be shared mutable state.
30
+ *
31
+ * @param {string} file file name under `data/`, e.g. "directions.json"
32
+ * @returns {any} the parsed JSON
33
+ */
34
+ module.exports = function load(file) {
35
+ const loader = LOADERS[file];
36
+ if (!loader) throw new Error(`@geoalgeria/buses: no data file "${file}" in this package`);
37
+ return structuredClone(loader());
38
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@geoalgeria/buses",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
- "description": "Reviewed urban and suburban bus data for Algeria: 184 Lines, 76 shapes, 128 Directions and 1,603 Stations across 16 Operators.",
5
+ "description": "Reviewed urban and suburban bus data for Algeria: 184 Lines, 76 shapes, 128 Directions and 1,599 Stations across 16 Operators.",
6
6
  "main": "index.js",
7
7
  "types": "types/index.d.ts",
8
8
  "exports": {
@@ -19,6 +19,7 @@
19
19
  "data/**/*.csv",
20
20
  "data/**/*.geojson",
21
21
  "types/",
22
+ "loaders.cjs",
22
23
  "index.js"
23
24
  ],
24
25
  "scripts": {
package/types/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export type GeoPrecision = "exact" | "approximate" | null;
2
2
  export type SourceKey = "wikipedia" | "osm" | "wikipedia+osm" | "etus-tiaret" | "etusto" | "etus-bejaia" | "etus-msila" | "etus-sidi-bel-abbes" | "etus-setif" | "etus-setif+osm" | "etus-ain-defla" | "etus-ain-defla+osm" | "etus-annaba" | "etus-tlemcen" | "eto-oran" | "etus-oeb" | "etus-c-constantine" | "etus-skikda" | "etul-laghouat";
3
3
  export type RouteColor = "blue" | "green" | "orange" | "purple";
4
- export type SequenceStatus = "osm_member_order_unvalidated";
4
+ /** ADR 0005 ladder. A minor release may add values, such as `operator_sequence` for order from an Operator's published stop list. */
5
+ export type SequenceStatus = "osm_member_order_unvalidated" | "osm_member_order_consistent" | "osm_member_order_inconsistent";
5
6
  export type ServicePeriod = "regular" | "friday" | "saturday";
6
7
  export type ServiceDay = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
7
8
 
@@ -65,6 +66,12 @@ export interface BusLine {
65
66
  osm_relation_ids: number[];
66
67
  source_refs: SourceKey[];
67
68
  source_url?: string | null;
69
+ /**
70
+ * Date (YYYY-MM-DD) of the official Operator source that states the Line: the
71
+ * document's own date when it carries one, else the day it was read or supplied.
72
+ * Null when only Wikipedia or OpenStreetMap name the Line. OSM edits never move it.
73
+ */
74
+ last_confirmed: string | null;
68
75
  }
69
76
 
70
77
  export interface BusStation {
@@ -125,6 +132,8 @@ export interface BusShape {
125
132
  terminus2: string | null;
126
133
  terminus2_fr?: string;
127
134
  terminus2_ar?: string;
135
+ /** The Line's `last_confirmed`, copied so a map feature carries it. */
136
+ last_confirmed: string | null;
128
137
  source: "osm";
129
138
  osm_relation_ids: number[];
130
139
  geometry: MultiLineStringGeometry;