@lango-project/lango-js 0.1.2 → 0.1.4
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/NOTICE +5 -0
- package/README.md +3 -1
- package/package.json +1 -1
- package/src/cli.mjs +8 -2
- package/src/compiler.mjs +198 -58
- package/src/runtime.mjs +92 -1
- package/src/template/package.json +4 -0
- package/src/vendor/xmldom/conventions.js +429 -0
- package/src/vendor/xmldom/dom-parser.js +591 -0
- package/src/vendor/xmldom/dom.js +3759 -0
- package/src/vendor/xmldom/entities.js +2171 -0
- package/src/vendor/xmldom/errors.js +205 -0
- package/src/vendor/xmldom/grammar.js +559 -0
- package/src/vendor/xmldom/index.js +41 -0
- package/src/vendor/xmldom/sax.js +983 -0
- package/src/vendor/xmldom.LICENSE.md +8 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var conventions = require('./conventions');
|
|
4
|
+
|
|
5
|
+
function extendError(constructor, writableName) {
|
|
6
|
+
constructor.prototype = Object.create(Error.prototype, {
|
|
7
|
+
constructor: { value: constructor },
|
|
8
|
+
name: { value: constructor.name, enumerable: true, writable: writableName },
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var DOMExceptionName = conventions.freeze({
|
|
13
|
+
/**
|
|
14
|
+
* the default value as defined by the spec
|
|
15
|
+
*/
|
|
16
|
+
Error: 'Error',
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
* Use RangeError instead.
|
|
20
|
+
*/
|
|
21
|
+
IndexSizeError: 'IndexSizeError',
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated
|
|
24
|
+
* Just to match the related static code, not part of the spec.
|
|
25
|
+
*/
|
|
26
|
+
DomstringSizeError: 'DomstringSizeError',
|
|
27
|
+
HierarchyRequestError: 'HierarchyRequestError',
|
|
28
|
+
WrongDocumentError: 'WrongDocumentError',
|
|
29
|
+
InvalidCharacterError: 'InvalidCharacterError',
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated
|
|
32
|
+
* Just to match the related static code, not part of the spec.
|
|
33
|
+
*/
|
|
34
|
+
NoDataAllowedError: 'NoDataAllowedError',
|
|
35
|
+
NoModificationAllowedError: 'NoModificationAllowedError',
|
|
36
|
+
NotFoundError: 'NotFoundError',
|
|
37
|
+
NotSupportedError: 'NotSupportedError',
|
|
38
|
+
InUseAttributeError: 'InUseAttributeError',
|
|
39
|
+
InvalidStateError: 'InvalidStateError',
|
|
40
|
+
SyntaxError: 'SyntaxError',
|
|
41
|
+
InvalidModificationError: 'InvalidModificationError',
|
|
42
|
+
NamespaceError: 'NamespaceError',
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
* Use TypeError for invalid arguments,
|
|
46
|
+
* "NotSupportedError" DOMException for unsupported operations,
|
|
47
|
+
* and "NotAllowedError" DOMException for denied requests instead.
|
|
48
|
+
*/
|
|
49
|
+
InvalidAccessError: 'InvalidAccessError',
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated
|
|
52
|
+
* Just to match the related static code, not part of the spec.
|
|
53
|
+
*/
|
|
54
|
+
ValidationError: 'ValidationError',
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
* Use TypeError instead.
|
|
58
|
+
*/
|
|
59
|
+
TypeMismatchError: 'TypeMismatchError',
|
|
60
|
+
SecurityError: 'SecurityError',
|
|
61
|
+
NetworkError: 'NetworkError',
|
|
62
|
+
AbortError: 'AbortError',
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
* Just to match the related static code, not part of the spec.
|
|
66
|
+
*/
|
|
67
|
+
URLMismatchError: 'URLMismatchError',
|
|
68
|
+
QuotaExceededError: 'QuotaExceededError',
|
|
69
|
+
TimeoutError: 'TimeoutError',
|
|
70
|
+
InvalidNodeTypeError: 'InvalidNodeTypeError',
|
|
71
|
+
DataCloneError: 'DataCloneError',
|
|
72
|
+
EncodingError: 'EncodingError',
|
|
73
|
+
NotReadableError: 'NotReadableError',
|
|
74
|
+
UnknownError: 'UnknownError',
|
|
75
|
+
ConstraintError: 'ConstraintError',
|
|
76
|
+
DataError: 'DataError',
|
|
77
|
+
TransactionInactiveError: 'TransactionInactiveError',
|
|
78
|
+
ReadOnlyError: 'ReadOnlyError',
|
|
79
|
+
VersionError: 'VersionError',
|
|
80
|
+
OperationError: 'OperationError',
|
|
81
|
+
NotAllowedError: 'NotAllowedError',
|
|
82
|
+
OptOutError: 'OptOutError',
|
|
83
|
+
});
|
|
84
|
+
var DOMExceptionNames = Object.keys(DOMExceptionName);
|
|
85
|
+
|
|
86
|
+
function isValidDomExceptionCode(value) {
|
|
87
|
+
return typeof value === 'number' && value >= 1 && value <= 25;
|
|
88
|
+
}
|
|
89
|
+
function endsWithError(value) {
|
|
90
|
+
return typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation
|
|
94
|
+
* is impossible to perform (either for logical reasons, because data is lost, or because the
|
|
95
|
+
* implementation has become unstable). In general, DOM methods return specific error values in
|
|
96
|
+
* ordinary processing situations, such as out-of-bound errors when using NodeList.
|
|
97
|
+
*
|
|
98
|
+
* Implementations should raise other exceptions under other circumstances. For example,
|
|
99
|
+
* implementations should raise an implementation-dependent exception if a null argument is
|
|
100
|
+
* passed when null was not expected.
|
|
101
|
+
*
|
|
102
|
+
* This implementation supports the following usages:
|
|
103
|
+
* 1. according to the living standard (both arguments are optional):
|
|
104
|
+
* ```
|
|
105
|
+
* new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
|
|
106
|
+
* ```
|
|
107
|
+
* 2. according to previous xmldom implementation (only the first argument is required):
|
|
108
|
+
* ```
|
|
109
|
+
* new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
|
|
110
|
+
* ```
|
|
111
|
+
* both result in the proper name being set.
|
|
112
|
+
*
|
|
113
|
+
* @class DOMException
|
|
114
|
+
* @param {number | string} messageOrCode
|
|
115
|
+
* The reason why an operation is not acceptable.
|
|
116
|
+
* If it is a number, it is used to determine the `name`, see
|
|
117
|
+
* {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}
|
|
118
|
+
* @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]
|
|
119
|
+
* The `name` to use for the error.
|
|
120
|
+
* If `messageOrCode` is a number, this arguments is used as the `message` instead.
|
|
121
|
+
* @augments Error
|
|
122
|
+
* @see https://webidl.spec.whatwg.org/#idl-DOMException
|
|
123
|
+
* @see https://webidl.spec.whatwg.org/#dfn-error-names-table
|
|
124
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
|
|
125
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
|
126
|
+
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
|
127
|
+
*/
|
|
128
|
+
function DOMException(messageOrCode, nameOrMessage) {
|
|
129
|
+
// support old way of passing arguments: first argument is a valid number
|
|
130
|
+
if (isValidDomExceptionCode(messageOrCode)) {
|
|
131
|
+
this.name = DOMExceptionNames[messageOrCode];
|
|
132
|
+
this.message = nameOrMessage || '';
|
|
133
|
+
} else {
|
|
134
|
+
this.message = messageOrCode;
|
|
135
|
+
this.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;
|
|
136
|
+
}
|
|
137
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
|
|
138
|
+
}
|
|
139
|
+
extendError(DOMException, true);
|
|
140
|
+
Object.defineProperties(DOMException.prototype, {
|
|
141
|
+
code: {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function () {
|
|
144
|
+
var code = DOMExceptionNames.indexOf(this.name);
|
|
145
|
+
if (isValidDomExceptionCode(code)) return code;
|
|
146
|
+
return 0;
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
var ExceptionCode = {
|
|
152
|
+
INDEX_SIZE_ERR: 1,
|
|
153
|
+
DOMSTRING_SIZE_ERR: 2,
|
|
154
|
+
HIERARCHY_REQUEST_ERR: 3,
|
|
155
|
+
WRONG_DOCUMENT_ERR: 4,
|
|
156
|
+
INVALID_CHARACTER_ERR: 5,
|
|
157
|
+
NO_DATA_ALLOWED_ERR: 6,
|
|
158
|
+
NO_MODIFICATION_ALLOWED_ERR: 7,
|
|
159
|
+
NOT_FOUND_ERR: 8,
|
|
160
|
+
NOT_SUPPORTED_ERR: 9,
|
|
161
|
+
INUSE_ATTRIBUTE_ERR: 10,
|
|
162
|
+
INVALID_STATE_ERR: 11,
|
|
163
|
+
SYNTAX_ERR: 12,
|
|
164
|
+
INVALID_MODIFICATION_ERR: 13,
|
|
165
|
+
NAMESPACE_ERR: 14,
|
|
166
|
+
INVALID_ACCESS_ERR: 15,
|
|
167
|
+
VALIDATION_ERR: 16,
|
|
168
|
+
TYPE_MISMATCH_ERR: 17,
|
|
169
|
+
SECURITY_ERR: 18,
|
|
170
|
+
NETWORK_ERR: 19,
|
|
171
|
+
ABORT_ERR: 20,
|
|
172
|
+
URL_MISMATCH_ERR: 21,
|
|
173
|
+
QUOTA_EXCEEDED_ERR: 22,
|
|
174
|
+
TIMEOUT_ERR: 23,
|
|
175
|
+
INVALID_NODE_TYPE_ERR: 24,
|
|
176
|
+
DATA_CLONE_ERR: 25,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
var entries = Object.entries(ExceptionCode);
|
|
180
|
+
for (var i = 0; i < entries.length; i++) {
|
|
181
|
+
var key = entries[i][0];
|
|
182
|
+
DOMException[key] = entries[i][1];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
|
187
|
+
*
|
|
188
|
+
* @class
|
|
189
|
+
* @param {string} message
|
|
190
|
+
* @param {any} [locator]
|
|
191
|
+
* @param {Error} [cause]
|
|
192
|
+
* The error that caused this one, e.g. a `DOMException` thrown while building the DOM.
|
|
193
|
+
*/
|
|
194
|
+
function ParseError(message, locator, cause) {
|
|
195
|
+
this.message = message;
|
|
196
|
+
this.locator = locator;
|
|
197
|
+
this.cause = cause;
|
|
198
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
|
|
199
|
+
}
|
|
200
|
+
extendError(ParseError);
|
|
201
|
+
|
|
202
|
+
exports.DOMException = DOMException;
|
|
203
|
+
exports.DOMExceptionName = DOMExceptionName;
|
|
204
|
+
exports.ExceptionCode = ExceptionCode;
|
|
205
|
+
exports.ParseError = ParseError;
|