jscrewit 2.34.0 → 2.35.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/api-doc/README.md +85 -11
- package/api-doc/interfaces/CustomFeature.md +2 -2
- package/api-doc/interfaces/ElementaryFeature.md +2 -2
- package/api-doc/interfaces/EncodeOptions.md +4 -4
- package/api-doc/interfaces/Feature.md +7 -8
- package/api-doc/interfaces/FeatureAll.md +57 -57
- package/api-doc/interfaces/FeatureConstructor.md +79 -80
- package/api-doc/interfaces/PredefinedFeature.md +2 -2
- package/api-doc/interfaces/default.md +0 -2
- package/api-doc/interfaces/encode.md +1 -1
- package/lib/encode.d.ts +14 -7
- package/lib/feature.d.ts +19 -15
- package/lib/jscrewit.d.ts +2 -2
- package/lib/jscrewit.js +240 -162
- package/lib/jscrewit.min.js +2 -2
- package/package.json +2 -2
package/lib/encode.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { FeatureElementOrCompatibleArray } from './feature';
|
|
1
|
+
import type { FeatureElementOrCompatibleArray } from './feature';
|
|
2
2
|
|
|
3
3
|
export interface EncodeOptions
|
|
4
4
|
{
|
|
5
5
|
/**
|
|
6
6
|
* Specifies the features available in the engines that evaluate the encoded output.
|
|
7
7
|
*
|
|
8
|
-
* If this parameter is unspecified,
|
|
9
|
-
* ensures maximum compatibility but also generates
|
|
8
|
+
* If this parameter is unspecified, {@link FeatureConstructor.DEFAULT |
|
|
9
|
+
* `JScrewIt.Feature.DEFAULT`} is assumed: this ensures maximum compatibility but also generates
|
|
10
|
+
* the largest code.
|
|
10
11
|
* To generate shorter code, specify all features available in all target engines explicitly.
|
|
11
12
|
*/
|
|
12
|
-
features?: FeatureElementOrCompatibleArray;
|
|
13
|
+
features?: FeatureElementOrCompatibleArray | undefined;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* This option controls the type of code generated from the given input.
|
|
@@ -59,7 +60,7 @@ export interface EncodeOptions
|
|
|
59
60
|
*
|
|
60
61
|
* </dl>
|
|
61
62
|
*/
|
|
62
|
-
runAs?:
|
|
63
|
+
runAs?: RunAs | undefined;
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
* If this parameter is truthy, lines in the beginning and in the end of the file containing
|
|
@@ -72,12 +73,18 @@ export interface EncodeOptions
|
|
|
72
73
|
* Using this option may produce unexpected results if the input is not well-formed JavaScript
|
|
73
74
|
* code.
|
|
74
75
|
*/
|
|
75
|
-
trimCode?: boolean;
|
|
76
|
+
trimCode?: boolean | undefined;
|
|
76
77
|
|
|
77
78
|
/** An alias for `runAs`. */
|
|
78
|
-
wrapWith?:
|
|
79
|
+
wrapWith?: RunAs | undefined;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Values of this type control the type of code generated from a given input.
|
|
84
|
+
* See {@link EncodeOptions.runAs | `EncodeOptions.runAs`} for the meaning of each possible value.
|
|
85
|
+
*/
|
|
86
|
+
type RunAs = 'call' | 'eval' | 'express' | 'express-call' | 'express-eval' | 'none';
|
|
87
|
+
|
|
81
88
|
interface encode
|
|
82
89
|
{
|
|
83
90
|
/**
|
package/lib/feature.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementaryFeatureName, FeatureAll, PredefinedFeatureName } from './feature-all';
|
|
1
|
+
import type { ElementaryFeatureName, FeatureAll, PredefinedFeatureName } from './feature-all';
|
|
2
2
|
|
|
3
3
|
export interface CustomFeature extends Feature
|
|
4
4
|
{
|
|
@@ -16,8 +16,8 @@ export interface ElementaryFeature extends PredefinedFeature
|
|
|
16
16
|
* length of its output are available in a particular JavaScript engine.
|
|
17
17
|
*
|
|
18
18
|
* JScrewIt comes with a set of predefined feature objects exposed as property values of
|
|
19
|
-
* `JScrewIt.Feature` or
|
|
20
|
-
* name or alias.
|
|
19
|
+
* `JScrewIt.Feature` or {@link FeatureConstructor.ALL | `JScrewIt.Feature.ALL`}, where the property
|
|
20
|
+
* name is the feature's name or alias.
|
|
21
21
|
*
|
|
22
22
|
* Besides these predefined features, it is possible to construct custom features from the union or
|
|
23
23
|
* intersection of other features.
|
|
@@ -28,10 +28,10 @@ export interface ElementaryFeature extends PredefinedFeature
|
|
|
28
28
|
* their elementary components.
|
|
29
29
|
* All other features, called *composite* features, can be constructed as a union of zero or more
|
|
30
30
|
* elementary features.
|
|
31
|
-
* Two of the predefined composite features are particularly important:
|
|
32
|
-
* the empty feature, indicating that no elementary
|
|
33
|
-
*
|
|
34
|
-
* environment.
|
|
31
|
+
* Two of the predefined composite features are particularly important: {@link
|
|
32
|
+
* FeatureConstructor.DEFAULT | `DEFAULT`} is the empty feature, indicating that no elementary
|
|
33
|
+
* feature is available at all; {@link FeatureConstructor.AUTO | `AUTO`} is the union of all
|
|
34
|
+
* elementary features available in the current environment.
|
|
35
35
|
*
|
|
36
36
|
* Not all features can be available at the same time: some features are necessarily incompatible,
|
|
37
37
|
* meaning that they mutually exclude each other, and thus their union cannot be constructed.
|
|
@@ -119,12 +119,13 @@ export interface FeatureConstructor extends FeatureAll
|
|
|
119
119
|
* The constructor can be used with or without the `new` operator, e.g.
|
|
120
120
|
* `new JScrewIt.Feature(feature1, feature2)` or `JScrewIt.Feature(feature1, feature2)`.
|
|
121
121
|
* If no arguments are specified, the new feature object will be equivalent to
|
|
122
|
-
*
|
|
122
|
+
* {@link FeatureConstructor.DEFAULT | `DEFAULT`}.
|
|
123
123
|
*
|
|
124
124
|
* @example
|
|
125
125
|
*
|
|
126
126
|
* The following statements are equivalent, and will all construct a new feature object
|
|
127
|
-
* including both
|
|
127
|
+
* including both {@link FeatureConstructor.ANY_DOCUMENT | `ANY_DOCUMENT`} and {@link
|
|
128
|
+
* FeatureConstructor.ANY_WINDOW | `ANY_WINDOW`}.
|
|
128
129
|
*
|
|
129
130
|
* ```js
|
|
130
131
|
* new JScrewIt.Feature("ANY_DOCUMENT", "ANY_WINDOW");
|
|
@@ -172,12 +173,13 @@ export interface FeatureConstructor extends FeatureAll
|
|
|
172
173
|
* The constructor can be used with or without the `new` operator, e.g.
|
|
173
174
|
* `new JScrewIt.Feature(feature1, feature2)` or `JScrewIt.Feature(feature1, feature2)`.
|
|
174
175
|
* If no arguments are specified, the new feature object will be equivalent to
|
|
175
|
-
*
|
|
176
|
+
* {@link FeatureConstructor.DEFAULT | `DEFAULT`}.
|
|
176
177
|
*
|
|
177
178
|
* @example
|
|
178
179
|
*
|
|
179
180
|
* The following statements are equivalent, and will all construct a new feature object
|
|
180
|
-
* including both
|
|
181
|
+
* including both {@link FeatureConstructor.ANY_DOCUMENT | `ANY_DOCUMENT`} and {@link
|
|
182
|
+
* FeatureConstructor.ANY_WINDOW | `ANY_WINDOW`}.
|
|
181
183
|
*
|
|
182
184
|
* ```js
|
|
183
185
|
* JScrewIt.Feature("ANY_DOCUMENT", "ANY_WINDOW");
|
|
@@ -253,15 +255,17 @@ export interface FeatureConstructor extends FeatureAll
|
|
|
253
255
|
*
|
|
254
256
|
* @example
|
|
255
257
|
*
|
|
256
|
-
* This will create a new feature object equivalent to
|
|
258
|
+
* This will create a new feature object equivalent to {@link FeatureConstructor.NAME | `NAME`}.
|
|
257
259
|
*
|
|
258
260
|
* ```js
|
|
259
261
|
* const newFeature = JScrewIt.Feature.commonOf(["ATOB", "NAME"], ["NAME", "SELF"]);
|
|
260
262
|
* ```
|
|
261
263
|
*
|
|
262
|
-
* This will create a new feature object equivalent to
|
|
263
|
-
*
|
|
264
|
-
*
|
|
264
|
+
* This will create a new feature object equivalent to {@link FeatureConstructor.ANY_DOCUMENT |
|
|
265
|
+
* `ANY_DOCUMENT`}.
|
|
266
|
+
* This is because both {@link FeatureConstructor.HTMLDOCUMENT | `HTMLDOCUMENT`} and {@link
|
|
267
|
+
* FeatureConstructor.DOCUMENT | `DOCUMENT`} imply {@link FeatureConstructor.ANY_DOCUMENT |
|
|
268
|
+
* `ANY_DOCUMENT`}.
|
|
265
269
|
*
|
|
266
270
|
* ```js
|
|
267
271
|
* const newFeature = JScrewIt.Feature.commonOf("HTMLDOCUMENT", "DOCUMENT");
|
package/lib/jscrewit.d.ts
CHANGED