@atscript/typescript 0.1.109 → 0.2.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/dist/cli.cjs +3349 -2548
- package/dist/index.cjs +8 -3
- package/dist/index.d.ts +74 -2
- package/dist/index.mjs +3 -3
- package/dist/plugin-DhesoKce.mjs +3717 -0
- package/dist/plugin-oUSsb3Ri.cjs +3780 -0
- package/dist/realm-runtime.js +6328 -0
- package/dist/test-utils.cjs +79 -5
- package/dist/test-utils.d.ts +366 -1
- package/dist/test-utils.mjs +76 -5
- package/dist/unique-name-hg1CyPIs.mjs +3451 -0
- package/dist/unique-name-xWd9uO-k.cjs +3703 -0
- package/dist/utils.cjs +1303 -250
- package/dist/utils.d.ts +392 -20
- package/dist/utils.mjs +1262 -228
- package/package.json +13 -3
- package/dist/json-schema-9OBvrg9D.cjs +0 -1964
- package/dist/json-schema-CioBVi6F.mjs +0 -1880
- package/dist/plugin-6r27w6rG.cjs +0 -1683
- package/dist/plugin-D3_BnRrI.mjs +0 -1644
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_plugin = require('./plugin-
|
|
3
|
-
require('./
|
|
2
|
+
const require_plugin = require('./plugin-oUSsb3Ri.cjs');
|
|
3
|
+
const require_unique_name = require('./unique-name-xWd9uO-k.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;
|
|
6
|
-
exports.
|
|
8
|
+
exports.importCycle = require_plugin.importCycle;
|
|
9
|
+
exports.invalidateCompiledValidators = require_unique_name.invalidateCompiledValidators;
|
|
10
|
+
exports.tsPlugin = require_plugin.tsPlugin;
|
|
11
|
+
exports.withLoadCheck = require_plugin.withLoadCheck;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TAtscriptPlugin } from '@atscript/core';
|
|
1
|
+
import { TAtscriptPlugin, AtscriptDoc } from '@atscript/core';
|
|
2
2
|
|
|
3
3
|
interface TTsPluginOptions {
|
|
4
4
|
/**
|
|
@@ -27,7 +27,79 @@ 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 and the `defineAnnotatedType()` handle.
|
|
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`).
|
|
48
|
+
*
|
|
49
|
+
* Off (the default), only types annotated with `@emit.compiledValidator` get a compiled
|
|
50
|
+
* check. The `'js:compiled'` render format compiles every type; `'js:interpreted'`
|
|
51
|
+
* compiles none, ignoring `@emit.compiledValidator` (see {@link JS_INTERPRETED_FORMAT}).
|
|
52
|
+
* *(default: `false`)*
|
|
53
|
+
*/
|
|
54
|
+
compileValidators?: boolean;
|
|
30
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Render formats of the JS output that override {@link TTsPluginOptions.compileValidators}
|
|
58
|
+
* (used by `unplugin-atscript`'s `compileValidators` option): `'js:compiled'` compiles
|
|
59
|
+
* every type; `'js:interpreted'` compiles none — `@emit.compiledValidator` included (a
|
|
60
|
+
* forced-interpreted build, e.g. a browser bundle).
|
|
61
|
+
*/
|
|
62
|
+
declare const JS_COMPILED_FORMAT = "js:compiled";
|
|
63
|
+
declare const JS_INTERPRETED_FORMAT = "js:interpreted";
|
|
31
64
|
declare const tsPlugin: (opts?: TTsPluginOptions) => TAtscriptPlugin;
|
|
32
65
|
|
|
33
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Makes every compiled validator check re-verify the type tree it was compiled for, and every
|
|
68
|
+
* node that reads metadata through other nodes re-read them, before its next use.
|
|
69
|
+
*
|
|
70
|
+
* Validators (compiled checks emitted with `tsPlugin({ compileValidators: true })` and the
|
|
71
|
+
* interpreted walk alike) see mutations made through `annotate()`, the metadata / props `Map`
|
|
72
|
+
* methods and the `defineAnnotatedType()` handle methods automatically. Call this after
|
|
73
|
+
* changing a type tree any other way:
|
|
74
|
+
* - a raw property write: `node.optional = …`, `node.type = …`, `node.metadata = …`,
|
|
75
|
+
* `type.items.push(…)`, `type.of = …`, `type.propsPatterns.push(…)`;
|
|
76
|
+
* - an in-place edit of an annotation value: mutating a constraint object
|
|
77
|
+
* (`metadata.get('expect.min').minValue = 5`), editing or pushing onto an
|
|
78
|
+
* `@expect.pattern` array directly (use `annotate(metadata, key, value, true)` instead).
|
|
79
|
+
*
|
|
80
|
+
* Without it a compiled check may keep validating against the old shape or values, and a
|
|
81
|
+
* node that reads metadata through other nodes (a reference, a merged field, a path override)
|
|
82
|
+
* may keep reading the old values: the rule is the same for both engines.
|
|
83
|
+
*
|
|
84
|
+
* Any mutation of a type a compiled check has bound to (tracked or invalidated) makes every
|
|
85
|
+
* compiled check re-bind once on its next use: cheap during startup / configuration, but
|
|
86
|
+
* avoid mutating validated types per request.
|
|
87
|
+
*/
|
|
88
|
+
declare function invalidateCompiledValidators(): void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Runs `fn` — renders of a build (`BuildRepo.generate` / `write`, `AtscriptDoc.render`) — with
|
|
92
|
+
* the build's load check (MODEL CYCLE-GUARD-6, -8): every generated JS module is loaded (each
|
|
93
|
+
* import cycle from each of its modules), and a module that fails to load fails the render. The
|
|
94
|
+
* CLI's build runs in it; a render's own `loadCheck` option wins (the bundler plugin sets it).
|
|
95
|
+
*/
|
|
96
|
+
declare function withLoadCheck<T>(fn: () => T): T;
|
|
97
|
+
/**
|
|
98
|
+
* Whether `doc`'s generated module is on an import cycle of generated modules with mutating
|
|
99
|
+
* annotates (see `findImportCycle`): `unplugin-atscript` keeps such a module's side effects (the
|
|
100
|
+
* cycles of the generated modules' imports, which the structure model's import ranks do not see).
|
|
101
|
+
*/
|
|
102
|
+
declare function importCycle(doc: AtscriptDoc): boolean;
|
|
103
|
+
|
|
104
|
+
export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, importCycle, invalidateCompiledValidators, tsPlugin, withLoadCheck };
|
|
105
|
+
export type { TTsPluginOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
1
|
+
import { a as withLoadCheck, i as importCycle, n as JS_INTERPRETED_FORMAT, r as tsPlugin, t as JS_COMPILED_FORMAT } from "./plugin-DhesoKce.mjs";
|
|
2
|
+
import { I as invalidateCompiledValidators } from "./unique-name-hg1CyPIs.mjs";
|
|
3
3
|
|
|
4
|
-
export { tsPlugin as default, tsPlugin };
|
|
4
|
+
export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, importCycle, invalidateCompiledValidators, withLoadCheck };
|