@gglib/content 0.6.2 → 0.8.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/LICENSE +7 -0
- package/Readme.md +11 -7
- package/dist/bundles/content.esm.js +1050 -0
- package/dist/bundles/content.esm.js.map +1 -0
- package/dist/content/src/AssetContainer.d.ts +18 -0
- package/dist/content/src/AssetContainer.d.ts.map +1 -0
- package/dist/content/src/AssetContainer.js +30 -0
- package/dist/content/src/AssetContainer.js.map +1 -0
- package/dist/content/src/AssetLoaderRegistry.d.ts +21 -0
- package/dist/content/src/AssetLoaderRegistry.d.ts.map +1 -0
- package/dist/content/src/AssetLoaderRegistry.js +28 -0
- package/dist/content/src/AssetLoaderRegistry.js.map +1 -0
- package/dist/content/src/AssetType.d.ts +13 -0
- package/dist/content/src/AssetType.d.ts.map +1 -0
- package/dist/content/src/AssetType.js +6 -0
- package/dist/content/src/AssetType.js.map +1 -0
- package/dist/content/src/AsyncExecutor.d.ts +63 -0
- package/dist/content/src/AsyncExecutor.d.ts.map +1 -0
- package/dist/content/src/AsyncExecutor.js +166 -0
- package/dist/content/src/AsyncExecutor.js.map +1 -0
- package/dist/content/src/ContentLoader.d.ts +266 -0
- package/dist/content/src/ContentLoader.d.ts.map +1 -0
- package/dist/content/src/ContentLoader.js +341 -0
- package/dist/content/src/ContentLoader.js.map +1 -0
- package/dist/content/src/ContentType.d.ts.map +1 -1
- package/dist/content/src/ContentType.js +6 -10
- package/dist/content/src/ContentType.js.map +1 -1
- package/dist/content/src/HttpClient.d.ts +48 -0
- package/dist/content/src/HttpClient.d.ts.map +1 -0
- package/dist/content/src/HttpClient.js +139 -0
- package/dist/content/src/HttpClient.js.map +1 -0
- package/dist/content/src/MaterialRegistry.d.ts +14 -0
- package/dist/content/src/MaterialRegistry.d.ts.map +1 -0
- package/dist/content/src/MaterialRegistry.js +24 -0
- package/dist/content/src/MaterialRegistry.js.map +1 -0
- package/dist/content/src/ResourceGraph.d.ts +54 -0
- package/dist/content/src/ResourceGraph.d.ts.map +1 -0
- package/dist/content/src/ResourceGraph.js +195 -0
- package/dist/content/src/ResourceGraph.js.map +1 -0
- package/dist/content/src/TextureLoader.d.ts +14 -0
- package/dist/content/src/TextureLoader.d.ts.map +1 -0
- package/dist/content/src/TextureLoader.js +70 -0
- package/dist/content/src/TextureLoader.js.map +1 -0
- package/dist/content/src/index.d.ts +8 -7
- package/dist/content/src/index.d.ts.map +1 -1
- package/dist/content/src/index.js +8 -7
- package/dist/content/src/index.js.map +1 -1
- package/dist/content/tsconfig.build.tsbuildinfo +1 -0
- package/dist/content/tsconfig.spec.tsbuildinfo +1 -0
- package/dist/stats.html +211 -170
- package/package.json +19 -8
- package/dist/bundles/content.umd.js +0 -713
- package/dist/bundles/content.umd.js.map +0 -1
- package/dist/content/src/ContentManager.d.ts +0 -153
- package/dist/content/src/ContentManager.d.ts.map +0 -1
- package/dist/content/src/ContentManager.js +0 -361
- package/dist/content/src/ContentManager.js.map +0 -1
- package/dist/content/src/ContentType.spec.d.ts +0 -2
- package/dist/content/src/ContentType.spec.d.ts.map +0 -1
- package/dist/content/src/ContentType.spec.js +0 -27
- package/dist/content/src/ContentType.spec.js.map +0 -1
- package/dist/content/src/Data.d.ts +0 -37
- package/dist/content/src/Data.d.ts.map +0 -1
- package/dist/content/src/Data.js +0 -34
- package/dist/content/src/Data.js.map +0 -1
- package/dist/content/src/Loader.d.ts +0 -69
- package/dist/content/src/Loader.d.ts.map +0 -1
- package/dist/content/src/Loader.js +0 -16
- package/dist/content/src/Loader.js.map +0 -1
- package/dist/content/src/Pipeline.d.ts +0 -38
- package/dist/content/src/Pipeline.d.ts.map +0 -1
- package/dist/content/src/Pipeline.js +0 -182
- package/dist/content/src/Pipeline.js.map +0 -1
- package/dist/content/src/Pipeline.spec.d.ts +0 -2
- package/dist/content/src/Pipeline.spec.d.ts.map +0 -1
- package/dist/content/src/Pipeline.spec.js +0 -121
- package/dist/content/src/Pipeline.spec.js.map +0 -1
- package/dist/content/src/PipelineContext.d.ts +0 -40
- package/dist/content/src/PipelineContext.d.ts.map +0 -1
- package/dist/content/src/PipelineContext.js +0 -2
- package/dist/content/src/PipelineContext.js.map +0 -1
- package/dist/content/src/symbols.d.ts +0 -2
- package/dist/content/src/symbols.d.ts.map +0 -1
- package/dist/content/src/symbols.js +0 -2
- package/dist/content/src/symbols.js.map +0 -1
- package/dist/content/src/utils.d.ts +0 -17
- package/dist/content/src/utils.d.ts.map +0 -1
- package/dist/content/src/utils.js +0 -42
- package/dist/content/src/utils.js.map +0 -1
- package/dist/content/tsconfig.tsbuildinfo +0 -2773
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { Pipeline } from './Pipeline';
|
|
3
|
-
var Model = Symbol('Model');
|
|
4
|
-
describe('Content.Loader', function () {
|
|
5
|
-
var loader;
|
|
6
|
-
var manager;
|
|
7
|
-
beforeEach(function () {
|
|
8
|
-
loader = new Pipeline();
|
|
9
|
-
loader.register({
|
|
10
|
-
input: '.json',
|
|
11
|
-
output: Object,
|
|
12
|
-
handle: function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13
|
-
var data;
|
|
14
|
-
return __generator(this, function (_a) {
|
|
15
|
-
switch (_a.label) {
|
|
16
|
-
case 0: return [4 /*yield*/, context.manager.download(context.source)];
|
|
17
|
-
case 1:
|
|
18
|
-
data = _a.sent();
|
|
19
|
-
return [2 /*return*/, JSON.parse(data.content)];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}); },
|
|
23
|
-
});
|
|
24
|
-
loader.register({
|
|
25
|
-
input: Object,
|
|
26
|
-
output: Model,
|
|
27
|
-
handle: function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
28
|
-
return __generator(this, function (_a) {
|
|
29
|
-
if (input.format === 'format1') {
|
|
30
|
-
return [2 /*return*/, input.format];
|
|
31
|
-
}
|
|
32
|
-
return [2 /*return*/];
|
|
33
|
-
});
|
|
34
|
-
}); },
|
|
35
|
-
});
|
|
36
|
-
loader.register({
|
|
37
|
-
input: Object,
|
|
38
|
-
output: Model,
|
|
39
|
-
handle: function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
-
return __generator(this, function (_a) {
|
|
41
|
-
if (input.format === 'format2') {
|
|
42
|
-
return [2 /*return*/, input.format];
|
|
43
|
-
}
|
|
44
|
-
return [2 /*return*/];
|
|
45
|
-
});
|
|
46
|
-
}); },
|
|
47
|
-
});
|
|
48
|
-
loader.register({
|
|
49
|
-
input: Object,
|
|
50
|
-
output: Model,
|
|
51
|
-
handle: function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
if (input.format === 'format3') {
|
|
54
|
-
return [2 /*return*/, input.format];
|
|
55
|
-
}
|
|
56
|
-
return [2 /*return*/];
|
|
57
|
-
});
|
|
58
|
-
}); },
|
|
59
|
-
});
|
|
60
|
-
var downloads = {
|
|
61
|
-
'url/format1.json': { content: '{ "format": "format1" }' },
|
|
62
|
-
'url/format2.json': { content: '{ "format": "format2" }' },
|
|
63
|
-
'url/format3.json': { content: '{ "format": "format3" }' },
|
|
64
|
-
};
|
|
65
|
-
manager = {
|
|
66
|
-
download: function (source) { return Promise.resolve(downloads[source]); },
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
it('takes a fallback route if a loader returns null', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var result;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0: return [4 /*yield*/, Pipeline.run({
|
|
74
|
-
manager: manager,
|
|
75
|
-
source: 'url/format1.json',
|
|
76
|
-
target: Model,
|
|
77
|
-
pipeline: loader,
|
|
78
|
-
})];
|
|
79
|
-
case 1:
|
|
80
|
-
result = _a.sent();
|
|
81
|
-
expect(result).toBe('format1');
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}); });
|
|
86
|
-
it('takes a fallback route if a loader returns null', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var result;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0: return [4 /*yield*/, Pipeline.run({
|
|
91
|
-
manager: manager,
|
|
92
|
-
source: 'url/format2.json',
|
|
93
|
-
target: Model,
|
|
94
|
-
pipeline: loader,
|
|
95
|
-
})];
|
|
96
|
-
case 1:
|
|
97
|
-
result = _a.sent();
|
|
98
|
-
expect(result).toBe('format2');
|
|
99
|
-
return [2 /*return*/];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}); });
|
|
103
|
-
it('takes a fallback route if a loader returns null', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
-
var result;
|
|
105
|
-
return __generator(this, function (_a) {
|
|
106
|
-
switch (_a.label) {
|
|
107
|
-
case 0: return [4 /*yield*/, Pipeline.run({
|
|
108
|
-
manager: manager,
|
|
109
|
-
source: 'url/format3.json',
|
|
110
|
-
target: Model,
|
|
111
|
-
pipeline: loader,
|
|
112
|
-
})];
|
|
113
|
-
case 1:
|
|
114
|
-
result = _a.sent();
|
|
115
|
-
expect(result).toBe('format3');
|
|
116
|
-
return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); });
|
|
120
|
-
});
|
|
121
|
-
//# sourceMappingURL=Pipeline.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Pipeline.spec.js","sourceRoot":"","sources":["../../../src/Pipeline.spec.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,IAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAE7B,QAAQ,CAAC,gBAAgB,EAAE;IACzB,IAAI,MAAgB,CAAA;IACpB,IAAI,OAAuB,CAAA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ager } from './ContentManager'\nimport { Pipeline } from './Pipeline'\nimport { PipelineContext } from './PipelineContext'\n\nconst Model = Symbol('Model')\n\ndescribe('Content.Loader', () => {\n let loader: Pipeline\n let manager: ContentManager\n\n beforeEach(() => {\n loader = new Pipeline()\n loader.register({\n input: '.json',\n output: Object,\n handle: async (input: any, context: PipelineContext) => {\n const data = await context.manager.download(context.source)\n return JSON.parse(data.content as string)\n },\n })\n\n loader.register({\n input: Object,\n output: Model,\n handle: async (input: any, context: PipelineContext) => {\n if (input.format === 'format1') {\n return input.format\n }\n },\n })\n\n loader.register({\n input: Object,\n output: Model,\n handle: async (input: any, context: PipelineContext) => {\n if (input.format === 'format2') {\n return input.format\n }\n },\n })\n\n loader.register({\n input: Object,\n output: Model,\n handle: async (input: any, context: PipelineContext) => {\n if (input.format === 'format3') {\n return input.format\n }\n },\n })\n\n const downloads = {\n 'url/format1.json': { content: '{ \"format\": \"format1\" }' },\n 'url/format2.json': { content: '{ \"format\": \"format2\" }' },\n 'url/format3.json': { content: '{ \"format\": \"format3\" }' },\n }\n manager = {\n download: (source: string) => Promise.resolve(downloads[source]),\n } as any\n })\n\n it('takes a fallback route if a loader returns null', async () => {\n const result = await Pipeline.run({\n manager: manager,\n source: 'url/format1.json',\n target: Model,\n pipeline: loader,\n })\n expect(result).toBe('format1')\n })\n\n it('takes a fallback route if a loader returns null', async () => {\n const result = await Pipeline.run({\n manager: manager,\n source: 'url/format2.json',\n target: Model,\n pipeline: loader,\n })\n expect(result).toBe('format2')\n })\n\n it('takes a fallback route if a loader returns null', async () => {\n const result = await Pipeline.run({\n manager: manager,\n source: 'url/format3.json',\n target: Model,\n pipeline: loader,\n })\n expect(result).toBe('format3')\n })\n})\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ContentManager } from './ContentManager';
|
|
2
|
-
import { Pipeline } from './Pipeline';
|
|
3
|
-
import { LoaderOutput } from './Loader';
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export interface PipelineContext<T = any> {
|
|
8
|
-
/**
|
|
9
|
-
* The current processing content manager
|
|
10
|
-
*/
|
|
11
|
-
manager: ContentManager;
|
|
12
|
-
/**
|
|
13
|
-
* The instance of the pipeline that is currently handling the loading process
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* this is usually the same instance as owned by the {@link manager}
|
|
17
|
-
*/
|
|
18
|
-
pipeline: Pipeline;
|
|
19
|
-
/**
|
|
20
|
-
* The initially requested source type.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* This is usually a path or url to an external resource
|
|
24
|
-
*/
|
|
25
|
-
source: string;
|
|
26
|
-
/**
|
|
27
|
-
* The target type
|
|
28
|
-
*/
|
|
29
|
-
target: LoaderOutput<T>;
|
|
30
|
-
/**
|
|
31
|
-
* Any user defined options that might be used during the pipeline
|
|
32
|
-
*
|
|
33
|
-
* @remarks
|
|
34
|
-
* Not used or inspected by the pipeline or manager
|
|
35
|
-
*/
|
|
36
|
-
options?: {
|
|
37
|
-
[key: string]: unknown;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=PipelineContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PipelineContext.d.ts","sourceRoot":"","sources":["../../../src/PipelineContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACtC;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAClB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IACvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;CACrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PipelineContext.js","sourceRoot":"","sources":["../../../src/PipelineContext.ts"],"names":[],"mappings":"","sourcesContent":["import { Type } from '@gglib/utils'\nimport { ContentManager } from './ContentManager'\nimport { Pipeline } from './Pipeline'\nimport { LoaderOutput } from './Loader'\n\n/**\n * @public\n */\nexport interface PipelineContext<T = any> {\n /**\n * The current processing content manager\n */\n manager: ContentManager\n /**\n * The instance of the pipeline that is currently handling the loading process\n *\n * @remarks\n * this is usually the same instance as owned by the {@link manager}\n */\n pipeline: Pipeline\n /**\n * The initially requested source type.\n *\n * @remarks\n * This is usually a path or url to an external resource\n */\n source: string\n /**\n * The target type\n */\n target: LoaderOutput<T>\n /**\n * Any user defined options that might be used during the pipeline\n *\n * @remarks\n * Not used or inspected by the pipeline or manager\n */\n options?: { [key: string]: unknown }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../../../src/symbols.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,eAAuB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../../src/symbols.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA","sourcesContent":["export const JsonObject = Symbol('JsonObject')\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LoaderSpec, LoaderInputs, LoaderOutput, LoaderHandle } from './Loader';
|
|
2
|
-
import { PipelineContext } from './PipelineContext';
|
|
3
|
-
export declare function loader<T extends LoaderSpec>(spec: T): T;
|
|
4
|
-
export declare function loader<I extends LoaderInputs, O extends LoaderOutput>(input: I, output: O, handle: LoaderHandle<I, O>): LoaderSpec<I, O>;
|
|
5
|
-
/**
|
|
6
|
-
* Resolves a uri reference relative to the source of given context.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
* @remarks
|
|
10
|
-
* If `refUri` is absolute or is in data uri format then it is returned as is. Otherwise
|
|
11
|
-
* it is merged with `context.source`
|
|
12
|
-
*
|
|
13
|
-
* @param refUri - The uri
|
|
14
|
-
* @param context - The context
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveUri(refUri: string, context: PipelineContext): string;
|
|
17
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,wBAAgB,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAI,CAAC,CAAA;AACzD,wBAAgB,MAAM,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAyBzI;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAE3E"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { DataUri, Uri } from '@gglib/utils';
|
|
2
|
-
import { Pipeline } from './Pipeline';
|
|
3
|
-
/**
|
|
4
|
-
* Registeres a loader specification at the default pipeline (`Pipeline.default`) and returns
|
|
5
|
-
* without any modification
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
* @param spec - The loader specification to register
|
|
9
|
-
*/
|
|
10
|
-
export function loader() {
|
|
11
|
-
var spec;
|
|
12
|
-
if (arguments.length === 3) {
|
|
13
|
-
spec = {
|
|
14
|
-
input: arguments[0],
|
|
15
|
-
output: arguments[1],
|
|
16
|
-
handle: arguments[3],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else if (arguments.length === 1) {
|
|
20
|
-
spec = arguments[0];
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
throw new Error('invalid arguments');
|
|
24
|
-
}
|
|
25
|
-
Pipeline.default.register(spec);
|
|
26
|
-
return spec;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Resolves a uri reference relative to the source of given context.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
* @remarks
|
|
33
|
-
* If `refUri` is absolute or is in data uri format then it is returned as is. Otherwise
|
|
34
|
-
* it is merged with `context.source`
|
|
35
|
-
*
|
|
36
|
-
* @param refUri - The uri
|
|
37
|
-
* @param context - The context
|
|
38
|
-
*/
|
|
39
|
-
export function resolveUri(refUri, context) {
|
|
40
|
-
return DataUri.isDataUri(refUri) ? refUri : Uri.merge(context.source, refUri);
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAKrC;;;;;;GAMG;AACH,MAAM,UAAU,MAAM;IACpB,IAAI,IAAgB,CAAA;IACpB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,IAAI,GAAG;YACL,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;YACnB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;YACpB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SACrB,CAAA;KACF;SAAM,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QACjC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;KACpB;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;KACrC;IACD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/B,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,OAAwB;IACjE,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import { DataUri, Uri } from '@gglib/utils'\nimport { LoaderSpec, LoaderInputs, LoaderOutput, LoaderHandle } from './Loader'\nimport { Pipeline } from './Pipeline'\nimport { PipelineContext } from './PipelineContext'\n\nexport function loader<T extends LoaderSpec>(spec: T ): T\nexport function loader<I extends LoaderInputs, O extends LoaderOutput>(input: I, output: O, handle: LoaderHandle<I, O>): LoaderSpec<I, O>\n/**\n * Registeres a loader specification at the default pipeline (`Pipeline.default`) and returns\n * without any modification\n *\n * @public\n * @param spec - The loader specification to register\n */\nexport function loader<I extends LoaderInputs, O extends LoaderOutput>(): LoaderSpec<I, O> {\n let spec: LoaderSpec\n if (arguments.length === 3) {\n spec = {\n input: arguments[0],\n output: arguments[1],\n handle: arguments[3],\n }\n } else if (arguments.length === 1) {\n spec = arguments[0]\n } else {\n throw new Error('invalid arguments')\n }\n Pipeline.default.register(spec)\n return spec\n}\n\n/**\n * Resolves a uri reference relative to the source of given context.\n *\n * @public\n * @remarks\n * If `refUri` is absolute or is in data uri format then it is returned as is. Otherwise\n * it is merged with `context.source`\n *\n * @param refUri - The uri\n * @param context - The context\n */\nexport function resolveUri(refUri: string, context: PipelineContext): string {\n return DataUri.isDataUri(refUri) ? refUri : Uri.merge(context.source, refUri)\n}\n"]}
|