@dunguel/expo-geo-parser 0.1.0 → 0.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.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ⚠️ This package is currently experimental and will have issues. Install on your own risk.
2
+
1
3
  # expo-geo-parser
2
4
 
3
5
  A high-performance Expo native module for parsing geospatial files like KML, KMZ, and other formats, extracting polygons, markers, and spatial data efficiently on iOS and Android.
@@ -1,2 +1,31 @@
1
- export type ExpoGeoParserEvents = {};
1
+ export type GeoFileType = "kml" | "kmz" | "zip" | "geojson" | "json" | "unknown";
2
+ export type File = {
3
+ uri: string;
4
+ fileName?: string | null;
5
+ extension?: string | null;
6
+ type: GeoFileType;
7
+ uti?: string | null;
8
+ };
9
+ export type Feature = {
10
+ type: "Feature";
11
+ id?: string | number;
12
+ geometry: Geometry;
13
+ properties: Record<string, unknown>;
14
+ };
15
+ export type Geometry = {
16
+ type: string;
17
+ coordinates?: number[][];
18
+ geometries?: Geometry[];
19
+ };
20
+ export type FeatureCollection = {
21
+ type: "FeatureCollection";
22
+ name?: string;
23
+ description?: string;
24
+ sourceType?: GeoFileType;
25
+ features: Feature[];
26
+ };
27
+ export type ParseFeaturesEvent = {
28
+ features: Feature[];
29
+ isLast: boolean;
30
+ };
2
31
  //# sourceMappingURL=ExpoGeoParser.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParser.types.d.ts","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"ExpoGeoParser.types.d.ts","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParser.types.js","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ExpoGeoParserEvents = {};\n"]}
1
+ {"version":3,"file":"ExpoGeoParser.types.js","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"","sourcesContent":["export type GeoFileType = \"kml\" | \"kmz\" | \"zip\" | \"geojson\" | \"json\" | \"unknown\";\n\nexport type File = {\n uri: string;\n fileName?: string | null;\n extension?: string | null;\n type: GeoFileType;\n uti?: string | null;\n};\n\nexport type Feature = {\n type: \"Feature\";\n id?: string | number;\n geometry: Geometry;\n properties: Record<string, unknown>;\n};\n\nexport type Geometry = {\n type: string;\n coordinates?: number[][];\n geometries?: Geometry[];\n};\n\nexport type FeatureCollection = {\n type: \"FeatureCollection\";\n name?: string;\n description?: string;\n sourceType?: GeoFileType;\n features: Feature[];\n};\n\nexport type ParseFeaturesEvent = {\n features: Feature[];\n isLast: boolean;\n};\n"]}
@@ -1,37 +1,9 @@
1
1
  import { NativeModule } from "expo";
2
- export type GeoFileType = "kml" | "kmz" | "zip" | "geojson" | "json" | "unknown";
3
- export type DetectedFileType = {
4
- uri: string;
5
- fileName?: string | null;
6
- extension?: string | null;
7
- type: GeoFileType;
8
- uti?: string | null;
9
- };
10
- export type GeoJSONGeometry = {
11
- type: string;
12
- coordinates?: unknown;
13
- geometries?: GeoJSONGeometry[];
14
- };
15
- export type GeoJSONFeature = {
16
- type: "Feature";
17
- id?: string | number;
18
- geometry: GeoJSONGeometry;
19
- properties: Record<string, unknown>;
20
- };
21
- export type GeoJSONFeatureCollection = {
22
- type: "FeatureCollection";
23
- name?: string;
24
- description?: string;
25
- sourceType?: GeoFileType;
26
- features: GeoJSONFeature[];
27
- };
28
- export type ParseFeaturesEvent = {
29
- features: GeoJSONFeature[];
30
- isLast: boolean;
31
- };
2
+ import type { File, FeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParser.types";
3
+ export type { GeoFileType, File, Feature, Geometry, FeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParser.types";
32
4
  declare class ExpoGeoParserModule extends NativeModule {
33
- detectFileType(uri: string): DetectedFileType;
34
- parseFile(uri: string): Promise<Omit<GeoJSONFeatureCollection, "features">>;
5
+ detectFileType(uri: string): File;
6
+ parseFile(uri: string): Promise<Omit<FeatureCollection, "features">>;
35
7
  addListener(event: "onParseFeatures", listener: (event: ParseFeaturesEvent) => void): {
36
8
  remove: () => void;
37
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParserModule.d.ts","sourceRoot":"","sources":["../src/ExpoGeoParserModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IACpD,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAC7C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;IAC3E,WAAW,CACT,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC5C;QAAE,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE;CAC1B;;AAED,wBAAyE"}
1
+ {"version":3,"file":"ExpoGeoParserModule.d.ts","sourceRoot":"","sources":["../src/ExpoGeoParserModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEzF,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEzH,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IACpD,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACjC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IACpE,WAAW,CACT,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC5C;QAAE,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE;CAC1B;;AAED,wBAAyE"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParserModule.js","sourceRoot":"","sources":["../src/ExpoGeoParserModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA+CzD,eAAe,mBAAmB,CAAsB,eAAe,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nexport type GeoFileType = \"kml\" | \"kmz\" | \"zip\" | \"geojson\" | \"json\" | \"unknown\";\n\nexport type DetectedFileType = {\n uri: string;\n fileName?: string | null;\n extension?: string | null;\n type: GeoFileType;\n uti?: string | null;\n};\n\nexport type GeoJSONGeometry = {\n type: string;\n coordinates?: unknown;\n geometries?: GeoJSONGeometry[];\n};\n\nexport type GeoJSONFeature = {\n type: \"Feature\";\n id?: string | number;\n geometry: GeoJSONGeometry;\n properties: Record<string, unknown>;\n};\n\nexport type GeoJSONFeatureCollection = {\n type: \"FeatureCollection\";\n name?: string;\n description?: string;\n sourceType?: GeoFileType;\n features: GeoJSONFeature[];\n};\n\nexport type ParseFeaturesEvent = {\n features: GeoJSONFeature[];\n isLast: boolean;\n};\n\ndeclare class ExpoGeoParserModule extends NativeModule {\n detectFileType(uri: string): DetectedFileType;\n parseFile(uri: string): Promise<Omit<GeoJSONFeatureCollection, \"features\">>;\n addListener(\n event: \"onParseFeatures\",\n listener: (event: ParseFeaturesEvent) => void\n ): { remove: () => void };\n}\n\nexport default requireNativeModule<ExpoGeoParserModule>(\"ExpoGeoParser\");\n"]}
1
+ {"version":3,"file":"ExpoGeoParserModule.js","sourceRoot":"","sources":["../src/ExpoGeoParserModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAczD,eAAe,mBAAmB,CAAsB,eAAe,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\nimport type { File, FeatureCollection, ParseFeaturesEvent } from \"./ExpoGeoParser.types\";\n\nexport type { GeoFileType, File, Feature, Geometry, FeatureCollection, ParseFeaturesEvent } from \"./ExpoGeoParser.types\";\n\ndeclare class ExpoGeoParserModule extends NativeModule {\n detectFileType(uri: string): File;\n parseFile(uri: string): Promise<Omit<FeatureCollection, \"features\">>;\n addListener(\n event: \"onParseFeatures\",\n listener: (event: ParseFeaturesEvent) => void\n ): { remove: () => void };\n}\n\nexport default requireNativeModule<ExpoGeoParserModule>(\"ExpoGeoParser\");\n"]}
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { GeoJSONFeatureCollection } from "./ExpoGeoParserModule";
1
+ import type { FeatureCollection } from "./ExpoGeoParserModule";
2
2
  export { default } from "./ExpoGeoParserModule";
3
3
  export * from "./ExpoGeoParserModule";
4
- export declare function parseFile(uri: string): Promise<GeoJSONFeatureCollection>;
4
+ export declare function parseFile(uri: string): Promise<FeatureCollection>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,wBAAwB,EAAsB,MAAM,uBAAuB,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC;AAEtC,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqB9E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,iBAAiB,EAAsB,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC;AAEtC,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsBvE"}
package/build/index.js CHANGED
@@ -4,20 +4,20 @@ export * from "./ExpoGeoParserModule";
4
4
  export async function parseFile(uri) {
5
5
  const features = [];
6
6
  let resolveDone;
7
- const allReceived = new Promise(r => { resolveDone = r; });
8
- const sub = NativeModule.addListener("onParseFeatures", (e) => {
9
- for (const f of e.features)
10
- features.push(f);
11
- if (e.isLast)
7
+ const allReceived = new Promise(received => { resolveDone = received; });
8
+ const subscription = NativeModule.addListener("onParseFeatures", (event) => {
9
+ for (const feature of event.features)
10
+ features.push(feature);
11
+ if (event.isLast)
12
12
  resolveDone();
13
13
  });
14
14
  try {
15
- const meta = await NativeModule.parseFile(uri);
15
+ const result = await NativeModule.parseFile(uri);
16
16
  await allReceived;
17
- return { ...meta, features };
17
+ return { ...result, features };
18
18
  }
19
19
  finally {
20
- sub.remove();
20
+ subscription.remove();
21
21
  }
22
22
  }
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IACzC,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,IAAI,WAAwB,CAAC;IAC7B,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAClC,iBAAiB,EACjB,CAAC,CAAqB,EAAE,EAAE;QACxB,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,CAAC,MAAM;YAAE,WAAW,EAAE,CAAC;IAC9B,CAAC,CACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,WAAW,CAAC;QAClB,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;YAAS,CAAC;QACT,GAAG,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import NativeModule from \"./ExpoGeoParserModule\";\nimport type { GeoJSONFeature, GeoJSONFeatureCollection, ParseFeaturesEvent } from \"./ExpoGeoParserModule\";\n\nexport { default } from \"./ExpoGeoParserModule\";\nexport * from \"./ExpoGeoParserModule\";\n\nexport async function parseFile(uri: string): Promise<GeoJSONFeatureCollection> {\n const features: GeoJSONFeature[] = [];\n\n let resolveDone!: () => void;\n const allReceived = new Promise<void>(r => { resolveDone = r; });\n\n const sub = NativeModule.addListener(\n \"onParseFeatures\",\n (e: ParseFeaturesEvent) => {\n for (const f of e.features) features.push(f);\n if (e.isLast) resolveDone();\n }\n );\n\n try {\n const meta = await NativeModule.parseFile(uri);\n await allReceived;\n return { ...meta, features };\n } finally {\n sub.remove();\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IACzC,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,IAAI,WAAwB,CAAC;IAC7B,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,QAAQ,CAAC,EAAE,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/E,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,CAC3C,iBAAiB,EACjB,CAAC,KAAyB,EAAE,EAAE;QAC5B,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ;YAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,MAAM;YAAE,WAAW,EAAE,CAAC;IAClC,CAAC,CACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,WAAW,CAAC;QAElB,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;AACH,CAAC","sourcesContent":["import NativeModule from \"./ExpoGeoParserModule\";\nimport type { Feature, FeatureCollection, ParseFeaturesEvent } from \"./ExpoGeoParserModule\";\nexport { default } from \"./ExpoGeoParserModule\";\nexport * from \"./ExpoGeoParserModule\";\n\nexport async function parseFile(uri: string): Promise<FeatureCollection> {\n const features: Feature[] = [];\n\n let resolveDone!: () => void;\n const allReceived = new Promise<void>(received => { resolveDone = received; });\n\n const subscription = NativeModule.addListener(\n \"onParseFeatures\",\n (event: ParseFeaturesEvent) => {\n for (const feature of event.features) features.push(feature);\n if (event.isLast) resolveDone();\n }\n );\n\n try {\n const result = await NativeModule.parseFile(uri);\n await allReceived;\n\n return { ...result, features };\n } finally {\n subscription.remove();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunguel/expo-geo-parser",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "A high-performance Expo native module for parsing geospatial files like KML, KMZ, and other formats, extracting polygons, markers, and spatial data efficiently on iOS and Android.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1 +1,35 @@
1
- export type ExpoGeoParserEvents = {};
1
+ export type GeoFileType = "kml" | "kmz" | "zip" | "geojson" | "json" | "unknown";
2
+
3
+ export type File = {
4
+ uri: string;
5
+ fileName?: string | null;
6
+ extension?: string | null;
7
+ type: GeoFileType;
8
+ uti?: string | null;
9
+ };
10
+
11
+ export type Feature = {
12
+ type: "Feature";
13
+ id?: string | number;
14
+ geometry: Geometry;
15
+ properties: Record<string, unknown>;
16
+ };
17
+
18
+ export type Geometry = {
19
+ type: string;
20
+ coordinates?: number[][];
21
+ geometries?: Geometry[];
22
+ };
23
+
24
+ export type FeatureCollection = {
25
+ type: "FeatureCollection";
26
+ name?: string;
27
+ description?: string;
28
+ sourceType?: GeoFileType;
29
+ features: Feature[];
30
+ };
31
+
32
+ export type ParseFeaturesEvent = {
33
+ features: Feature[];
34
+ isLast: boolean;
35
+ };
@@ -1,44 +1,11 @@
1
1
  import { NativeModule, requireNativeModule } from "expo";
2
+ import type { File, FeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParser.types";
2
3
 
3
- export type GeoFileType = "kml" | "kmz" | "zip" | "geojson" | "json" | "unknown";
4
-
5
- export type DetectedFileType = {
6
- uri: string;
7
- fileName?: string | null;
8
- extension?: string | null;
9
- type: GeoFileType;
10
- uti?: string | null;
11
- };
12
-
13
- export type GeoJSONGeometry = {
14
- type: string;
15
- coordinates?: unknown;
16
- geometries?: GeoJSONGeometry[];
17
- };
18
-
19
- export type GeoJSONFeature = {
20
- type: "Feature";
21
- id?: string | number;
22
- geometry: GeoJSONGeometry;
23
- properties: Record<string, unknown>;
24
- };
25
-
26
- export type GeoJSONFeatureCollection = {
27
- type: "FeatureCollection";
28
- name?: string;
29
- description?: string;
30
- sourceType?: GeoFileType;
31
- features: GeoJSONFeature[];
32
- };
33
-
34
- export type ParseFeaturesEvent = {
35
- features: GeoJSONFeature[];
36
- isLast: boolean;
37
- };
4
+ export type { GeoFileType, File, Feature, Geometry, FeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParser.types";
38
5
 
39
6
  declare class ExpoGeoParserModule extends NativeModule {
40
- detectFileType(uri: string): DetectedFileType;
41
- parseFile(uri: string): Promise<Omit<GeoJSONFeatureCollection, "features">>;
7
+ detectFileType(uri: string): File;
8
+ parseFile(uri: string): Promise<Omit<FeatureCollection, "features">>;
42
9
  addListener(
43
10
  event: "onParseFeatures",
44
11
  listener: (event: ParseFeaturesEvent) => void
package/src/index.ts CHANGED
@@ -1,28 +1,28 @@
1
1
  import NativeModule from "./ExpoGeoParserModule";
2
- import type { GeoJSONFeature, GeoJSONFeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParserModule";
3
-
2
+ import type { Feature, FeatureCollection, ParseFeaturesEvent } from "./ExpoGeoParserModule";
4
3
  export { default } from "./ExpoGeoParserModule";
5
4
  export * from "./ExpoGeoParserModule";
6
5
 
7
- export async function parseFile(uri: string): Promise<GeoJSONFeatureCollection> {
8
- const features: GeoJSONFeature[] = [];
6
+ export async function parseFile(uri: string): Promise<FeatureCollection> {
7
+ const features: Feature[] = [];
9
8
 
10
9
  let resolveDone!: () => void;
11
- const allReceived = new Promise<void>(r => { resolveDone = r; });
10
+ const allReceived = new Promise<void>(received => { resolveDone = received; });
12
11
 
13
- const sub = NativeModule.addListener(
12
+ const subscription = NativeModule.addListener(
14
13
  "onParseFeatures",
15
- (e: ParseFeaturesEvent) => {
16
- for (const f of e.features) features.push(f);
17
- if (e.isLast) resolveDone();
14
+ (event: ParseFeaturesEvent) => {
15
+ for (const feature of event.features) features.push(feature);
16
+ if (event.isLast) resolveDone();
18
17
  }
19
18
  );
20
19
 
21
20
  try {
22
- const meta = await NativeModule.parseFile(uri);
21
+ const result = await NativeModule.parseFile(uri);
23
22
  await allReceived;
24
- return { ...meta, features };
23
+
24
+ return { ...result, features };
25
25
  } finally {
26
- sub.remove();
26
+ subscription.remove();
27
27
  }
28
28
  }