@atscript/typescript 0.1.110 → 0.2.1

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/index.cjs CHANGED
@@ -1,9 +1,11 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_plugin = require('./plugin-mzTvme4k.cjs');
3
- const require_json_schema = require('./json-schema-B3iAqkGQ.cjs');
2
+ const require_plugin = require('./plugin-oUSsb3Ri.cjs');
3
+ const require_unique_name = require('./unique-name-xWd9uO-k.cjs');
4
4
 
5
5
  exports.JS_COMPILED_FORMAT = require_plugin.JS_COMPILED_FORMAT;
6
6
  exports.JS_INTERPRETED_FORMAT = require_plugin.JS_INTERPRETED_FORMAT;
7
7
  exports.default = require_plugin.tsPlugin;
8
- exports.invalidateCompiledValidators = require_json_schema.invalidateCompiledValidators;
9
- exports.tsPlugin = require_plugin.tsPlugin;
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
  /**
@@ -33,7 +33,7 @@ interface TTsPluginOptions {
33
33
  * `validate()` then runs the type's compiled check instead of the interpreted pre-check
34
34
  * (results and errors are identical; only speed differs). The check binds to the live
35
35
  * type on first use and re-binds after mutations made through `annotate()`, the
36
- * metadata / props `Map` methods, the `defineAnnotatedType()` handle and `cloneRefProp()`.
36
+ * metadata / props `Map` methods and the `defineAnnotatedType()` handle.
37
37
  * Raw writes need `invalidateCompiledValidators()`: property writes (`node.optional = …`,
38
38
  * `type.items.push(…)`, …) and in-place edits of annotation values (mutating a constraint
39
39
  * object, pushing onto an `@expect.pattern` array directly) — the check keeps the values
@@ -44,36 +44,42 @@ interface TTsPluginOptions {
44
44
  * before.
45
45
  *
46
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.
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}).
49
52
  * *(default: `false`)*
50
53
  */
51
54
  compileValidators?: boolean;
52
55
  }
53
56
  /**
54
57
  * Render formats of the JS output that override {@link TTsPluginOptions.compileValidators}
55
- * (used by `unplugin-atscript`'s `compileValidators` option).
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).
56
61
  */
57
62
  declare const JS_COMPILED_FORMAT = "js:compiled";
58
63
  declare const JS_INTERPRETED_FORMAT = "js:interpreted";
59
64
  declare const tsPlugin: (opts?: TTsPluginOptions) => TAtscriptPlugin;
60
65
 
61
66
  /**
62
- * Makes every compiled validator check re-verify the type tree it was compiled for before
63
- * its next use.
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.
64
69
  *
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:
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:
69
74
  * - a raw property write: `node.optional = …`, `node.type = …`, `node.metadata = …`,
70
75
  * `type.items.push(…)`, `type.of = …`, `type.propsPatterns.push(…)`;
71
76
  * - an in-place edit of an annotation value: mutating a constraint object
72
77
  * (`metadata.get('expect.min').minValue = 5`), editing or pushing onto an
73
78
  * `@expect.pattern` array directly (use `annotate(metadata, key, value, true)` instead).
74
79
  *
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.
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.
77
83
  *
78
84
  * Any mutation of a type a compiled check has bound to (tracked or invalidated) makes every
79
85
  * compiled check re-bind once on its next use: cheap during startup / configuration, but
@@ -81,5 +87,19 @@ declare const tsPlugin: (opts?: TTsPluginOptions) => TAtscriptPlugin;
81
87
  */
82
88
  declare function invalidateCompiledValidators(): void;
83
89
 
84
- export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, invalidateCompiledValidators, tsPlugin };
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 };
85
105
  export type { TTsPluginOptions };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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";
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 { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, invalidateCompiledValidators };
4
+ export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, importCycle, invalidateCompiledValidators, withLoadCheck };