@expofp/resolve 3.0.0-alpha.3
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.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/lib/resolve.d.ts +2 -0
- package/dist/lib/resolve.js +3 -0
- package/dist/resolve.d.ts +3 -0
- package/dist/resolve.js +17 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +1 -0
- package/package.json +31 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { importJsonModule } from '@expofp/utils';
|
|
2
|
+
const globalResolveCache = new Map();
|
|
3
|
+
// TODO: use json pointer lib to resolve within documents
|
|
4
|
+
export async function resolve(data, options) {
|
|
5
|
+
const importOptions = {
|
|
6
|
+
fetchCache: options?.refCache || globalResolveCache,
|
|
7
|
+
forceFetch: options?.forceFetch,
|
|
8
|
+
signal: options?.signal,
|
|
9
|
+
importCallback: options?.importCallback,
|
|
10
|
+
};
|
|
11
|
+
if (typeof data !== 'object' || data === null || !('$ref' in data)) {
|
|
12
|
+
return data;
|
|
13
|
+
// throw new Error('resolve: data is not a $ref object');
|
|
14
|
+
}
|
|
15
|
+
const module = await importJsonModule(data.$ref, importOptions);
|
|
16
|
+
return module;
|
|
17
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Ref<T> = {
|
|
2
|
+
$ref: string;
|
|
3
|
+
__type?: T;
|
|
4
|
+
};
|
|
5
|
+
export type RefTarget<R> = R extends Ref<infer T> ? T : never;
|
|
6
|
+
export interface ResolveOptions {
|
|
7
|
+
forceFetch?: boolean;
|
|
8
|
+
refCache?: Map<string, Promise<unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Callback invoked when a URL is fetched or imported.
|
|
11
|
+
*/
|
|
12
|
+
importCallback?: (url: string) => void;
|
|
13
|
+
signal?: AbortSignal | null;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expofp/resolve",
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "ExpoFP SDK internal: asset and resource resolution",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"@expofp/source": "./src/index.ts",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"!**/*.tsbuildinfo",
|
|
25
|
+
"!**/*.map"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tslib": "^2.3.0",
|
|
29
|
+
"@expofp/utils": "3.0.0-alpha.3"
|
|
30
|
+
}
|
|
31
|
+
}
|