@gglib/content 0.6.2 → 0.8.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/LICENSE +7 -0
- package/Readme.md +1 -1
- 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content.umd.js","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/ContentType.ts","../../src/Data.ts","../../src/Loader.ts","../../src/Pipeline.ts","../../src/ContentManager.ts","../../src/symbols.ts","../../src/utils.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","// for explanation see:\n// https://www.debuggex.com/\nconst regex = /(([a-z0-9-]+)\\/([a-z0-9+-]+))?((;\\s*([a-z0-9-]+=)?(([a-z0-9]+)|(\"[^\"]*\")))+)?/\n\n/**\n * Describes components of a mime type\n *\n * @public\n */\nexport class ContentType {\n /**\n * The mime type string e.g. text/json\n */\n public mimeType: string\n\n /**\n * The media type of a mime type e.g. 'text'\n */\n public mediaType: string\n\n /**\n * The sub type of a mime type e.g. 'json'\n */\n public subType: string\n\n /**\n * The params of a mime type\n */\n public params?: string\n\n public static parse(input: string): ContentType {\n const match: any[] = regex.exec(input) || []\n return match ? {\n mimeType: match[1],\n mediaType: match[2],\n subType: match[3],\n params: (match[4] || ''),\n } : null\n }\n}\n","import { DataUri } from '@gglib/utils'\nimport { ContentType } from './ContentType'\n\n /**\n * @public\n */\nexport interface Data<T = string | ArrayBuffer | Blob | Document | any> {\n /**\n * The source url\n */\n source: string\n /**\n * The content\n */\n content: T\n /**\n * The content type (e.g. application/json)\n */\n type?: ContentType\n}\n\n/**\n * @public\n */\nexport function dataFromXhr(xhr: XMLHttpRequest) {\n return {\n xhr: xhr,\n source: xhr.responseURL,\n content: xhr.response || xhr.responseText,\n type: ContentType.parse(xhr.getResponseHeader('content-type')),\n }\n}\n\n/**\n * @public\n */\nexport function dataFromUri(uri: DataUri): Data<string> {\n return {\n source: uri.uri,\n content: uri.data,\n type: ContentType.parse(uri.contentType),\n }\n}\n\n/**\n * @public\n */\nexport function dataFromElement<T = string>(path: string, el: Element, convert = (it: string): T => it as any): Data<T> {\n return {\n source: path,\n type: ContentType.parse(el.getAttribute('type')),\n content: convert(el.textContent),\n }\n}\n","import { Type, AbstractType, TypeToken } from '@gglib/utils'\nimport { PipelineContext } from './PipelineContext'\n\nexport type LoaderInput<T = unknown> = string | symbol | Type<T> | AbstractType<T> | TypeToken<T>\nexport type LoaderOutput<T = unknown> = symbol | Type<T> | AbstractType<T> | TypeToken<T>\nexport type LoaderInputs<T = unknown> = LoaderInput<T> | Array<LoaderInput<T>>\n\nexport type LoaderInputType<I extends LoaderInputs> =\n I extends Type<infer T> ? T :\n I extends AbstractType<infer T> ? T :\n I extends TypeToken<infer T> ? T : unknown\nexport type LoaderOutputType<O extends LoaderOutput> = O extends LoaderOutput<infer T> ? T : unknown\n\n/**\n * A function that transforms an input of type `I` to output of type `O` using context with data type `D`\n *\n * @public\n */\nexport type LoaderHandle<I extends LoaderInputs, O extends LoaderOutput> = (input: LoaderInputType<I>, context: PipelineContext<unknown>) => Promise<LoaderOutputType<O>>\n\n/**\n * A specification of a loader function declaring its input and output types\n *\n * @public\n */\nexport interface LoaderSpec<Input extends LoaderInputs = any, Output extends LoaderOutput = any> {\n /**\n * The input type or input types that the loader can load from\n *\n * @remarks\n * Use strings for file extensions or mime types\n *\n * ```ts\n * input: ['.jpg', 'image/jpeg']\n * ```\n * Use symbols for interface types that have no class type at runtime\n * ```ts\n * input: Texture.Options\n * ```\n * Use class types for everything that has an own runtime type\n * ```ts\n * input: HTMLImageElement\n * ```\n */\n readonly input: Input\n /**\n * The output type that the loader can load to\n *\n * @remarks\n * Use symbols for interface types that have no class type at runtime\n * ```ts\n * output: Texture.Options\n * ```\n * Use class types for everything that has an own runtime type\n * ```ts\n * output: HTMLImageElement\n * ```\n */\n readonly output: Output\n /**\n * The loader function\n */\n readonly handle: LoaderHandle<Input, Output>\n}\n\nexport type Loader<Input, Output> = LoaderSpec<LoaderInputs<Input>, LoaderOutput<Output>>\n\n/**\n * @public\n */\nexport class LoaderEntry<Input extends LoaderInput = any, Output extends LoaderOutput = any> {\n public constructor(\n public input: Input,\n public output: Output,\n public handle: LoaderHandle<Input, Output>,\n ) {\n\n }\n\n public toString() {\n return `${this.input.toString()} => ${this.output.toString()}`\n }\n}\n","import { DataUri, Log, Uri } from '@gglib/utils'\n\nimport { ContentType } from './ContentType'\nimport { LoaderEntry, LoaderSpec, LoaderInput, LoaderOutput } from './Loader'\nimport { PipelineContext } from './PipelineContext'\n\ninterface Node {\n entry: LoaderEntry\n next: Node[]\n}\n\nfunction describeSym(sym: any) {\n if (!sym) {\n return `${sym}`\n }\n if (sym['name']) {\n return sym['name']\n }\n return sym.toString()\n}\n\nfunction warn(msg: string) {\n Log.warn('[Content.Loader] ' + msg)\n}\n\nlet defaultPipeline: Pipeline\n\n/**\n * @public\n */\nexport class Pipeline {\n /**\n * Returns the default pipeline instance\n */\n public static get default() {\n if (defaultPipeline == null) {\n defaultPipeline = new Pipeline()\n }\n return defaultPipeline\n }\n\n private loaders: LoaderEntry[] = []\n\n public static async run(context: PipelineContext) {\n return context.pipeline.run(context.source, context.target, null, context)\n }\n\n /**\n * Registeres a loader function\n *\n * @param loader - The loader specification\n */\n public register(loader: LoaderSpec) {\n const inputs = Array.isArray(loader.input) ? loader.input : [loader.input]\n inputs.forEach((input) => {\n for (const entry of this.loaders) {\n if (entry.handle === loader.handle && entry.input === input && entry.output === loader.output) {\n warn(`same loader was registered twice... loader is skipped. ${entry.toString()}`)\n return\n }\n }\n this.loaders.push(new LoaderEntry(input, loader.output, loader.handle))\n })\n }\n\n /**\n *\n * @param source - The source type or symbol identifying the input type\n * @param target - The target type or symbol identifying the target type\n * @param input - The input value to import. Its type is identified by `source`\n * @param context - The context to use during the import\n */\n public async run<S = unknown, T = unknown>(source: LoaderInput<S>, target: LoaderOutput<T>, input: any, context: PipelineContext): Promise<T> {\n\n if (typeof source === 'string') {\n if (DataUri.isDataUri(source)) {\n source = ContentType.parse(DataUri.parse(source).contentType).mimeType\n } else {\n source = Uri.ext(source)\n }\n }\n\n const pipeline = this.resolve(source, target)\n if (pipeline.length === 0) {\n throw new Error(`Loader is missing: ${describeSym(source)} => ${describeSym(target)}`)\n }\n return this.walk(pipeline, input, context)\n }\n\n public async graph(source: LoaderInput, target: LoaderOutput, input: any, context: PipelineContext) {\n\n }\n\n /**\n * Detects whether there is a loding path from `source` type to the `target` type\n *\n * @param source - The source type or symbol identifying the input type\n * @param target - The target type or symbol identifying the target type\n */\n public canLoad(source: LoaderInput, target: LoaderOutput): boolean {\n return this.resolve(source, target).length > 0\n }\n\n private resolve(\n source: LoaderInput,\n target: LoaderOutput,\n exclude: LoaderEntry[] = [],\n ): Node[] {\n const candidates = this.loaders.filter((it) => exclude.indexOf(it) === -1 && it.input === source)\n exclude.push(...candidates)\n return candidates.map((it) => {\n if (it.output === target) {\n return {\n entry: it,\n next: [],\n }\n }\n const next = this.resolve(it.output, target, exclude)\n return next && next.length ? {\n entry: it,\n next: next,\n } : null\n })\n .filter((it) => it != null)\n .sort((a, b) => a.next.length <= b.next.length ? -1 : 1)\n }\n\n private async walk<T>(nodes: Node[], input: any, context: PipelineContext<T>, depth: number = 1) {\n if (nodes.length === 0) {\n // finish recursion\n return input\n }\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]\n context.pipeline = this\n\n Log.group(`stage:${depth} (${i + 1}) ${describeSym(node.entry.input)} => ${describeSym(node.entry.output)}`)\n const loaded = await Log.groupEndAsync(() => node.entry.handle(input, context))\n const result: T = await this.walk(node.next, loaded, context, depth + 1)\n if (result) {\n return result\n }\n }\n return null\n }\n}\n","import { Device } from '@gglib/graphics'\nimport { DataUri, Http, HttpOptions, Log, Type, Uri } from '@gglib/utils'\nimport { ContentType } from './ContentType'\nimport { Data, dataFromElement, dataFromXhr } from './Data'\nimport { Pipeline } from './Pipeline'\nimport { LoaderOutput } from './Loader'\n\n/**\n * @public\n */\nexport interface IManagerOptions {\n enableDomAssets?: boolean\n pipeline?: Pipeline\n}\n\nfunction getOption<T>(options: IManagerOptions, key: keyof IManagerOptions, fallback: T): T {\n if (key in options) {\n return options[key] as any\n }\n return fallback\n}\n\n/**\n * @public\n */\nexport class ContentManager {\n /**\n * The instance of the graphics device\n */\n public device: Device\n\n /**\n * Allows to rewrite a url\n *\n * @remarks\n * Use this to remap a resource uri to another location.\n */\n public rewriteUrl: (url: string) => string = (it) => it\n\n /**\n * Allows to rewrite an http request\n *\n * @remarks\n * Use this to add authentication or header fields to the request.\n * Avoid changing the `url` string.\n */\n public rewriteRequest: (options: HttpOptions) => HttpOptions = (it: HttpOptions) => it\n\n /**\n * Encodes a string to an array buffer\n */\n public encode: (str: string) => ArrayBuffer = (str) => {\n const buf = new ArrayBuffer(str.length * 2)\n const bufView = new Uint8Array(buf)\n for (let i = 0; i < str.length; i++) {\n bufView[i] = str.charCodeAt(i)\n }\n return buf\n }\n\n /**\n * Indicates whether assets embedded in DOM elements are enabled\n */\n public enableDomAssets = true\n\n /**\n * The instance of the loader to use\n */\n public pipeline: Pipeline = Pipeline.default\n\n /**\n * Collection of all loaded assets\n */\n private loaded = new Map<string, any>()\n /**\n * Collection of all ongoing loading promises\n */\n private loading = new Map<string, Promise<any>>()\n\n /**\n * Collection of existing download requests\n */\n private downloads = new Map<string, Map<string, Promise<Data<any>>>>()\n\n /**\n *\n */\n constructor(device: Device, options: IManagerOptions= {}) {\n this.device = device\n this.setup(options)\n }\n\n public setup(options: IManagerOptions) {\n this.enableDomAssets = getOption(options, 'enableDomAssets', this.enableDomAssets)\n this.pipeline = getOption(options, 'pipeline', this.pipeline)\n }\n\n /**\n * Downloads a resource as json\n */\n public async downloadJSON(optionsOrUrl: HttpOptions|string): Promise<Data<{}>> {\n const options = this.createHttpOptions(optionsOrUrl)\n options.xhr = Http.createXMLHttpRequest('json')\n return this.download<{}>(options)\n }\n\n /**\n * Downloads a resource as xml document\n */\n public async downloadDocument(optionsOrUrl: HttpOptions|string): Promise<Data<Document>> {\n const options = this.createHttpOptions(optionsOrUrl)\n options.xhr = Http.createXMLHttpRequest('document')\n return this.download<Document>(options)\n }\n\n /**\n * Downloads a resource as text\n */\n public async downloadText(optionsOrUrl: HttpOptions|string): Promise<Data<string>> {\n const options = this.createHttpOptions(optionsOrUrl)\n options.xhr = Http.createXMLHttpRequest('text')\n return this.download<string>(options)\n }\n\n /**\n * Downloads a resource as `Blob`\n */\n public async downloadBlob(optionsOrUrl: HttpOptions|string): Promise<Data<Blob>> {\n const options = this.createHttpOptions(optionsOrUrl)\n options.xhr = Http.createXMLHttpRequest('blob')\n return this.download<Blob>(options)\n }\n\n /**\n * Downloads a resource as `ArrayBuffer`\n */\n public async downloadArrayBuffer(optionsOrUrl: HttpOptions|string): Promise<Data<ArrayBuffer>> {\n const options = this.createHttpOptions(optionsOrUrl)\n options.xhr = Http.createXMLHttpRequest('arraybuffer')\n return this.download<ArrayBuffer>(options)\n }\n\n /**\n * Downloads data from a remote location.\n *\n * @remarks\n * If dom assets are enabled then an attempt will be made to find a DOM Element matching the following criteria\n * - element has a `type` attribute\n * - element has an `id` attribute with the value of the given url\n *\n * If such DOM Element exists then its textContent is taken as a result\n */\n public async download<T = any>(optionsOrUrl: HttpOptions|string): Promise<Data<T>> {\n let options = this.createHttpOptions(optionsOrUrl)\n if (this.rewriteRequest) {\n options = this.rewriteRequest(options) || options\n }\n const path = options.url\n const type = options.xhr ? options.xhr.responseType || 'text' : 'text'\n\n if (this.downloads.has(type)) {\n if (this.downloads.get(type).has(path)) {\n return this.downloads.get(type).get(path)\n }\n } else {\n this.downloads.set(type, new Map())\n }\n\n return this.downloads\n .get(type)\n .set(path, (async () => {\n if (this.enableDomAssets) {\n const element = document.getElementById(path) || document.getElementById(path.replace(/^[\\/|#]/, ''))\n if (!element || !element.hasAttribute('type')) {\n //\n } else if (type === 'text') {\n return Promise.resolve(dataFromElement(path, element))\n } else if (type === 'json') {\n return Promise.resolve(dataFromElement(path, element, (text) => JSON.parse(text)))\n } else if (type === 'arraybuffer') {\n return Promise.resolve(dataFromElement(path, element, this.encode))\n } else {\n //\n }\n }\n if (this.enableDomAssets && type === 'text') {\n const element = document.getElementById(path) || document.getElementById(path.replace(/^[\\/|#]/, ''))\n if (element && element.hasAttribute('type')) {\n return Promise.resolve(dataFromElement(path, element))\n }\n }\n return Http.request(options)\n .catch((xhr: XMLHttpRequest) => {\n throw new Error(`${xhr.responseURL} ${xhr.statusText} (${xhr.status})`)\n })\n .then(dataFromXhr)\n })())\n .get(path)\n }\n\n /**\n * Loads and instantiates multiple assets\n *\n * @remarks\n * The given batch must be an object where each key identifies the target type e.g. `Model` or `Effect` etc.\n * The result has always the same structure as the given batch but all asset paths are replaced with an asset instance.\n *\n * If the batch value is a string, then that is used as an asset path where the asset is downloaded from.\n *\n * ```ts\n * load({ Model: 'path/to/model.obj' })\n * // => { Model: INSTANCE }\n * ```\n *\n * If the batch value is an array, then each entry is used as an asset path.\n *\n * ```ts\n * load({ Model: ['path/1.obj', 'path/2.obj'] })\n * // => { Model: [INSTANCE1, INSTANCE2] }\n * ```\n *\n * If the batch value is an object, then each entry is used as an asset path.\n *\n * ```ts\n * load({ Model: { foo: 'path/foo.obj' })\n * // => { Model: { foo: INSTANCE } }\n * ```\n *\n */\n public loadBatch(batch: { [key: string]: [string, any] }): Promise<{ [key: string]: any }> {\n let result = {}\n\n const promises: Array<Promise<any>> = []\n let counter = 0\n\n function enqueue(job: Promise<void>) {\n promises.push(job.then(() => {\n counter++\n // TODO: notify\n }))\n }\n\n Object.keys(batch).forEach((key) => {\n const [source, targetType] = batch[key]\n\n enqueue(this.load(source, targetType).then((res) => {\n result[key] = res\n }))\n })\n\n return Promise.all(promises).then(() => result)\n }\n\n /**\n * Checks whether loading from given source is supported.\n *\n * @param src - The source url to load from. This will be passed to `rewriteUrl`.\n * @param targetType - The target asset type or a symbol identifying the target type.\n */\n public canLoad<T = any>(src: string, targetType: LoaderOutput<T>) {\n const remapped = this.rewriteUrl(src)\n if (remapped) {\n src = remapped\n }\n\n if (DataUri.isDataUri(src)) {\n return this.pipeline.canLoad(ContentType.parse(DataUri.parse(src).contentType).mimeType, targetType)\n } else {\n return this.pipeline.canLoad(Uri.ext(src), targetType)\n }\n }\n\n /**\n * Loads and instantiates a single asset\n *\n * @param src - The source url to load from. This will be passed to `rewriteUrl`.\n * @param targetType - The target asset type or a symbol identifying the target type.\n * @param options - Options which will be available in the loading context.\n */\n public async load<T = unknown>(src: string, targetType: LoaderOutput<T>, options: { [key: string]: any } = {}): Promise<T> {\n const requested = Uri.merge(location.pathname, src)\n const remapped = this.rewriteUrl(requested)\n if (requested !== remapped) {\n Log.debug(`[Content.Manager] remap Url ${src} => ${remapped}`)\n src = remapped\n } else {\n src = requested\n }\n\n let key: string\n let group: string\n if (DataUri.isDataUri(src)) {\n const uri = DataUri.parse(src)\n const source = ContentType.parse(uri.contentType).mimeType\n const target = targetType['name'] || targetType.toString()\n key = `${source} => ${target}`\n group = `[Content.Manager] load ${key} (from DataUri '${uri.contentType}')`\n } else {\n const source = src\n const target = targetType['name'] || targetType.toString()\n key = `${source} => ${target}`\n group = `[Content.Manager] load ${key}`\n }\n\n if (this.loading.has(key)) {\n return this.loading.get(key)\n }\n\n if (this.loaded.has(key)) {\n return Promise.resolve(this.loaded.get(key))\n }\n\n Log.group(group)\n const loader = Log.groupEndAsync(() => Pipeline.run({\n manager: this,\n source: src,\n target: targetType,\n options: options,\n pipeline: this.pipeline,\n }))\n return this.loading.set(key, loader).get(key).then((result) => {\n this.loading.delete(key)\n this.loaded.set(key, result)\n return result\n })\n }\n\n /**\n * Unloads all currently loaded assets\n */\n public unload() {\n this.loaded.forEach((value, key) => {\n try {\n if (typeof value.unload === 'function') { value.unload() }\n } catch (e) {\n Log.warn(`[Content.Manager] failed to unload asset at '${key}'`, e)\n }\n })\n this.loaded.clear()\n this.loading.clear()\n // TODO: abort ongoing xhr requests\n this.downloads.forEach((v) => v.clear())\n this.downloads.clear()\n }\n\n private createHttpOptions(optionsOrUrl: HttpOptions|string): HttpOptions {\n let options = optionsOrUrl as HttpOptions\n if (typeof optionsOrUrl === 'string') {\n options = { url: optionsOrUrl }\n }\n return options\n }\n}\n","export const JsonObject = Symbol('JsonObject')\n","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"],"names":["Log","DataUri","Uri","Http"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AAuDA;IACO,SAAS,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE;IAC7D,IAAI,SAAS,KAAK,CAAC,KAAK,EAAE,EAAE,OAAO,KAAK,YAAY,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,OAAO,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAChH,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,EAAE,UAAU,OAAO,EAAE,MAAM,EAAE;IAC/D,QAAQ,SAAS,SAAS,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IACnG,QAAQ,SAAS,QAAQ,CAAC,KAAK,EAAE,EAAE,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,MAAM,KAAK,CAAC,EAAE;YAC1B,IAAI,GAAG;gBACL,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;gBACnB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;gBACpB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;aACrB,CAAA;SACF;aAAM,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QACD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;;;;;aAWgB,UAAU,CAAC,MAAc,EAAE,OAAwB;QACjE,OAAOC,aAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAGC,SAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/E;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Device } from '@gglib/graphics';
|
|
2
|
-
import { HttpOptions } from '@gglib/utils';
|
|
3
|
-
import { Data } from './Data';
|
|
4
|
-
import { Pipeline } from './Pipeline';
|
|
5
|
-
import { LoaderOutput } from './Loader';
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface IManagerOptions {
|
|
10
|
-
enableDomAssets?: boolean;
|
|
11
|
-
pipeline?: Pipeline;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export declare class ContentManager {
|
|
17
|
-
/**
|
|
18
|
-
* The instance of the graphics device
|
|
19
|
-
*/
|
|
20
|
-
device: Device;
|
|
21
|
-
/**
|
|
22
|
-
* Allows to rewrite a url
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Use this to remap a resource uri to another location.
|
|
26
|
-
*/
|
|
27
|
-
rewriteUrl: (url: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Allows to rewrite an http request
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* Use this to add authentication or header fields to the request.
|
|
33
|
-
* Avoid changing the `url` string.
|
|
34
|
-
*/
|
|
35
|
-
rewriteRequest: (options: HttpOptions) => HttpOptions;
|
|
36
|
-
/**
|
|
37
|
-
* Encodes a string to an array buffer
|
|
38
|
-
*/
|
|
39
|
-
encode: (str: string) => ArrayBuffer;
|
|
40
|
-
/**
|
|
41
|
-
* Indicates whether assets embedded in DOM elements are enabled
|
|
42
|
-
*/
|
|
43
|
-
enableDomAssets: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* The instance of the loader to use
|
|
46
|
-
*/
|
|
47
|
-
pipeline: Pipeline;
|
|
48
|
-
/**
|
|
49
|
-
* Collection of all loaded assets
|
|
50
|
-
*/
|
|
51
|
-
private loaded;
|
|
52
|
-
/**
|
|
53
|
-
* Collection of all ongoing loading promises
|
|
54
|
-
*/
|
|
55
|
-
private loading;
|
|
56
|
-
/**
|
|
57
|
-
* Collection of existing download requests
|
|
58
|
-
*/
|
|
59
|
-
private downloads;
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
*/
|
|
63
|
-
constructor(device: Device, options?: IManagerOptions);
|
|
64
|
-
setup(options: IManagerOptions): void;
|
|
65
|
-
/**
|
|
66
|
-
* Downloads a resource as json
|
|
67
|
-
*/
|
|
68
|
-
downloadJSON(optionsOrUrl: HttpOptions | string): Promise<Data<{}>>;
|
|
69
|
-
/**
|
|
70
|
-
* Downloads a resource as xml document
|
|
71
|
-
*/
|
|
72
|
-
downloadDocument(optionsOrUrl: HttpOptions | string): Promise<Data<Document>>;
|
|
73
|
-
/**
|
|
74
|
-
* Downloads a resource as text
|
|
75
|
-
*/
|
|
76
|
-
downloadText(optionsOrUrl: HttpOptions | string): Promise<Data<string>>;
|
|
77
|
-
/**
|
|
78
|
-
* Downloads a resource as `Blob`
|
|
79
|
-
*/
|
|
80
|
-
downloadBlob(optionsOrUrl: HttpOptions | string): Promise<Data<Blob>>;
|
|
81
|
-
/**
|
|
82
|
-
* Downloads a resource as `ArrayBuffer`
|
|
83
|
-
*/
|
|
84
|
-
downloadArrayBuffer(optionsOrUrl: HttpOptions | string): Promise<Data<ArrayBuffer>>;
|
|
85
|
-
/**
|
|
86
|
-
* Downloads data from a remote location.
|
|
87
|
-
*
|
|
88
|
-
* @remarks
|
|
89
|
-
* If dom assets are enabled then an attempt will be made to find a DOM Element matching the following criteria
|
|
90
|
-
* - element has a `type` attribute
|
|
91
|
-
* - element has an `id` attribute with the value of the given url
|
|
92
|
-
*
|
|
93
|
-
* If such DOM Element exists then its textContent is taken as a result
|
|
94
|
-
*/
|
|
95
|
-
download<T = any>(optionsOrUrl: HttpOptions | string): Promise<Data<T>>;
|
|
96
|
-
/**
|
|
97
|
-
* Loads and instantiates multiple assets
|
|
98
|
-
*
|
|
99
|
-
* @remarks
|
|
100
|
-
* The given batch must be an object where each key identifies the target type e.g. `Model` or `Effect` etc.
|
|
101
|
-
* The result has always the same structure as the given batch but all asset paths are replaced with an asset instance.
|
|
102
|
-
*
|
|
103
|
-
* If the batch value is a string, then that is used as an asset path where the asset is downloaded from.
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* load({ Model: 'path/to/model.obj' })
|
|
107
|
-
* // => { Model: INSTANCE }
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* If the batch value is an array, then each entry is used as an asset path.
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* load({ Model: ['path/1.obj', 'path/2.obj'] })
|
|
114
|
-
* // => { Model: [INSTANCE1, INSTANCE2] }
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* If the batch value is an object, then each entry is used as an asset path.
|
|
118
|
-
*
|
|
119
|
-
* ```ts
|
|
120
|
-
* load({ Model: { foo: 'path/foo.obj' })
|
|
121
|
-
* // => { Model: { foo: INSTANCE } }
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
*/
|
|
125
|
-
loadBatch(batch: {
|
|
126
|
-
[key: string]: [string, any];
|
|
127
|
-
}): Promise<{
|
|
128
|
-
[key: string]: any;
|
|
129
|
-
}>;
|
|
130
|
-
/**
|
|
131
|
-
* Checks whether loading from given source is supported.
|
|
132
|
-
*
|
|
133
|
-
* @param src - The source url to load from. This will be passed to `rewriteUrl`.
|
|
134
|
-
* @param targetType - The target asset type or a symbol identifying the target type.
|
|
135
|
-
*/
|
|
136
|
-
canLoad<T = any>(src: string, targetType: LoaderOutput<T>): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Loads and instantiates a single asset
|
|
139
|
-
*
|
|
140
|
-
* @param src - The source url to load from. This will be passed to `rewriteUrl`.
|
|
141
|
-
* @param targetType - The target asset type or a symbol identifying the target type.
|
|
142
|
-
* @param options - Options which will be available in the loading context.
|
|
143
|
-
*/
|
|
144
|
-
load<T = unknown>(src: string, targetType: LoaderOutput<T>, options?: {
|
|
145
|
-
[key: string]: any;
|
|
146
|
-
}): Promise<T>;
|
|
147
|
-
/**
|
|
148
|
-
* Unloads all currently loaded assets
|
|
149
|
-
*/
|
|
150
|
-
unload(): void;
|
|
151
|
-
private createHttpOptions;
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=ContentManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentManager.d.ts","sourceRoot":"","sources":["../../../src/ContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAiB,WAAW,EAAkB,MAAM,cAAc,CAAA;AAEzE,OAAO,EAAE,IAAI,EAAgC,MAAM,QAAQ,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAA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AAmB,CAAC,YAAY,EAAE,WAAW,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAM9F;;;;;;;;;OASG;IACU,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,YAAY,EAAE,WAAW,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAgDlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACI,SAAS,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAwB1F;;;;;OAKG;IACI,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IAahE;;;;;;OAMG;IACU,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAgD1H;;OAEG;IACI,MAAM;IAeb,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { DataUri, Http, Log, Uri } from '@gglib/utils';
|
|
3
|
-
import { ContentType } from './ContentType';
|
|
4
|
-
import { dataFromElement, dataFromXhr } from './Data';
|
|
5
|
-
import { Pipeline } from './Pipeline';
|
|
6
|
-
function getOption(options, key, fallback) {
|
|
7
|
-
if (key in options) {
|
|
8
|
-
return options[key];
|
|
9
|
-
}
|
|
10
|
-
return fallback;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
var ContentManager = /** @class */ (function () {
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
function ContentManager(device, options) {
|
|
20
|
-
if (options === void 0) { options = {}; }
|
|
21
|
-
/**
|
|
22
|
-
* Allows to rewrite a url
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* Use this to remap a resource uri to another location.
|
|
26
|
-
*/
|
|
27
|
-
this.rewriteUrl = function (it) { return it; };
|
|
28
|
-
/**
|
|
29
|
-
* Allows to rewrite an http request
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* Use this to add authentication or header fields to the request.
|
|
33
|
-
* Avoid changing the `url` string.
|
|
34
|
-
*/
|
|
35
|
-
this.rewriteRequest = function (it) { return it; };
|
|
36
|
-
/**
|
|
37
|
-
* Encodes a string to an array buffer
|
|
38
|
-
*/
|
|
39
|
-
this.encode = function (str) {
|
|
40
|
-
var buf = new ArrayBuffer(str.length * 2);
|
|
41
|
-
var bufView = new Uint8Array(buf);
|
|
42
|
-
for (var i = 0; i < str.length; i++) {
|
|
43
|
-
bufView[i] = str.charCodeAt(i);
|
|
44
|
-
}
|
|
45
|
-
return buf;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Indicates whether assets embedded in DOM elements are enabled
|
|
49
|
-
*/
|
|
50
|
-
this.enableDomAssets = true;
|
|
51
|
-
/**
|
|
52
|
-
* The instance of the loader to use
|
|
53
|
-
*/
|
|
54
|
-
this.pipeline = Pipeline.default;
|
|
55
|
-
/**
|
|
56
|
-
* Collection of all loaded assets
|
|
57
|
-
*/
|
|
58
|
-
this.loaded = new Map();
|
|
59
|
-
/**
|
|
60
|
-
* Collection of all ongoing loading promises
|
|
61
|
-
*/
|
|
62
|
-
this.loading = new Map();
|
|
63
|
-
/**
|
|
64
|
-
* Collection of existing download requests
|
|
65
|
-
*/
|
|
66
|
-
this.downloads = new Map();
|
|
67
|
-
this.device = device;
|
|
68
|
-
this.setup(options);
|
|
69
|
-
}
|
|
70
|
-
ContentManager.prototype.setup = function (options) {
|
|
71
|
-
this.enableDomAssets = getOption(options, 'enableDomAssets', this.enableDomAssets);
|
|
72
|
-
this.pipeline = getOption(options, 'pipeline', this.pipeline);
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Downloads a resource as json
|
|
76
|
-
*/
|
|
77
|
-
ContentManager.prototype.downloadJSON = function (optionsOrUrl) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var options;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
82
|
-
options.xhr = Http.createXMLHttpRequest('json');
|
|
83
|
-
return [2 /*return*/, this.download(options)];
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Downloads a resource as xml document
|
|
89
|
-
*/
|
|
90
|
-
ContentManager.prototype.downloadDocument = function (optionsOrUrl) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
-
var options;
|
|
93
|
-
return __generator(this, function (_a) {
|
|
94
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
95
|
-
options.xhr = Http.createXMLHttpRequest('document');
|
|
96
|
-
return [2 /*return*/, this.download(options)];
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Downloads a resource as text
|
|
102
|
-
*/
|
|
103
|
-
ContentManager.prototype.downloadText = function (optionsOrUrl) {
|
|
104
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
-
var options;
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
108
|
-
options.xhr = Http.createXMLHttpRequest('text');
|
|
109
|
-
return [2 /*return*/, this.download(options)];
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Downloads a resource as `Blob`
|
|
115
|
-
*/
|
|
116
|
-
ContentManager.prototype.downloadBlob = function (optionsOrUrl) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var options;
|
|
119
|
-
return __generator(this, function (_a) {
|
|
120
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
121
|
-
options.xhr = Http.createXMLHttpRequest('blob');
|
|
122
|
-
return [2 /*return*/, this.download(options)];
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Downloads a resource as `ArrayBuffer`
|
|
128
|
-
*/
|
|
129
|
-
ContentManager.prototype.downloadArrayBuffer = function (optionsOrUrl) {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
-
var options;
|
|
132
|
-
return __generator(this, function (_a) {
|
|
133
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
134
|
-
options.xhr = Http.createXMLHttpRequest('arraybuffer');
|
|
135
|
-
return [2 /*return*/, this.download(options)];
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Downloads data from a remote location.
|
|
141
|
-
*
|
|
142
|
-
* @remarks
|
|
143
|
-
* If dom assets are enabled then an attempt will be made to find a DOM Element matching the following criteria
|
|
144
|
-
* - element has a `type` attribute
|
|
145
|
-
* - element has an `id` attribute with the value of the given url
|
|
146
|
-
*
|
|
147
|
-
* If such DOM Element exists then its textContent is taken as a result
|
|
148
|
-
*/
|
|
149
|
-
ContentManager.prototype.download = function (optionsOrUrl) {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
var options, path, type;
|
|
152
|
-
var _this = this;
|
|
153
|
-
return __generator(this, function (_a) {
|
|
154
|
-
options = this.createHttpOptions(optionsOrUrl);
|
|
155
|
-
if (this.rewriteRequest) {
|
|
156
|
-
options = this.rewriteRequest(options) || options;
|
|
157
|
-
}
|
|
158
|
-
path = options.url;
|
|
159
|
-
type = options.xhr ? options.xhr.responseType || 'text' : 'text';
|
|
160
|
-
if (this.downloads.has(type)) {
|
|
161
|
-
if (this.downloads.get(type).has(path)) {
|
|
162
|
-
return [2 /*return*/, this.downloads.get(type).get(path)];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
this.downloads.set(type, new Map());
|
|
167
|
-
}
|
|
168
|
-
return [2 /*return*/, this.downloads
|
|
169
|
-
.get(type)
|
|
170
|
-
.set(path, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
-
var element, element;
|
|
172
|
-
return __generator(this, function (_a) {
|
|
173
|
-
if (this.enableDomAssets) {
|
|
174
|
-
element = document.getElementById(path) || document.getElementById(path.replace(/^[\/|#]/, ''));
|
|
175
|
-
if (!element || !element.hasAttribute('type')) {
|
|
176
|
-
//
|
|
177
|
-
}
|
|
178
|
-
else if (type === 'text') {
|
|
179
|
-
return [2 /*return*/, Promise.resolve(dataFromElement(path, element))];
|
|
180
|
-
}
|
|
181
|
-
else if (type === 'json') {
|
|
182
|
-
return [2 /*return*/, Promise.resolve(dataFromElement(path, element, function (text) { return JSON.parse(text); }))];
|
|
183
|
-
}
|
|
184
|
-
else if (type === 'arraybuffer') {
|
|
185
|
-
return [2 /*return*/, Promise.resolve(dataFromElement(path, element, this.encode))];
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
//
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (this.enableDomAssets && type === 'text') {
|
|
192
|
-
element = document.getElementById(path) || document.getElementById(path.replace(/^[\/|#]/, ''));
|
|
193
|
-
if (element && element.hasAttribute('type')) {
|
|
194
|
-
return [2 /*return*/, Promise.resolve(dataFromElement(path, element))];
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return [2 /*return*/, Http.request(options)
|
|
198
|
-
.catch(function (xhr) {
|
|
199
|
-
throw new Error(xhr.responseURL + " " + xhr.statusText + " (" + xhr.status + ")");
|
|
200
|
-
})
|
|
201
|
-
.then(dataFromXhr)];
|
|
202
|
-
});
|
|
203
|
-
}); })())
|
|
204
|
-
.get(path)];
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* Loads and instantiates multiple assets
|
|
210
|
-
*
|
|
211
|
-
* @remarks
|
|
212
|
-
* The given batch must be an object where each key identifies the target type e.g. `Model` or `Effect` etc.
|
|
213
|
-
* The result has always the same structure as the given batch but all asset paths are replaced with an asset instance.
|
|
214
|
-
*
|
|
215
|
-
* If the batch value is a string, then that is used as an asset path where the asset is downloaded from.
|
|
216
|
-
*
|
|
217
|
-
* ```ts
|
|
218
|
-
* load({ Model: 'path/to/model.obj' })
|
|
219
|
-
* // => { Model: INSTANCE }
|
|
220
|
-
* ```
|
|
221
|
-
*
|
|
222
|
-
* If the batch value is an array, then each entry is used as an asset path.
|
|
223
|
-
*
|
|
224
|
-
* ```ts
|
|
225
|
-
* load({ Model: ['path/1.obj', 'path/2.obj'] })
|
|
226
|
-
* // => { Model: [INSTANCE1, INSTANCE2] }
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* If the batch value is an object, then each entry is used as an asset path.
|
|
230
|
-
*
|
|
231
|
-
* ```ts
|
|
232
|
-
* load({ Model: { foo: 'path/foo.obj' })
|
|
233
|
-
* // => { Model: { foo: INSTANCE } }
|
|
234
|
-
* ```
|
|
235
|
-
*
|
|
236
|
-
*/
|
|
237
|
-
ContentManager.prototype.loadBatch = function (batch) {
|
|
238
|
-
var _this = this;
|
|
239
|
-
var result = {};
|
|
240
|
-
var promises = [];
|
|
241
|
-
var counter = 0;
|
|
242
|
-
function enqueue(job) {
|
|
243
|
-
promises.push(job.then(function () {
|
|
244
|
-
counter++;
|
|
245
|
-
// TODO: notify
|
|
246
|
-
}));
|
|
247
|
-
}
|
|
248
|
-
Object.keys(batch).forEach(function (key) {
|
|
249
|
-
var _a = batch[key], source = _a[0], targetType = _a[1];
|
|
250
|
-
enqueue(_this.load(source, targetType).then(function (res) {
|
|
251
|
-
result[key] = res;
|
|
252
|
-
}));
|
|
253
|
-
});
|
|
254
|
-
return Promise.all(promises).then(function () { return result; });
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Checks whether loading from given source is supported.
|
|
258
|
-
*
|
|
259
|
-
* @param src - The source url to load from. This will be passed to `rewriteUrl`.
|
|
260
|
-
* @param targetType - The target asset type or a symbol identifying the target type.
|
|
261
|
-
*/
|
|
262
|
-
ContentManager.prototype.canLoad = function (src, targetType) {
|
|
263
|
-
var remapped = this.rewriteUrl(src);
|
|
264
|
-
if (remapped) {
|
|
265
|
-
src = remapped;
|
|
266
|
-
}
|
|
267
|
-
if (DataUri.isDataUri(src)) {
|
|
268
|
-
return this.pipeline.canLoad(ContentType.parse(DataUri.parse(src).contentType).mimeType, targetType);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
return this.pipeline.canLoad(Uri.ext(src), targetType);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* Loads and instantiates a single asset
|
|
276
|
-
*
|
|
277
|
-
* @param src - The source url to load from. This will be passed to `rewriteUrl`.
|
|
278
|
-
* @param targetType - The target asset type or a symbol identifying the target type.
|
|
279
|
-
* @param options - Options which will be available in the loading context.
|
|
280
|
-
*/
|
|
281
|
-
ContentManager.prototype.load = function (src, targetType, options) {
|
|
282
|
-
if (options === void 0) { options = {}; }
|
|
283
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
-
var requested, remapped, key, group, uri, source, target, source, target, loader;
|
|
285
|
-
var _this = this;
|
|
286
|
-
return __generator(this, function (_a) {
|
|
287
|
-
requested = Uri.merge(location.pathname, src);
|
|
288
|
-
remapped = this.rewriteUrl(requested);
|
|
289
|
-
if (requested !== remapped) {
|
|
290
|
-
Log.debug("[Content.Manager] remap Url " + src + " => " + remapped);
|
|
291
|
-
src = remapped;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
src = requested;
|
|
295
|
-
}
|
|
296
|
-
if (DataUri.isDataUri(src)) {
|
|
297
|
-
uri = DataUri.parse(src);
|
|
298
|
-
source = ContentType.parse(uri.contentType).mimeType;
|
|
299
|
-
target = targetType['name'] || targetType.toString();
|
|
300
|
-
key = source + " => " + target;
|
|
301
|
-
group = "[Content.Manager] load " + key + " (from DataUri '" + uri.contentType + "')";
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
source = src;
|
|
305
|
-
target = targetType['name'] || targetType.toString();
|
|
306
|
-
key = source + " => " + target;
|
|
307
|
-
group = "[Content.Manager] load " + key;
|
|
308
|
-
}
|
|
309
|
-
if (this.loading.has(key)) {
|
|
310
|
-
return [2 /*return*/, this.loading.get(key)];
|
|
311
|
-
}
|
|
312
|
-
if (this.loaded.has(key)) {
|
|
313
|
-
return [2 /*return*/, Promise.resolve(this.loaded.get(key))];
|
|
314
|
-
}
|
|
315
|
-
Log.group(group);
|
|
316
|
-
loader = Log.groupEndAsync(function () { return Pipeline.run({
|
|
317
|
-
manager: _this,
|
|
318
|
-
source: src,
|
|
319
|
-
target: targetType,
|
|
320
|
-
options: options,
|
|
321
|
-
pipeline: _this.pipeline,
|
|
322
|
-
}); });
|
|
323
|
-
return [2 /*return*/, this.loading.set(key, loader).get(key).then(function (result) {
|
|
324
|
-
_this.loading.delete(key);
|
|
325
|
-
_this.loaded.set(key, result);
|
|
326
|
-
return result;
|
|
327
|
-
})];
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* Unloads all currently loaded assets
|
|
333
|
-
*/
|
|
334
|
-
ContentManager.prototype.unload = function () {
|
|
335
|
-
this.loaded.forEach(function (value, key) {
|
|
336
|
-
try {
|
|
337
|
-
if (typeof value.unload === 'function') {
|
|
338
|
-
value.unload();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
catch (e) {
|
|
342
|
-
Log.warn("[Content.Manager] failed to unload asset at '" + key + "'", e);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
this.loaded.clear();
|
|
346
|
-
this.loading.clear();
|
|
347
|
-
// TODO: abort ongoing xhr requests
|
|
348
|
-
this.downloads.forEach(function (v) { return v.clear(); });
|
|
349
|
-
this.downloads.clear();
|
|
350
|
-
};
|
|
351
|
-
ContentManager.prototype.createHttpOptions = function (optionsOrUrl) {
|
|
352
|
-
var options = optionsOrUrl;
|
|
353
|
-
if (typeof optionsOrUrl === 'string') {
|
|
354
|
-
options = { url: optionsOrUrl };
|
|
355
|
-
}
|
|
356
|
-
return options;
|
|
357
|
-
};
|
|
358
|
-
return ContentManager;
|
|
359
|
-
}());
|
|
360
|
-
export { ContentManager };
|
|
361
|
-
//# sourceMappingURL=ContentManager.js.map
|