@comapeo/map-server 1.0.0-pre.5 → 1.0.0-pre.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAW/C,KAAK,cAAc,GAAG,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG;IAC7D,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CACpC,CAAA;AAID,qBAAa,OAAO;;IAKnB,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;gBAExB,EACX,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,OAAO,EACP,aAAa,GACb,EAAE,cAAc;IAmBjB,wBAAwB;IAGxB,UAAU;mBA/Ba,UAAU;mBAAa,UAAU;;IAkClD,UAAU,CAAC,KAAK,EAAE,MAAM;;;;;;;;;IA2B9B,SAAS,CAAC,KAAK,EAAE,MAAM;IAavB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAO/B,cAAc,CAAC,UAAU,CAAC;IAEhC;;;;;;;;OAQG;IACH,uBAAuB,CAAC,KAAK,EAAE,MAAM;IAmDrC;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM;CAuB7B"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAW/C,KAAK,cAAc,GAAG,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG;IAC7D,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CACpC,CAAA;AAID,qBAAa,OAAO;;IAKnB,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;gBAExB,EACX,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,OAAO,EACP,aAAa,GACb,EAAE,cAAc;IAmBjB,wBAAwB;IAGxB,UAAU;mBA/Ba,UAAU;mBAAa,UAAU;;IAkClD,UAAU,CAAC,KAAK,EAAE,MAAM;;;;;;;;;IA2B9B,SAAS,CAAC,KAAK,EAAE,MAAM;IAavB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAO/B,cAAc,CAAC,UAAU,CAAC;IAEhC;;;;;;;;OAQG;IACH,uBAAuB,CAAC,KAAK,EAAE,MAAM;IAoDrC;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM;CAuB7B"}
package/dist/context.js CHANGED
@@ -129,13 +129,14 @@ export class Context {
129
129
  const existingReaderPromise = this.#mapReaders.get(mapId);
130
130
  if (existingReaderPromise) {
131
131
  const existingReader = await existingReaderPromise;
132
+ await existingReader.opened().catch(noop); // Ensure reader is fully opened before closing
132
133
  await existingReader.close().catch(noop);
133
134
  }
134
- await fsPromises.cp(tempPath, mapFileUrl, { force: true });
135
+ await fsPromises.rename(tempPath, mapFileUrl);
135
136
  return new Reader(fileURLToPath(mapFileUrl));
136
137
  })();
137
138
  this.#mapReaders.set(mapId, readerPromise);
138
- // Wait for the file copy to complete before closing the stream
139
+ // Wait for the file rename to complete before closing the stream
139
140
  await readerPromise;
140
141
  },
141
142
  async abort(err) {
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export type ListenOptions = {
17
17
  localPort?: number;
18
18
  remotePort?: number;
19
19
  };
20
+ export type MapServer = ReturnType<typeof createServer>;
20
21
  export declare function createServer(options: ServerOptions): {
21
22
  listen(opts?: ListenOptions): Promise<{
22
23
  localPort: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAElE,YAAY,EACX,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EACX,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,MAAM,MAAM,aAAa,GAAG;IAC3B,qBAAqB,EAAE,MAAM,GAAG,GAAG,CAAA;IACnC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAA;IAC3B,eAAe,EAAE,MAAM,GAAG,GAAG,CAAA;IAC7B,OAAO,CAAC,EAAE;QACT,SAAS,EAAE,UAAU,CAAA;QACrB,SAAS,EAAE,UAAU,CAAA;KACrB,CAAA;CACD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAOD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa;kBA+C9B,aAAa;;;;;EA+BjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAElE,YAAY,EACX,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EACX,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,MAAM,MAAM,aAAa,GAAG;IAC3B,qBAAqB,EAAE,MAAM,GAAG,GAAG,CAAA;IACnC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAA;IAC3B,eAAe,EAAE,MAAM,GAAG,GAAG,CAAA;IAC7B,OAAO,CAAC,EAAE;QACT,SAAS,EAAE,UAAU,CAAA;QACrB,SAAS,EAAE,UAAU,CAAA;KACrB,CAAA;CACD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAOD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa;kBA+C9B,aAAa;;;;;EA+BjC"}
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@comapeo/map-server",
3
- "version": "1.0.0-pre.5",
3
+ "version": "1.0.0-pre.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
8
8
  "default": "./dist/index.js"
9
+ },
10
+ "./errors.js": {
11
+ "types": "./dist/lib/errors.d.ts",
12
+ "default": "./dist/lib/errors.js"
13
+ },
14
+ "./constants.js": {
15
+ "types": "./dist/lib/constants.d.ts",
16
+ "default": "./dist/lib/constants.js"
9
17
  }
10
18
  },
11
19
  "scripts": {
@@ -71,7 +79,7 @@
71
79
  "p-defer": "^4.0.1",
72
80
  "p-mutex": "^0.1.0",
73
81
  "secret-stream-http": "^1.0.1",
74
- "styled-map-package": "^4.0.1",
82
+ "styled-map-package": "^4.1.0",
75
83
  "typebox": "^1.0.61",
76
84
  "typed-event-target": "^3.4.0"
77
85
  },
package/src/context.ts CHANGED
@@ -153,13 +153,14 @@ export class Context {
153
153
  const existingReaderPromise = this.#mapReaders.get(mapId)
154
154
  if (existingReaderPromise) {
155
155
  const existingReader = await existingReaderPromise
156
+ await existingReader.opened().catch(noop) // Ensure reader is fully opened before closing
156
157
  await existingReader.close().catch(noop)
157
158
  }
158
- await fsPromises.cp(tempPath, mapFileUrl, { force: true })
159
+ await fsPromises.rename(tempPath, mapFileUrl)
159
160
  return new Reader(fileURLToPath(mapFileUrl))
160
161
  })()
161
162
  this.#mapReaders.set(mapId, readerPromise)
162
- // Wait for the file copy to complete before closing the stream
163
+ // Wait for the file rename to complete before closing the stream
163
164
  await readerPromise
164
165
  },
165
166
  async abort(err) {
package/src/index.ts CHANGED
@@ -51,6 +51,8 @@ type ListenResult = {
51
51
  remotePort: number
52
52
  }
53
53
 
54
+ export type MapServer = ReturnType<typeof createServer>
55
+
54
56
  export function createServer(options: ServerOptions) {
55
57
  validateOptions(options)
56
58
  if (!options.keyPair) {