nexusframework 0.3.0-beta.72 → 0.3.0-beta.74

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.
Files changed (64) hide show
  1. package/LICENSE.md +55 -55
  2. package/README.md +12 -12
  3. package/about/index.json +5 -5
  4. package/about/index.nhp +4 -4
  5. package/icon.png +0 -0
  6. package/index.d.ts +12 -15
  7. package/index.js +94 -81
  8. package/index.js.map +1 -1
  9. package/index.ts +101 -89
  10. package/indexOfSkeleton.nhp +133 -133
  11. package/legacySkeleton.nhp +22 -22
  12. package/loader/overlay.css +1 -1
  13. package/loader/overlay.html +25 -25
  14. package/loader/overlay.scss +152 -152
  15. package/package.json +102 -89
  16. package/scripts/es5/compat.js +101 -0
  17. package/scripts/es5/compat.js.map +1 -0
  18. package/scripts/es5/compat.min.js +2 -0
  19. package/scripts/es5/compat.min.js.map +1 -0
  20. package/scripts/es5/loader.js +0 -0
  21. package/scripts/es5/loader.js.map +0 -0
  22. package/scripts/es5/loader.min.js +1 -1
  23. package/scripts/es5/loader.min.js.map +0 -0
  24. package/scripts/es5/nexusframeworkclient.js +1092 -1103
  25. package/scripts/es5/nexusframeworkclient.js.map +1 -1
  26. package/scripts/es5/nexusframeworkclient.min.js +1 -1
  27. package/scripts/es5/nexusframeworkclient.min.js.map +1 -1
  28. package/scripts/es6/compat.js +65 -0
  29. package/scripts/es6/compat.js.map +1 -0
  30. package/scripts/es6/compat.min.js +2 -0
  31. package/scripts/es6/compat.min.js.map +1 -0
  32. package/scripts/es6/loader.js +0 -0
  33. package/scripts/es6/loader.js.map +0 -0
  34. package/scripts/es6/loader.min.js +1 -1
  35. package/scripts/es6/loader.min.js.map +0 -0
  36. package/scripts/es6/nexusframeworkclient.js +1026 -1049
  37. package/scripts/es6/nexusframeworkclient.js.map +1 -1
  38. package/scripts/es6/nexusframeworkclient.min.js +1 -1
  39. package/scripts/es6/nexusframeworkclient.min.js.map +1 -1
  40. package/scripts/index.d.ts +259 -251
  41. package/scripts/src/compat.ts +62 -0
  42. package/scripts/src/loader.ts +385 -385
  43. package/scripts/src/nexusframeworkclient.ts +1163 -1185
  44. package/scripts/tsconfig.json +11 -11
  45. package/src/cli.d.ts +1 -0
  46. package/src/cli.js +102 -102
  47. package/src/cli.js.map +1 -1
  48. package/src/cli.ts +101 -101
  49. package/src/compileScripts.d.ts +2 -2
  50. package/src/compileScripts.js +145 -145
  51. package/src/compileScripts.js.map +1 -1
  52. package/src/compileScripts.ts +153 -153
  53. package/src/nexusframework.d.ts +177 -168
  54. package/src/nexusframework.js +3578 -3422
  55. package/src/nexusframework.js.map +1 -1
  56. package/src/nexusframework.ts +3631 -3473
  57. package/templates/basic/package.json +3 -3
  58. package/templates/basic/www/skeleton.nhp +1 -1
  59. package/templates/bootstrap/package.json +2 -2
  60. package/templates/bootstrap/www/skeleton.nhp +1 -1
  61. package/templates/bootstrap-material-design/package.json +2 -2
  62. package/templates/bootstrap-material-design/www/skeleton.nhp +1 -1
  63. package/tsconfig.json +25 -22
  64. package/types.d.ts +612 -564
@@ -1,251 +1,259 @@
1
- /// <reference types="socket.io-client" />
2
- /// <reference types="jquery" />
3
-
4
- declare interface NexusFrameworkResource {
5
- name: string;
6
- type: string;
7
- source: string;
8
- inline?: boolean;
9
- integrity?: string;
10
- dependencies: string[];
11
- }
12
- declare interface NexusFrameworkLoaderData {
13
- [0]: string[];
14
- [1]: NexusFrameworkResource[];
15
- }
16
- declare interface NexusFrameworkLoader {
17
- load(data: NexusFrameworkLoaderData, onsuccess?: () => void): void;
18
- /**
19
- * Loads a resource.
20
- * Downloads the file asynchroniously and reads any header for @ tags.
21
- * After that, queues it for download, and returns an info object for the script when complete.
22
- *
23
- * @param type The type, script or style
24
- * @param name The name of the resource
25
- * @param source The source of the resource
26
- * @param cb The callback
27
- * @param deps The dependencies
28
- * @param inlineOrVersion True or String, inline or version.
29
- */
30
- loadResource(type: string, script: string, cb?: (err?: Error) => void, deps?: string[], inlineOrIntegrity?: boolean | string, name?: string): void;
31
- /**
32
- * Queries the list of requested resources.
33
- * Each resource is listed as `type:name`.
34
- */
35
- requestedResources(): string[];
36
- /**
37
- * Get the source for a given resource.
38
- */
39
- resourceSource(key: string): string;
40
- /**
41
- * Show the specified error to the user.
42
- */
43
- showError(err: Error): HTMLElement | HTMLCollection;
44
- /**
45
- * Clear the error screen.
46
- */
47
- resetError(): void;
48
- /**
49
- * Show the specified error to the user.
50
- */
51
- showProgress(cb?: () => void, title?: string, message?: string): HTMLElement | HTMLCollection;
52
- /**
53
- * Clear the error screen.
54
- */
55
- resetProgress(): void;
56
- }
57
- declare interface NexusFrameworkTransportResponse {
58
- /**
59
- * The response url.
60
- */
61
- readonly url: string;
62
- /**
63
- * The response code;
64
- */
65
- readonly code: number;
66
- /**
67
- * Parses a JSON representation from the response string or throws an error.
68
- */
69
- readonly contentFromJSON: any;
70
- /**
71
- * The content as a String.
72
- */
73
- readonly contentAsString: string;
74
- /**
75
- * The length in bytes of
76
- */
77
- readonly contentLength: number;
78
- /**
79
- * A map of response headers, each header can occur more than once.
80
- */
81
- readonly headers: {[index: string]: string[]};
82
- /**
83
- * Whether or not this request posted data.
84
- */
85
- readonly hadData?: boolean;
86
- }
87
- declare interface NexusFrameworkPageSystemResponse {
88
- data: any;
89
- code: number;
90
- headers: {[index: string]: string[]};
91
- }
92
- declare interface NexusFrameworkPageSystemOptions {
93
- /**
94
- * Override the built in way of handling page responses.
95
- *
96
- * @returns True when handled correctly, false to reload the page to the request url.
97
- */
98
- handler?: (res: NexusFrameworkTransportResponse, contentReady: (err?: Error) => void) => void;
99
- /**
100
- * Method to call before attempting to make a page request.
101
- *
102
- * @returns True to continue, False to abort.
103
- */
104
- prerequest?: (path: string) => boolean;
105
- /**
106
- * Disables using the loader-progress elements.
107
- */
108
- noprogress?: boolean;
109
- /**
110
- * Disables using SocketIO for the Page System.
111
- * The Page System over SocketIO cannot pass some HttpOnly cookies,
112
- * as such this might be required for some websites.
113
- */
114
- nopagesysio?: boolean;
115
- /**
116
- * The timing in milliseconds the page transition animation will take.
117
- * Defaults to 500.
118
- */
119
- animationTiming?: number;
120
- /**
121
- * The size in bytes worth of data to allow storing for caching page history.
122
- * Defaults to 25000000 (25mb)
123
- */
124
- pageHistoryCacheSize?: number;
125
- /**
126
- * Disables using SocketIO, which would be used otherwise, when available
127
- */
128
- noio?: boolean;
129
- }
130
- declare interface NexusFrameworkEvents {
131
- /**
132
- * Add an event listener for when pages are loaded via the dynamic page system.
133
- */
134
- on(event: "page", cb: (baseurl: string, path: string) => void): void;
135
- /**
136
- * Add an event listener for a specific event.
137
- */
138
- on(event: string, cb: (...args: any[]) => void): void;
139
- /**
140
- * Remove a event listener for when pages are loaded via the dynamic page system.
141
- */
142
- off(event: "page", cb: (baseurl: string, path: string) => void): void;
143
- /**
144
- * Remove n event listener for a specific event.
145
- */
146
- off(event: string, cb: (...args: any[]) => void): void;
147
- }
148
- /*declare interface NexusFrameworkComponentHelper extends NexusFrameworkEvents {
149
-
150
- }*/
151
- declare interface NexusFrameworkComponent {
152
- create(element: HTMLElement/*, createHelper: () => NexusFrameworkComponentHelper*/): void;
153
- destroy(): void;
154
-
155
- restore(data: any): void;
156
- save(): any;
157
- }
158
- declare interface NexusFrameworkComponentFactory {
159
- new (): NexusFrameworkComponent;
160
- }
161
- declare interface NexusFrameworkAnalyticsAdapter {
162
- reportError(err: Error): void;
163
- reportPage(path?: string): void;
164
- reportEvent(category: string, action: string, label?: string, value?: number): void;
165
- }
166
- declare interface NexusFrameworkClient extends NexusFrameworkEvents {
167
- /**
168
- * The Socket.IO instance, if enabled and available.
169
- */
170
- readonly io: SocketIOClient.Socket;
171
- /**
172
- * The base URL for this client.
173
- */
174
- readonly url: string;
175
- /**
176
- * The analytics adapter.
177
- */
178
- analytics: NexusFrameworkAnalyticsAdapter;
179
-
180
- /**
181
- * Initialize the page system.
182
- */
183
- initPageSystem(opts?: NexusFrameworkPageSystemOptions): void;
184
- /**
185
- * Loads a page, relative to the root URL for the website.
186
- */
187
- requestPage(path: string, post?: any): void;
188
-
189
- /**
190
- * Register a component by selector.
191
- */
192
- registerComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
193
- /**
194
- * Unregister a component by selector.
195
- */
196
- unregisterComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
197
- /**
198
- * Initialize and create all components within root
199
- */
200
- createComponents(root: HTMLElement): void;
201
- /**
202
- * Destroy all components within root
203
- */
204
- destroyComponents(root: HTMLElement): void;
205
- /**
206
- * Save components in root into a state object
207
- */
208
- saveComponents(root: HTMLElement): Object;
209
- /**
210
- * Restore components in root from a state object
211
- */
212
- restoreComponents(root: HTMLElement, state: Object): void;
213
-
214
- /**
215
- * Disable an element and its children.
216
- *
217
- * @param root The root element, by default document.body
218
- */
219
- disableAll(root?: HTMLElement): void;
220
- /**
221
- * Enable an element and its children.
222
- *
223
- * @param root The root element, by default document.body
224
- */
225
- enableAll(root?: HTMLElement): void;
226
-
227
- /**
228
- * Remove a event listener for when pages are loaded via the dynamic page system.
229
- */
230
- emit(event: string, ...args: any[]): void;
231
- }
232
- declare interface NexusFrameworkTransport {
233
- get(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
234
- head(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
235
- put(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
236
- post(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
237
- execute(method: string, url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
238
- del(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void): void;
239
- }
240
- declare interface GoogleAnalytics {
241
- (cmd: string, ...args: any[]): void;
242
- }
243
- declare interface Window {
244
- NexusFrameworkImpl?: any;
245
- NexusFrameworkLoader?: NexusFrameworkLoader;
246
- NexusFrameworkTransport?: NexusFrameworkTransport;
247
- NexusFrameworkClient?: NexusFrameworkClient;
248
- io?: SocketIOClientStatic;
249
- jQuery?: JQueryStatic;
250
- ga?: GoogleAnalytics;
251
- }
1
+ /// <reference types="socket.io-client" />
2
+ /// <reference types="jquery" />
3
+
4
+ declare interface NexusFrameworkResource {
5
+ name: string;
6
+ type: string;
7
+ source: string;
8
+ inline?: boolean;
9
+ integrity?: string;
10
+ dependencies: string[];
11
+ }
12
+ declare interface NexusFrameworkLoaderData {
13
+ [0]: string[];
14
+ [1]: NexusFrameworkResource[];
15
+ }
16
+ declare interface NexusFrameworkLoader {
17
+ load(data: NexusFrameworkLoaderData, onsuccess?: () => void): void;
18
+ /**
19
+ * Loads a resource.
20
+ * Downloads the file asynchroniously and reads any header for @ tags.
21
+ * After that, queues it for download, and returns an info object for the script when complete.
22
+ *
23
+ * @param type The type, script or style
24
+ * @param name The name of the resource
25
+ * @param source The source of the resource
26
+ * @param cb The callback
27
+ * @param deps The dependencies
28
+ * @param inlineOrVersion True or String, inline or version.
29
+ */
30
+ loadResource(type: string, script: string, cb?: (err?: Error) => void, deps?: string[], inlineOrIntegrity?: boolean | string, name?: string): void;
31
+ /**
32
+ * Queries the list of requested resources.
33
+ * Each resource is listed as `type:name`.
34
+ */
35
+ requestedResources(): string[];
36
+ /**
37
+ * Get the source for a given resource.
38
+ */
39
+ resourceSource(key: string): string;
40
+ /**
41
+ * Show the specified error to the user.
42
+ */
43
+ showError(err: Error): HTMLElement | HTMLCollection;
44
+ /**
45
+ * Clear the error screen.
46
+ */
47
+ resetError(): void;
48
+ /**
49
+ * Show the specified error to the user.
50
+ */
51
+ showProgress(cb?: () => void, title?: string, message?: string): HTMLElement | HTMLCollection;
52
+ /**
53
+ * Clear the error screen.
54
+ */
55
+ resetProgress(): void;
56
+ }
57
+ declare interface NexusFrameworkTransportResponse {
58
+ /**
59
+ * The response url.
60
+ */
61
+ readonly url: string;
62
+ /**
63
+ * The response code;
64
+ */
65
+ readonly code: number;
66
+ /**
67
+ * Parses a JSON representation from the response string or throws an error.
68
+ */
69
+ readonly contentFromJSON: any;
70
+ /**
71
+ * Parses a BSON representation from the response string or throws an error.
72
+ */
73
+ readonly contentFromBSON: any;
74
+ /**
75
+ * The content as a String.
76
+ */
77
+ readonly contentAsString: string;
78
+ /**
79
+ * The content as an ArrayBuffer.
80
+ */
81
+ readonly contentAsArrayBuffer: ArrayBuffer;
82
+ /**
83
+ * The length in bytes of
84
+ */
85
+ readonly contentLength: number;
86
+ /**
87
+ * A map of response headers, each header can occur more than once.
88
+ */
89
+ readonly headers: {[index: string]: string[]};
90
+ /**
91
+ * Whether or not this request posted data.
92
+ */
93
+ readonly hadData?: boolean;
94
+ }
95
+ declare interface NexusFrameworkPageSystemResponse {
96
+ data: any;
97
+ code: number;
98
+ headers: {[index: string]: string[]};
99
+ }
100
+ declare interface NexusFrameworkPageSystemOptions {
101
+ /**
102
+ * Override the built in way of handling page responses.
103
+ *
104
+ * @returns True when handled correctly, false to reload the page to the request url.
105
+ */
106
+ handler?: (res: NexusFrameworkTransportResponse, contentReady: (err?: Error) => void) => void;
107
+ /**
108
+ * Method to call before attempting to make a page request.
109
+ *
110
+ * @returns True to continue, False to abort.
111
+ */
112
+ prerequest?: (path: string) => boolean;
113
+ /**
114
+ * Disables using the loader-progress elements.
115
+ */
116
+ noprogress?: boolean;
117
+ /**
118
+ * The timing in milliseconds the page transition animation will take.
119
+ * Defaults to 500.
120
+ */
121
+ animationTiming?: number;
122
+ /**
123
+ * The size in bytes worth of data to allow storing for caching page history.
124
+ * Defaults to 25000000 (25mb)
125
+ */
126
+ pageHistoryCacheSize?: number;
127
+ /**
128
+ * Disables using SocketIO for the Page System.
129
+ * The Page System over SocketIO cannot pass some HttpOnly cookies,
130
+ * as such this might be required for some websites.
131
+ */
132
+ noio?: boolean;
133
+ }
134
+ declare interface NexusFrameworkEvents {
135
+ /**
136
+ * Add an event listener for when pages are loaded via the dynamic page system.
137
+ */
138
+ on(event: "page", cb: (baseurl: string, path: string) => void): void;
139
+ /**
140
+ * Add an event listener for a specific event.
141
+ */
142
+ on(event: string, cb: (...args: any[]) => void): void;
143
+ /**
144
+ * Remove a event listener for when pages are loaded via the dynamic page system.
145
+ */
146
+ off(event: "page", cb: (baseurl: string, path: string) => void): void;
147
+ /**
148
+ * Remove n event listener for a specific event.
149
+ */
150
+ off(event: string, cb: (...args: any[]) => void): void;
151
+ }
152
+ /*declare interface NexusFrameworkComponentHelper extends NexusFrameworkEvents {
153
+
154
+ }*/
155
+ declare interface NexusFrameworkComponent {
156
+ create(element: HTMLElement/*, createHelper: () => NexusFrameworkComponentHelper*/): void;
157
+ destroy(): void;
158
+
159
+ restore(data: any): void;
160
+ save(): any;
161
+ }
162
+ declare interface NexusFrameworkComponentFactory {
163
+ new (): NexusFrameworkComponent;
164
+ }
165
+ declare interface NexusFrameworkAnalyticsAdapter {
166
+ reportError(err: Error): void;
167
+ reportPage(path?: string): void;
168
+ reportEvent(category: string, action: string, label?: string, value?: number): void;
169
+ }
170
+ declare interface NexusFrameworkClient extends NexusFrameworkEvents {
171
+ /**
172
+ * The Socket.IO instance, if enabled and available.
173
+ */
174
+ readonly io: SocketIOClient.Socket;
175
+ /**
176
+ * The base URL for this client.
177
+ */
178
+ readonly url: string;
179
+ /**
180
+ * The ID of the current user, if any.
181
+ */
182
+ readonly currentUser: string | undefined;
183
+ /**
184
+ * The analytics adapter.
185
+ */
186
+ analytics: NexusFrameworkAnalyticsAdapter;
187
+
188
+ /**
189
+ * Initialize the page system.
190
+ */
191
+ initPageSystem(opts?: NexusFrameworkPageSystemOptions): void;
192
+ /**
193
+ * Loads a page, relative to the root URL for the website.
194
+ */
195
+ requestPage(path: string, post?: any): void;
196
+
197
+ /**
198
+ * Register a component by selector.
199
+ */
200
+ registerComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
201
+ /**
202
+ * Unregister a component by selector.
203
+ */
204
+ unregisterComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
205
+ /**
206
+ * Initialize and create all components within root
207
+ */
208
+ createComponents(root: HTMLElement): void;
209
+ /**
210
+ * Destroy all components within root
211
+ */
212
+ destroyComponents(root: HTMLElement): void;
213
+ /**
214
+ * Save components in root into a state object
215
+ */
216
+ saveComponents(root: HTMLElement): Object;
217
+ /**
218
+ * Restore components in root from a state object
219
+ */
220
+ restoreComponents(root: HTMLElement, state: Object): void;
221
+
222
+ /**
223
+ * Disable an element and its children.
224
+ *
225
+ * @param root The root element, by default document.body
226
+ */
227
+ disableAll(root?: HTMLElement): void;
228
+ /**
229
+ * Enable an element and its children.
230
+ *
231
+ * @param root The root element, by default document.body
232
+ */
233
+ enableAll(root?: HTMLElement): void;
234
+
235
+ /**
236
+ * Remove a event listener for when pages are loaded via the dynamic page system.
237
+ */
238
+ emit(event: string, ...args: any[]): void;
239
+ }
240
+ declare interface NexusFrameworkTransport {
241
+ get(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
242
+ head(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
243
+ put(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
244
+ post(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
245
+ execute(method: string, url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
246
+ del(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
247
+ }
248
+ declare interface GoogleAnalytics {
249
+ (cmd: string, ...args: any[]): void;
250
+ }
251
+ declare interface Window {
252
+ NexusFrameworkImpl?: any;
253
+ NexusFrameworkLoader?: NexusFrameworkLoader;
254
+ NexusFrameworkTransport?: NexusFrameworkTransport;
255
+ NexusFrameworkClient?: NexusFrameworkClient;
256
+ io?: SocketIOClientStatic;
257
+ jQuery?: JQueryStatic;
258
+ ga?: GoogleAnalytics;
259
+ }
@@ -0,0 +1,62 @@
1
+ /// <reference path="../index.d.ts" />
2
+ (function(window) {
3
+ var Buffer;
4
+ const TextDecoder: {new (encoding: string): TextDecoder} = window['TextDecoder'];
5
+ const TextEncoder: {new (encoding: string): TextEncoder} = window['TextEncoder'];
6
+ class BufferBase extends Uint8Array {
7
+ static isBuffer(object: any) {
8
+ return object instanceof Buffer;
9
+ }
10
+ slice(start = 0, end = this.length) {
11
+ return new Buffer(this.buffer.slice(start, end));
12
+ }
13
+ write(index: number, val: number) {
14
+ this[index] = val;
15
+ }
16
+ copy(from: Uint8Array, offset = 0, start = 0, end = from.length) {
17
+ const copylen = end - start + offset;
18
+ for(var i=offset; i<copylen; i++)
19
+ this[offset] = from[start + i];
20
+ }
21
+ }
22
+ if (TextDecoder && TextEncoder) {
23
+ class BufferImpl extends BufferBase {
24
+ toString(encoding?: string, start = 0, end = this.length) {
25
+ const decoder = new TextDecoder(encoding);
26
+ if (start > 0 || end < this.length)
27
+ return decoder.decode(this.slice(start, end));
28
+ return decoder.decode(this);
29
+ }
30
+ }
31
+ ((Buffer = BufferImpl) as any)['from'] = function(data, encoding = "utf8") {
32
+ const encoder = new TextEncoder(encoding);
33
+ const encoded = encoder.encode(data);
34
+ const buffer = new Buffer(encoded.length);
35
+ buffer.copy(encoded);
36
+ return buffer;
37
+ };
38
+ } else {
39
+ class BufferImpl extends BufferBase {
40
+ toString(encoding?: string, start = 0, end = this.length) {
41
+ var str = "";
42
+ for(var i=start; i<end; i++)
43
+ str += String.fromCharCode(this[i]);
44
+ return str;
45
+ }
46
+ }
47
+ ((Buffer = BufferImpl) as any)['from'] = function(data, encoding = "utf8") {
48
+ if (encoding === "utf8") {
49
+ data = "" + data;
50
+ const len = data.length;
51
+ const buff = new Buffer(len);
52
+ for(var i=0; i<len; i++)
53
+ buff[i] = data.charCodeAt(i) & 0xFF;
54
+ console.log(buff);
55
+ return buff;
56
+ } else
57
+ return new Buffer(data);
58
+ };
59
+ }
60
+ window['Buffer'] = Buffer;
61
+ window['global'] = window;
62
+ })(window);