@mlightcad/common 1.0.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 +21 -0
- package/dist/common.js +1226 -0
- package/dist/common.umd.cjs +1 -0
- package/lib/AcCmColor.d.ts +42 -0
- package/lib/AcCmColor.d.ts.map +1 -0
- package/lib/AcCmColor.js +456 -0
- package/lib/AcCmColor.js.map +1 -0
- package/lib/AcCmColorUtil.d.ts +9 -0
- package/lib/AcCmColorUtil.d.ts.map +1 -0
- package/lib/AcCmColorUtil.js +54 -0
- package/lib/AcCmColorUtil.js.map +1 -0
- package/lib/AcCmErrors.d.ts +23 -0
- package/lib/AcCmErrors.d.ts.map +1 -0
- package/lib/AcCmErrors.js +37 -0
- package/lib/AcCmErrors.js.map +1 -0
- package/lib/AcCmEventDispatcher.d.ts +48 -0
- package/lib/AcCmEventDispatcher.d.ts.map +1 -0
- package/lib/AcCmEventDispatcher.js +60 -0
- package/lib/AcCmEventDispatcher.js.map +1 -0
- package/lib/AcCmEventManager.d.ts +27 -0
- package/lib/AcCmEventManager.d.ts.map +1 -0
- package/lib/AcCmEventManager.js +94 -0
- package/lib/AcCmEventManager.js.map +1 -0
- package/lib/AcCmLogUtil.d.ts +31 -0
- package/lib/AcCmLogUtil.d.ts.map +1 -0
- package/lib/AcCmLogUtil.js +23 -0
- package/lib/AcCmLogUtil.js.map +1 -0
- package/lib/AcCmObject.d.ts +96 -0
- package/lib/AcCmObject.d.ts.map +1 -0
- package/lib/AcCmObject.js +175 -0
- package/lib/AcCmObject.js.map +1 -0
- package/lib/AcCmPerformanceCollector.d.ts +68 -0
- package/lib/AcCmPerformanceCollector.d.ts.map +1 -0
- package/lib/AcCmPerformanceCollector.js +110 -0
- package/lib/AcCmPerformanceCollector.js.map +1 -0
- package/lib/AcCmStringUtil.d.ts +11 -0
- package/lib/AcCmStringUtil.d.ts.map +1 -0
- package/lib/AcCmStringUtil.js +25 -0
- package/lib/AcCmStringUtil.js.map +1 -0
- package/lib/AcCmTaskScheduler.d.ts +70 -0
- package/lib/AcCmTaskScheduler.d.ts.map +1 -0
- package/lib/AcCmTaskScheduler.js +173 -0
- package/lib/AcCmTaskScheduler.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/loader/AcCmFileLoader.d.ts +58 -0
- package/lib/loader/AcCmFileLoader.d.ts.map +1 -0
- package/lib/loader/AcCmFileLoader.js +225 -0
- package/lib/loader/AcCmFileLoader.js.map +1 -0
- package/lib/loader/AcCmLoader.d.ts +92 -0
- package/lib/loader/AcCmLoader.d.ts.map +1 -0
- package/lib/loader/AcCmLoader.js +88 -0
- package/lib/loader/AcCmLoader.js.map +1 -0
- package/lib/loader/AcCmLoadingManager.d.ts +119 -0
- package/lib/loader/AcCmLoadingManager.d.ts.map +1 -0
- package/lib/loader/AcCmLoadingManager.js +133 -0
- package/lib/loader/AcCmLoadingManager.js.map +1 -0
- package/lib/loader/index.d.ts +3 -0
- package/lib/loader/index.d.ts.map +1 -0
- package/lib/loader/index.js +3 -0
- package/lib/loader/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { AcCmLoader } from './AcCmLoader';
|
|
17
|
+
var loading = {};
|
|
18
|
+
var HttpError = /** @class */ (function (_super) {
|
|
19
|
+
__extends(HttpError, _super);
|
|
20
|
+
function HttpError(message, response) {
|
|
21
|
+
var _this = _super.call(this, message) || this;
|
|
22
|
+
_this.response = response;
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
return HttpError;
|
|
26
|
+
}(Error));
|
|
27
|
+
/**
|
|
28
|
+
* A low level class for loading resources with 'Fetch', used internally by most loaders. It can also
|
|
29
|
+
* be used directly to load any file type that does not have a loader.
|
|
30
|
+
*/
|
|
31
|
+
var AcCmFileLoader = /** @class */ (function (_super) {
|
|
32
|
+
__extends(AcCmFileLoader, _super);
|
|
33
|
+
/**
|
|
34
|
+
* Create a new AcCmFileLoader instance.
|
|
35
|
+
* @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
|
|
36
|
+
*/
|
|
37
|
+
function AcCmFileLoader(manager) {
|
|
38
|
+
return _super.call(this, manager) || this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load the URL and pass the response to the onLoad function.
|
|
42
|
+
* @param url The path or URL to the file. This can also be a Data URI.
|
|
43
|
+
* @param onLoad (optional) — Will be called when loading completes.
|
|
44
|
+
* @param onProgress (optional) — Will be called while load progresses.
|
|
45
|
+
* @param onError (optional) — Will be called if an error occurs.
|
|
46
|
+
*/
|
|
47
|
+
AcCmFileLoader.prototype.load = function (url, onLoad, onProgress, onError) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
if (url === undefined)
|
|
50
|
+
url = '';
|
|
51
|
+
if (this.path !== undefined)
|
|
52
|
+
url = this.path + url;
|
|
53
|
+
url = this.manager.resolveURL(url);
|
|
54
|
+
// Check if request is duplicate
|
|
55
|
+
if (loading[url] !== undefined) {
|
|
56
|
+
loading[url].push({
|
|
57
|
+
onLoad: onLoad,
|
|
58
|
+
onProgress: onProgress,
|
|
59
|
+
onError: onError
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Initialise array for duplicate requests
|
|
64
|
+
loading[url] = [];
|
|
65
|
+
loading[url].push({
|
|
66
|
+
onLoad: onLoad,
|
|
67
|
+
onProgress: onProgress,
|
|
68
|
+
onError: onError
|
|
69
|
+
});
|
|
70
|
+
// create request
|
|
71
|
+
var req = new Request(url, {
|
|
72
|
+
headers: new Headers(this.requestHeader),
|
|
73
|
+
credentials: this.withCredentials ? 'include' : 'same-origin'
|
|
74
|
+
// An abort controller could be added within a future PR
|
|
75
|
+
});
|
|
76
|
+
// record states ( avoid data race )
|
|
77
|
+
var mimeType = this.mimeType;
|
|
78
|
+
var responseType = this.responseType;
|
|
79
|
+
// start the fetch
|
|
80
|
+
fetch(req)
|
|
81
|
+
.then(function (response) {
|
|
82
|
+
var _a;
|
|
83
|
+
if (response.status === 200 || response.status === 0) {
|
|
84
|
+
// Some browsers return HTTP Status 0 when using non-http protocol
|
|
85
|
+
// e.g. 'file://' or 'data://'. Handle as success.
|
|
86
|
+
if (response.status === 0) {
|
|
87
|
+
console.warn('HTTP Status 0 received.');
|
|
88
|
+
}
|
|
89
|
+
// Workaround: Checking if response.body === undefined for Alipay browser #23548
|
|
90
|
+
if (typeof ReadableStream === 'undefined' ||
|
|
91
|
+
response.body === undefined ||
|
|
92
|
+
((_a = response.body) === null || _a === void 0 ? void 0 : _a.getReader) === undefined) {
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
95
|
+
var callbacks_1 = loading[url];
|
|
96
|
+
var reader_1 = response.body.getReader();
|
|
97
|
+
// Nginx needs X-File-Size check
|
|
98
|
+
// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
|
|
99
|
+
var contentLength = response.headers.get('X-File-Size') ||
|
|
100
|
+
response.headers.get('Content-Length');
|
|
101
|
+
var total_1 = contentLength ? parseInt(contentLength) : 0;
|
|
102
|
+
var lengthComputable_1 = total_1 !== 0;
|
|
103
|
+
var loaded_1 = 0;
|
|
104
|
+
// periodically read data into the new stream tracking while download progress
|
|
105
|
+
var stream = new ReadableStream({
|
|
106
|
+
start: function (controller) {
|
|
107
|
+
readData();
|
|
108
|
+
function readData() {
|
|
109
|
+
reader_1.read().then(function (_a) {
|
|
110
|
+
var done = _a.done, value = _a.value;
|
|
111
|
+
if (done) {
|
|
112
|
+
controller.close();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
loaded_1 += value.byteLength;
|
|
116
|
+
var event_1 = new ProgressEvent('progress', {
|
|
117
|
+
lengthComputable: lengthComputable_1,
|
|
118
|
+
loaded: loaded_1,
|
|
119
|
+
total: total_1
|
|
120
|
+
});
|
|
121
|
+
for (var i = 0, il = callbacks_1.length; i < il; i++) {
|
|
122
|
+
var callback = callbacks_1[i];
|
|
123
|
+
if (callback.onProgress)
|
|
124
|
+
callback.onProgress(event_1);
|
|
125
|
+
}
|
|
126
|
+
controller.enqueue(value);
|
|
127
|
+
readData();
|
|
128
|
+
}
|
|
129
|
+
}, function (e) {
|
|
130
|
+
controller.error(e);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return new Response(stream);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
throw new HttpError("fetch for \"".concat(response.url, "\" responded with ").concat(response.status, ": ").concat(response.statusText), response);
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
.then(function (response) {
|
|
142
|
+
switch (responseType) {
|
|
143
|
+
case 'arraybuffer':
|
|
144
|
+
return response.arrayBuffer();
|
|
145
|
+
case 'blob':
|
|
146
|
+
return response.blob();
|
|
147
|
+
case 'document':
|
|
148
|
+
return response.text().then(function (text) {
|
|
149
|
+
var parser = new DOMParser();
|
|
150
|
+
return parser.parseFromString(text, mimeType);
|
|
151
|
+
});
|
|
152
|
+
case 'json':
|
|
153
|
+
return response.json();
|
|
154
|
+
default:
|
|
155
|
+
if (mimeType === undefined) {
|
|
156
|
+
return response.text();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// sniff encoding
|
|
160
|
+
var re = /charset="?([^;"\s]*)"?/i;
|
|
161
|
+
var exec = re.exec(mimeType);
|
|
162
|
+
var label = exec && exec[1] ? exec[1].toLowerCase() : undefined;
|
|
163
|
+
var decoder_1 = new TextDecoder(label);
|
|
164
|
+
return response.arrayBuffer().then(function (ab) { return decoder_1.decode(ab); });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
.then(function (data) {
|
|
169
|
+
var callbacks = loading[url];
|
|
170
|
+
delete loading[url];
|
|
171
|
+
for (var i = 0, il = callbacks.length; i < il; i++) {
|
|
172
|
+
var callback = callbacks[i];
|
|
173
|
+
if (callback.onLoad)
|
|
174
|
+
callback.onLoad(data);
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
.catch(function (err) {
|
|
178
|
+
// Abort errors and other errors are handled the same
|
|
179
|
+
var callbacks = loading[url];
|
|
180
|
+
if (callbacks === undefined) {
|
|
181
|
+
// When onLoad was called and url was deleted in `loading`
|
|
182
|
+
_this.manager.itemError(url);
|
|
183
|
+
throw err;
|
|
184
|
+
}
|
|
185
|
+
delete loading[url];
|
|
186
|
+
for (var i = 0, il = callbacks.length; i < il; i++) {
|
|
187
|
+
var callback = callbacks[i];
|
|
188
|
+
if (callback.onError)
|
|
189
|
+
callback.onError(err);
|
|
190
|
+
}
|
|
191
|
+
_this.manager.itemError(url);
|
|
192
|
+
})
|
|
193
|
+
.finally(function () {
|
|
194
|
+
_this.manager.itemEnd(url);
|
|
195
|
+
});
|
|
196
|
+
this.manager.itemStart(url);
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Change the response type. Valid values are:
|
|
200
|
+
* - text or empty string (default) - returns the data as String.
|
|
201
|
+
* - arraybuffer - loads the data into a ArrayBuffer and returns that.
|
|
202
|
+
* - blob - returns the data as a Blob.
|
|
203
|
+
* - document - parses the file using the DOMParser.
|
|
204
|
+
* - json - parses the file using JSON.parse.
|
|
205
|
+
* @param value
|
|
206
|
+
* @returns Return this object
|
|
207
|
+
*/
|
|
208
|
+
AcCmFileLoader.prototype.setResponseType = function (value) {
|
|
209
|
+
this.responseType = value;
|
|
210
|
+
return this;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Set the expected mimeType of the file being loaded. Note that in many cases this will be determined
|
|
214
|
+
* automatically, so by default it is undefined.
|
|
215
|
+
* @param value The expected mimeType of the file being loaded.
|
|
216
|
+
* @returns Return this object.
|
|
217
|
+
*/
|
|
218
|
+
AcCmFileLoader.prototype.setMimeType = function (value) {
|
|
219
|
+
this.mimeType = value;
|
|
220
|
+
return this;
|
|
221
|
+
};
|
|
222
|
+
return AcCmFileLoader;
|
|
223
|
+
}(AcCmLoader));
|
|
224
|
+
export { AcCmFileLoader };
|
|
225
|
+
//# sourceMappingURL=AcCmFileLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmFileLoader.js","sourceRoot":"","sources":["../../src/loader/AcCmFileLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAA8B,MAAM,cAAc,CAAA;AAOrE,IAAM,OAAO,GAOT,EAAE,CAAA;AAEN;IAAwB,6BAAK;IAE3B,mBAAY,OAAe,EAAE,QAAkB;QAC7C,YAAA,MAAK,YAAC,OAAO,CAAC,SAAA;QACd,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;;IAC1B,CAAC;IACH,gBAAC;AAAD,CAAC,AAND,CAAwB,KAAK,GAM5B;AAkBD;;;GAGG;AACH;IAAoC,kCAAU;IAU5C;;;OAGG;IACH,wBAAY,OAA4B;QACtC,OAAA,MAAK,YAAC,OAAO,CAAC,SAAA;IAChB,CAAC;IAED;;;;;;OAMG;IACH,6BAAI,GAAJ,UACE,GAAW,E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cCmLoaderProgressCallback = (progress: ProgressEvent) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Base class for implementing loaders.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class AcCmLoader {
|
|
7
|
+
manager: AcCmLoadingManager;
|
|
8
|
+
/**
|
|
9
|
+
* The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
|
|
10
|
+
* Default is anonymous.
|
|
11
|
+
*/
|
|
12
|
+
crossOrigin: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the XMLHttpRequest uses credentials. Default is false.
|
|
15
|
+
*/
|
|
16
|
+
withCredentials: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The base path from which the asset will be loaded. Default is the empty string.
|
|
19
|
+
*/
|
|
20
|
+
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* The base path from which additional resources like textures will be loaded.
|
|
23
|
+
* Default is the empty string.
|
|
24
|
+
*/
|
|
25
|
+
resourcePath: string;
|
|
26
|
+
/**
|
|
27
|
+
* The request header used in HTTP request.
|
|
28
|
+
*/
|
|
29
|
+
requestHeader: HeadersInit;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new AcCmLoader instance.
|
|
32
|
+
* @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
|
|
33
|
+
*/
|
|
34
|
+
constructor(manager?: AcCmLoadingManager);
|
|
35
|
+
/**
|
|
36
|
+
* This method needs to be implement by all concrete loaders. It holds the logic for loading
|
|
37
|
+
* the asset from the backend.
|
|
38
|
+
* @param url The path or URL to the file. This can also be a Data URI.
|
|
39
|
+
* @param onLoad (optional) — Will be called when loading completes.
|
|
40
|
+
* @param onProgress (optional) — Will be called while load progresses.
|
|
41
|
+
* @param onError (optional) — Will be called if an error occurs.
|
|
42
|
+
*/
|
|
43
|
+
abstract load(url: string, onLoad?: (data: unknown) => void, onProgress?: AcCmLoaderProgressCallback, onError?: AcCmOnErrorCallback): void;
|
|
44
|
+
/**
|
|
45
|
+
* This method is equivalent to 'load', but returns a Promise.
|
|
46
|
+
* @param url A string containing the path/URL of the file to be loaded.
|
|
47
|
+
* @param onProgress (optional) — A function to be called while the loading is in progress.
|
|
48
|
+
* The argument will be the ProgressEvent instance, which contains .lengthComputable, .total
|
|
49
|
+
* and .loaded. If the server does not set the Content-Length header; .total will be 0.
|
|
50
|
+
* @returns Return a promise.
|
|
51
|
+
*/
|
|
52
|
+
loadAsync(url: string, onProgress: AcCmLoaderProgressCallback): Promise<unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset.
|
|
55
|
+
*/
|
|
56
|
+
parse(_data: unknown): void;
|
|
57
|
+
/**
|
|
58
|
+
* Set the crossOrigin string to implement CORS for loading the url from a different domain that allows
|
|
59
|
+
* CORS.
|
|
60
|
+
* @param crossOrigin The crossOrigin string
|
|
61
|
+
* @returns Return this object
|
|
62
|
+
*/
|
|
63
|
+
setCrossOrigin(crossOrigin: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Set whether the XMLHttpRequest uses credentials such as cookies, authorization headers or TLS
|
|
66
|
+
* client certificates.
|
|
67
|
+
* Note that this has no effect if you are loading files locally or from the same domain.
|
|
68
|
+
* @param value The flag whether the XMLHttpRequest uses credentials.
|
|
69
|
+
* @returns Return this object
|
|
70
|
+
*/
|
|
71
|
+
setWithCredentials(value: boolean): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set the base path for the asset.
|
|
74
|
+
* @param path The base path for the asset.
|
|
75
|
+
* @returns Return this object
|
|
76
|
+
*/
|
|
77
|
+
setPath(path: string): this;
|
|
78
|
+
/**
|
|
79
|
+
* Set the base path for dependent resources like textures.
|
|
80
|
+
* @param resourcePath The base path for dependent resources like textures.
|
|
81
|
+
* @returns Return this object
|
|
82
|
+
*/
|
|
83
|
+
setResourcePath(resourcePath: string): this;
|
|
84
|
+
/**
|
|
85
|
+
* Set the request header used in HTTP request.
|
|
86
|
+
* @param requestHeader key: The name of the header whose value is to be set. value: The value
|
|
87
|
+
* to set as the body of the header.
|
|
88
|
+
* @returns Return this object
|
|
89
|
+
*/
|
|
90
|
+
setRequestHeader(requestHeader: HeadersInit): this;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=AcCmLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmLoader.d.ts","sourceRoot":"","sources":["../../src/loader/AcCmLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,MAAM,0BAA0B,GAAG,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;AAE1E;;GAEG;AACH,8BAAsB,UAAU;IAC9B,OAAO,EAAE,kBAAkB,CAAA;IAC3B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,aAAa,EAAE,WAAW,CAAA;IAE1B;;;OAGG;gBACS,OAAO,CAAC,EAAE,kBAAkB;IASxC;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAChC,UAAU,CAAC,EAAE,0BAA0B,EACvC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI;IAEP;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,0BAA0B;IAM7D;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,OAAO;IAEpB;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM;IAKlC;;;;;;OAMG;IACH,kBAAkB,CAAC,KAAK,EAAE,OAAO;IAKjC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAKpB;;;;OAIG;IACH,eAAe,CAAC,YAAY,EAAE,MAAM;IAKpC;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,WAAW;CAI5C"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DefaultLoadingManager } from './AcCmLoadingManager';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for implementing loaders.
|
|
4
|
+
*/
|
|
5
|
+
var AcCmLoader = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new AcCmLoader instance.
|
|
8
|
+
* @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
|
|
9
|
+
*/
|
|
10
|
+
function AcCmLoader(manager) {
|
|
11
|
+
this.manager = manager !== undefined ? manager : DefaultLoadingManager;
|
|
12
|
+
this.crossOrigin = 'anonymous';
|
|
13
|
+
this.withCredentials = false;
|
|
14
|
+
this.path = '';
|
|
15
|
+
this.resourcePath = '';
|
|
16
|
+
this.requestHeader = {};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This method is equivalent to 'load', but returns a Promise.
|
|
20
|
+
* @param url A string containing the path/URL of the file to be loaded.
|
|
21
|
+
* @param onProgress (optional) — A function to be called while the loading is in progress.
|
|
22
|
+
* The argument will be the ProgressEvent instance, which contains .lengthComputable, .total
|
|
23
|
+
* and .loaded. If the server does not set the Content-Length header; .total will be 0.
|
|
24
|
+
* @returns Return a promise.
|
|
25
|
+
*/
|
|
26
|
+
AcCmLoader.prototype.loadAsync = function (url, onProgress) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
29
|
+
_this.load(url, resolve, onProgress, reject);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset.
|
|
34
|
+
*/
|
|
35
|
+
AcCmLoader.prototype.parse = function (_data) { };
|
|
36
|
+
/**
|
|
37
|
+
* Set the crossOrigin string to implement CORS for loading the url from a different domain that allows
|
|
38
|
+
* CORS.
|
|
39
|
+
* @param crossOrigin The crossOrigin string
|
|
40
|
+
* @returns Return this object
|
|
41
|
+
*/
|
|
42
|
+
AcCmLoader.prototype.setCrossOrigin = function (crossOrigin) {
|
|
43
|
+
this.crossOrigin = crossOrigin;
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Set whether the XMLHttpRequest uses credentials such as cookies, authorization headers or TLS
|
|
48
|
+
* client certificates.
|
|
49
|
+
* Note that this has no effect if you are loading files locally or from the same domain.
|
|
50
|
+
* @param value The flag whether the XMLHttpRequest uses credentials.
|
|
51
|
+
* @returns Return this object
|
|
52
|
+
*/
|
|
53
|
+
AcCmLoader.prototype.setWithCredentials = function (value) {
|
|
54
|
+
this.withCredentials = value;
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Set the base path for the asset.
|
|
59
|
+
* @param path The base path for the asset.
|
|
60
|
+
* @returns Return this object
|
|
61
|
+
*/
|
|
62
|
+
AcCmLoader.prototype.setPath = function (path) {
|
|
63
|
+
this.path = path;
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Set the base path for dependent resources like textures.
|
|
68
|
+
* @param resourcePath The base path for dependent resources like textures.
|
|
69
|
+
* @returns Return this object
|
|
70
|
+
*/
|
|
71
|
+
AcCmLoader.prototype.setResourcePath = function (resourcePath) {
|
|
72
|
+
this.resourcePath = resourcePath;
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Set the request header used in HTTP request.
|
|
77
|
+
* @param requestHeader key: The name of the header whose value is to be set. value: The value
|
|
78
|
+
* to set as the body of the header.
|
|
79
|
+
* @returns Return this object
|
|
80
|
+
*/
|
|
81
|
+
AcCmLoader.prototype.setRequestHeader = function (requestHeader) {
|
|
82
|
+
this.requestHeader = requestHeader;
|
|
83
|
+
return this;
|
|
84
|
+
};
|
|
85
|
+
return AcCmLoader;
|
|
86
|
+
}());
|
|
87
|
+
export { AcCmLoader };
|
|
88
|
+
//# sourceMappingURL=AcCmLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmLoader.js","sourceRoot":"","sources":["../../src/loader/AcCmLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACtB,MAAM,sBAAsB,CAAA;AAI7B;;GAEG;AACH;IAyBE;;;OAGG;IACH,oBAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAA;QACtE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;QACd,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAiBD;;;;;;;OAOG;IACH,8BAAS,GAAT,UAAU,GAAW,EAAE,UAAsC;QAA7D,iBAIC;QAHC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,KAAc,IAAG,CAAC;IAExB;;;;;OAKG;IACH,mCAAc,GAAd,UAAe,WAAmB;QAChC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;OAMG;IACH,uCAAkB,GAAlB,UAAmB,KAAc;QAC/B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,4BAAO,GAAP,UAAQ,IAAY;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,oCAAe,GAAf,UAAgB,YAAoB;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;OAKG;IACH,qCAAgB,GAAhB,UAAiB,aAA0B;QACzC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IACH,iBAAC;AAAD,CAAC,AA7HD,IA6HC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AcCmLoader } from './AcCmLoader';
|
|
2
|
+
/**
|
|
3
|
+
* This function will be called when loading starts. The arguments are:
|
|
4
|
+
* - url: The url of the item just loaded.
|
|
5
|
+
* - itemsLoaded: the number of items already loaded so far.
|
|
6
|
+
* - itemsTotal: the total amount of items to be loaded.
|
|
7
|
+
*/
|
|
8
|
+
export type AcCmOnStartCallback = (url: string, itemsLoaded: number, itemsTotal: number) => void;
|
|
9
|
+
/**
|
|
10
|
+
* This function will be called when all loading is completed.
|
|
11
|
+
*/
|
|
12
|
+
export type AcCmOnLoadCallback = () => void;
|
|
13
|
+
/**
|
|
14
|
+
* This function will be called when an item is complete. The arguments are:
|
|
15
|
+
* - url: The url of the item just loaded.
|
|
16
|
+
* - itemsLoaded: the number of items already loaded so far.
|
|
17
|
+
* - itemsTotal: the total amount of items to be loaded.
|
|
18
|
+
*/
|
|
19
|
+
export type AcCmOnProgressCallback = (url: string, itemsLoaded: number, itemsTotal: number) => void;
|
|
20
|
+
/**
|
|
21
|
+
* This function will be called when any item errors, with the argument:
|
|
22
|
+
* - url: The url of the item that errored.
|
|
23
|
+
*/
|
|
24
|
+
export type AcCmOnErrorCallback = (url: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* The callback called before a request is sent. It may return the original URL, or a new URL to override
|
|
27
|
+
* loading behavior.
|
|
28
|
+
*/
|
|
29
|
+
export type AcCmUrlModifier = (url: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Handles and keeps track of loaded and pending data. A default global instance of this class is
|
|
32
|
+
* created and used by loaders if not supplied manually. In general that should be sufficient,
|
|
33
|
+
* however there are times when it can be useful to have separate loaders - for example if you want
|
|
34
|
+
* to show separate loading bars for objects and textures.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AcCmLoadingManager {
|
|
37
|
+
/**
|
|
38
|
+
* This function will be called when loading starts.
|
|
39
|
+
*/
|
|
40
|
+
onStart?: AcCmOnStartCallback;
|
|
41
|
+
/**
|
|
42
|
+
* This function will be called when all loading is completed. By default this is undefined, unless
|
|
43
|
+
* passed in the constructor.
|
|
44
|
+
*/
|
|
45
|
+
onLoad?: AcCmOnLoadCallback;
|
|
46
|
+
/**
|
|
47
|
+
* This function will be called when an item is complete.
|
|
48
|
+
*/
|
|
49
|
+
onProgress?: AcCmOnProgressCallback;
|
|
50
|
+
/**
|
|
51
|
+
* This function will be called when any item errors.
|
|
52
|
+
*/
|
|
53
|
+
onError?: AcCmOnErrorCallback;
|
|
54
|
+
private isLoading;
|
|
55
|
+
private itemsLoaded;
|
|
56
|
+
private itemsTotal;
|
|
57
|
+
private handlers;
|
|
58
|
+
private urlModifier?;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new AcCmLoadingManager instance
|
|
61
|
+
* @param onLoad this function will be called when all loaders are done.
|
|
62
|
+
* @param onProgress this function will be called when an item is complete.
|
|
63
|
+
* @param onError this function will be called a loader encounters errors.
|
|
64
|
+
*/
|
|
65
|
+
constructor(onLoad?: AcCmOnLoadCallback, onProgress?: AcCmOnProgressCallback, onError?: AcCmOnErrorCallback);
|
|
66
|
+
/**
|
|
67
|
+
* This should be called by any loader using the manager when the loader starts loading an url.
|
|
68
|
+
* @param url The loaded url
|
|
69
|
+
*/
|
|
70
|
+
itemStart(url: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* This should be called by any loader using the manager when the loader ended loading an url.
|
|
73
|
+
* @param url The loaded url
|
|
74
|
+
*/
|
|
75
|
+
itemEnd(url: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* This should be called by any loader using the manager when the loader errors loading an url.
|
|
78
|
+
* @param url The loaded url
|
|
79
|
+
*/
|
|
80
|
+
itemError(url: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. If no URL
|
|
83
|
+
* modifier is set, returns the original URL.
|
|
84
|
+
* @param url The url to load
|
|
85
|
+
* @returns Return resolved URL
|
|
86
|
+
*/
|
|
87
|
+
resolveURL(url: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* If provided, the callback will be passed each resource URL before a request is sent. The callback
|
|
90
|
+
* may return the original URL, or a new URL to override loading behavior. This behavior can be used
|
|
91
|
+
* to load assets from .ZIP files, drag-and-drop APIs, and Data URIs.
|
|
92
|
+
* @param transform URL modifier callback. Called with url argument, and must return resolvedURL.
|
|
93
|
+
* @returns Return this object
|
|
94
|
+
*/
|
|
95
|
+
setURLModifier(transform: AcCmUrlModifier): this;
|
|
96
|
+
/**
|
|
97
|
+
* Register a loader with the given regular expression. Can be used to define what loader should
|
|
98
|
+
* be used in order to load specific files. A typical use case is to overwrite the default loader
|
|
99
|
+
* for textures.
|
|
100
|
+
* @param regex A regular expression.
|
|
101
|
+
* @param loader The loader.
|
|
102
|
+
* @returns Return this object
|
|
103
|
+
*/
|
|
104
|
+
addHandler(regex: RegExp, loader: AcCmLoader): this;
|
|
105
|
+
/**
|
|
106
|
+
* Remove the loader for the given regular expression.
|
|
107
|
+
* @param regex A regular expression.
|
|
108
|
+
* @returns Return this object
|
|
109
|
+
*/
|
|
110
|
+
removeHandler(regex: RegExp): this;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieve the registered loader for the given file path.
|
|
113
|
+
* @param file The file path.
|
|
114
|
+
* @returns Return the registered loader for the given file path.
|
|
115
|
+
*/
|
|
116
|
+
getHandler(file: string): RegExp | AcCmLoader | null;
|
|
117
|
+
}
|
|
118
|
+
export declare const DefaultLoadingManager: AcCmLoadingManager;
|
|
119
|
+
//# sourceMappingURL=AcCmLoadingManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmLoadingManager.d.ts","sourceRoot":"","sources":["../../src/loader/AcCmLoadingManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,KACf,IAAI,CAAA;AAET;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,KACf,IAAI,CAAA;AAET;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;AAEvD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;AAErD;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B;;OAEG;IACI,OAAO,CAAC,EAAE,mBAAmB,CAAA;IACpC;;;OAGG;IACI,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAClC;;OAEG;IACI,UAAU,CAAC,EAAE,sBAAsB,CAAA;IAC1C;;OAEG;IACI,OAAO,CAAC,EAAE,mBAAmB,CAAA;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,WAAW,CAAC,CAA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