@atscript/typescript 0.1.109 → 0.1.110
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/dist/cli.cjs +1587 -189
- package/dist/index.cjs +5 -2
- package/dist/index.d.ts +53 -1
- package/dist/index.mjs +3 -3
- package/dist/{json-schema-CioBVi6F.mjs → json-schema-B3iAqkGQ.cjs} +919 -37
- package/dist/{json-schema-9OBvrg9D.cjs → json-schema-BG1SEcjI.mjs} +618 -120
- package/dist/{plugin-D3_BnRrI.mjs → plugin-DpzE8aJr.mjs} +955 -116
- package/dist/{plugin-6r27w6rG.cjs → plugin-mzTvme4k.cjs} +966 -115
- package/dist/test-utils.cjs +4 -4
- package/dist/test-utils.d.ts +53 -0
- package/dist/test-utils.mjs +4 -4
- package/dist/utils.cjs +14 -26
- package/dist/utils.d.ts +81 -2
- package/dist/utils.mjs +13 -27
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_plugin = require('./plugin-
|
|
3
|
-
require('./json-schema-
|
|
2
|
+
const require_plugin = require('./plugin-mzTvme4k.cjs');
|
|
3
|
+
const require_json_schema = require('./json-schema-B3iAqkGQ.cjs');
|
|
4
4
|
|
|
5
|
+
exports.JS_COMPILED_FORMAT = require_plugin.JS_COMPILED_FORMAT;
|
|
6
|
+
exports.JS_INTERPRETED_FORMAT = require_plugin.JS_INTERPRETED_FORMAT;
|
|
5
7
|
exports.default = require_plugin.tsPlugin;
|
|
8
|
+
exports.invalidateCompiledValidators = require_json_schema.invalidateCompiledValidators;
|
|
6
9
|
exports.tsPlugin = require_plugin.tsPlugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,59 @@ interface TTsPluginOptions {
|
|
|
27
27
|
* from Node. *(default: `'.as'`)*
|
|
28
28
|
*/
|
|
29
29
|
moduleExtension?: '.as' | '.as.js' | '.as.mjs';
|
|
30
|
+
/**
|
|
31
|
+
* Emit a build-time compiled validator check per type into the `.as.js` output.
|
|
32
|
+
*
|
|
33
|
+
* `validate()` then runs the type's compiled check instead of the interpreted pre-check
|
|
34
|
+
* (results and errors are identical; only speed differs). The check binds to the live
|
|
35
|
+
* type on first use and re-binds after mutations made through `annotate()`, the
|
|
36
|
+
* metadata / props `Map` methods, the `defineAnnotatedType()` handle and `cloneRefProp()`.
|
|
37
|
+
* Raw writes need `invalidateCompiledValidators()`: property writes (`node.optional = …`,
|
|
38
|
+
* `type.items.push(…)`, …) and in-place edits of annotation values (mutating a constraint
|
|
39
|
+
* object, pushing onto an `@expect.pattern` array directly) — the check keeps the values
|
|
40
|
+
* it bound until then. Any runtime mutation of a type a check has bound to makes the
|
|
41
|
+
* checks re-bind once on next use: cheap at startup, but avoid it per request. Types it
|
|
42
|
+
* cannot bind to, and types not built from generated modules (deserialised,
|
|
43
|
+
* JSON-schema-built, flattened, hand-built), are validated by the interpreted path as
|
|
44
|
+
* before.
|
|
45
|
+
*
|
|
46
|
+
* Adds code to every `.as.js`: meant for backend builds — leave it off for bundles
|
|
47
|
+
* shipped to browsers (the code is CSP-safe: no `eval` / `new Function`). The
|
|
48
|
+
* `'js:compiled'` / `'js:interpreted'` render formats force it on / off per render.
|
|
49
|
+
* *(default: `false`)*
|
|
50
|
+
*/
|
|
51
|
+
compileValidators?: boolean;
|
|
30
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Render formats of the JS output that override {@link TTsPluginOptions.compileValidators}
|
|
55
|
+
* (used by `unplugin-atscript`'s `compileValidators` option).
|
|
56
|
+
*/
|
|
57
|
+
declare const JS_COMPILED_FORMAT = "js:compiled";
|
|
58
|
+
declare const JS_INTERPRETED_FORMAT = "js:interpreted";
|
|
31
59
|
declare const tsPlugin: (opts?: TTsPluginOptions) => TAtscriptPlugin;
|
|
32
60
|
|
|
33
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Makes every compiled validator check re-verify the type tree it was compiled for before
|
|
63
|
+
* its next use.
|
|
64
|
+
*
|
|
65
|
+
* Compiled checks (emitted with `tsPlugin({ compileValidators: true })`) see mutations made
|
|
66
|
+
* through `annotate()`, the metadata / props `Map` methods, the `defineAnnotatedType()`
|
|
67
|
+
* handle methods and `cloneRefProp()` automatically. Call this after changing a type tree
|
|
68
|
+
* any other way:
|
|
69
|
+
* - a raw property write: `node.optional = …`, `node.type = …`, `node.metadata = …`,
|
|
70
|
+
* `type.items.push(…)`, `type.of = …`, `type.propsPatterns.push(…)`;
|
|
71
|
+
* - an in-place edit of an annotation value: mutating a constraint object
|
|
72
|
+
* (`metadata.get('expect.min').minValue = 5`), editing or pushing onto an
|
|
73
|
+
* `@expect.pattern` array directly (use `annotate(metadata, key, value, true)` instead).
|
|
74
|
+
*
|
|
75
|
+
* Without it the compiled check may keep validating against the old shape or values.
|
|
76
|
+
* Types without compiled checks are always read live and never need it.
|
|
77
|
+
*
|
|
78
|
+
* Any mutation of a type a compiled check has bound to (tracked or invalidated) makes every
|
|
79
|
+
* compiled check re-bind once on its next use: cheap during startup / configuration, but
|
|
80
|
+
* avoid mutating validated types per request.
|
|
81
|
+
*/
|
|
82
|
+
declare function invalidateCompiledValidators(): void;
|
|
83
|
+
|
|
84
|
+
export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, invalidateCompiledValidators, tsPlugin };
|
|
85
|
+
export type { TTsPluginOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./json-schema-
|
|
1
|
+
import { n as JS_INTERPRETED_FORMAT, r as tsPlugin, t as JS_COMPILED_FORMAT } from "./plugin-DpzE8aJr.mjs";
|
|
2
|
+
import { Y as invalidateCompiledValidators } from "./json-schema-BG1SEcjI.mjs";
|
|
3
3
|
|
|
4
|
-
export { tsPlugin as default, tsPlugin };
|
|
4
|
+
export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, invalidateCompiledValidators };
|