@atscript/typescript 0.2.5 → 0.2.6
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 +20 -22
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{plugin-Bx7j-vWf.mjs → plugin-DUInOy5v.mjs} +1 -1
- package/dist/{plugin-JJ9MJ6AF.cjs → plugin-lDfE9qm8.cjs} +1 -1
- package/dist/realm-runtime.js +339 -177
- package/dist/test-utils.cjs +2 -2
- package/dist/test-utils.mjs +2 -2
- package/dist/{user-text-Dl8FNKLL.cjs → user-text-BvyErcKK.cjs} +29 -35
- package/dist/{user-text-BOf56N4d.mjs → user-text-DZR5hfLa.mjs} +24 -24
- package/dist/utils.cjs +317 -155
- package/dist/utils.d.ts +26 -12
- package/dist/utils.mjs +317 -155
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1594,20 +1594,22 @@ const tsPlugin = (opts) => {
|
|
|
1594
1594
|
const mapSet = Map.prototype.set;
|
|
1595
1595
|
/** Global mutation epoch: compiled checks bound in an older epoch re-bind before use. */ let epoch = 0;
|
|
1596
1596
|
/**
|
|
1597
|
-
* Writes of
|
|
1598
|
-
* replaced, a layer flag or intrinsic mark registered)
|
|
1599
|
-
*
|
|
1600
|
-
|
|
1597
|
+
* Writes of type trees so far, watched or not: of metadata (any map, any key: `annotate()`, the
|
|
1598
|
+
* `Map` methods, a node's map replaced, a layer flag or intrinsic mark registered) and of shape
|
|
1599
|
+
* (every {@link touched} mutation, `invalidateCompiledValidators()`). What is derived from a type
|
|
1600
|
+
* tree before the last write is derived again (`lazyJsonSchema`, `LayerMap`, `normalizeForType`).
|
|
1601
|
+
*/ let typeWrites = 0;
|
|
1601
1602
|
/** Some bind has watched an object (until then no mutation can affect a compiled check). */ let tracking = false;
|
|
1602
1603
|
/** Objects (nodes, type defs, metadata / props maps) read by some compiled-check bind. */ const watched = /* @__PURE__ */ new WeakSet();
|
|
1603
|
-
/**
|
|
1604
|
+
/**
|
|
1605
|
+
* Records a tracked mutation of `obj`: a type tree write (see `typeWrites`); compiled checks
|
|
1606
|
+
* re-bind when some bind has read it.
|
|
1607
|
+
*/ function touched(obj) {
|
|
1608
|
+
typeWrites++;
|
|
1604
1609
|
if (tracking && watched.has(obj)) epoch++;
|
|
1605
1610
|
}
|
|
1606
|
-
/** The number of
|
|
1607
|
-
return
|
|
1608
|
-
}
|
|
1609
|
-
/** Records a write of a node's metadata the maps do not see: the node's map replaced. */ function metadataReplaced() {
|
|
1610
|
-
metadataWrites++;
|
|
1611
|
+
/** The number of type tree writes so far (see `typeWrites`). */ function typeWriteCount() {
|
|
1612
|
+
return typeWrites;
|
|
1611
1613
|
}
|
|
1612
1614
|
/**
|
|
1613
1615
|
* Metadata map of runtime type nodes: a `Map` whose writes to validator annotation keys
|
|
@@ -1616,21 +1618,18 @@ const mapSet = Map.prototype.set;
|
|
|
1616
1618
|
set(key, value) {
|
|
1617
1619
|
super.set(key, value);
|
|
1618
1620
|
if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
1619
|
-
|
|
1621
|
+
else typeWrites++;
|
|
1620
1622
|
return this;
|
|
1621
1623
|
}
|
|
1622
1624
|
delete(key) {
|
|
1623
1625
|
const deleted = super.delete(key);
|
|
1624
|
-
if (deleted)
|
|
1625
|
-
|
|
1626
|
-
metadataWrites++;
|
|
1627
|
-
}
|
|
1626
|
+
if (deleted) if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
1627
|
+
else typeWrites++;
|
|
1628
1628
|
return deleted;
|
|
1629
1629
|
}
|
|
1630
1630
|
clear() {
|
|
1631
1631
|
super.clear();
|
|
1632
1632
|
touched(this);
|
|
1633
|
-
metadataWrites++;
|
|
1634
1633
|
}
|
|
1635
1634
|
/** A new map holding `entries`: no write (a new map is in no compiled check nor schema). */ constructor(entries) {
|
|
1636
1635
|
super();
|
|
@@ -1650,7 +1649,7 @@ const mapSet = Map.prototype.set;
|
|
|
1650
1649
|
* a base shows through every layer over it.
|
|
1651
1650
|
*
|
|
1652
1651
|
* Reads go through a flattened view of the effective entries, rebuilt on the first read after any
|
|
1653
|
-
*
|
|
1652
|
+
* type tree write (one global write counter: `typeWriteCount`). The view is used only while
|
|
1654
1653
|
* every map below is tracked (an `AnnotationMap` or a `LayerMap`, whose writes the counter
|
|
1655
1654
|
* sees); otherwise the reads are live. A raw write the counter does not see (a node's map swapped,
|
|
1656
1655
|
* `node.metadata = X`, or edited in place) must be followed by `invalidateCompiledValidators()`,
|
|
@@ -1698,7 +1697,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
1698
1697
|
* The flattened view (built again after a metadata write), `undefined`: read live. Internal:
|
|
1699
1698
|
* this module's readers and the validators read it (`readable`, `filledMeta`), never write.
|
|
1700
1699
|
*/ view() {
|
|
1701
|
-
return this.w ===
|
|
1700
|
+
return this.w === typeWriteCount() ? this.f : this.flatten();
|
|
1702
1701
|
}
|
|
1703
1702
|
flatten() {
|
|
1704
1703
|
this.w = -1;
|
|
@@ -1708,7 +1707,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
1708
1707
|
f = keys.length === 0 ? NO_ENTRIES : new AnnotationMap(keys.map((k) => [k, this.liveGet(k)]));
|
|
1709
1708
|
}
|
|
1710
1709
|
this.f = f;
|
|
1711
|
-
this.w =
|
|
1710
|
+
this.w = typeWriteCount();
|
|
1712
1711
|
return f;
|
|
1713
1712
|
}
|
|
1714
1713
|
/** The value of `key` (not concatenated), or `MISS`; `nr`: a `passedWhenReferred:false` key. */ lookup(key, nr) {
|
|
@@ -1736,7 +1735,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
1736
1735
|
return MISS;
|
|
1737
1736
|
}
|
|
1738
1737
|
get(key) {
|
|
1739
|
-
const view = this.w ===
|
|
1738
|
+
const view = this.w === typeWriteCount() ? this.f : this.flatten();
|
|
1740
1739
|
return view === void 0 ? this.liveGet(key) : mapGet.call(view, key);
|
|
1741
1740
|
}
|
|
1742
1741
|
/** `get` read through the layers (see the file comment). */ liveGet(key) {
|
|
@@ -1797,7 +1796,6 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
1797
1796
|
const deleted = super.delete(key);
|
|
1798
1797
|
if ((hiding ? HIDDEN.get(this) : void 0)?.delete(key)) {
|
|
1799
1798
|
touched(this);
|
|
1800
|
-
metadataReplaced();
|
|
1801
1799
|
return true;
|
|
1802
1800
|
}
|
|
1803
1801
|
return deleted;
|
|
@@ -1839,7 +1837,7 @@ Object.defineProperty(LayerMap.prototype, "size", {
|
|
|
1839
1837
|
});
|
|
1840
1838
|
/**
|
|
1841
1839
|
* Every map of `m`'s layers is tracked (an `AnnotationMap` or a `LayerMap`, whose writes count in
|
|
1842
|
-
* `
|
|
1840
|
+
* `typeWrites`), so a flattened view of `m` stays right until the next write.
|
|
1843
1841
|
*/ function tracked(m, seen) {
|
|
1844
1842
|
const p = Object.getPrototypeOf(m);
|
|
1845
1843
|
if (p !== AnnotationMap.prototype && p !== LayerMap.prototype) return false;
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_plugin = require('./plugin-
|
|
3
|
-
const require_user_text = require('./user-text-
|
|
2
|
+
const require_plugin = require('./plugin-lDfE9qm8.cjs');
|
|
3
|
+
const require_user_text = require('./user-text-BvyErcKK.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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as withLoadCheck, i as importCycle, n as JS_INTERPRETED_FORMAT, r as tsPlugin, t as JS_COMPILED_FORMAT } from "./plugin-
|
|
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-DUInOy5v.mjs";
|
|
2
|
+
import { Y as invalidateCompiledValidators } from "./user-text-DZR5hfLa.mjs";
|
|
3
3
|
|
|
4
4
|
export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, importCycle, invalidateCompiledValidators, withLoadCheck };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CORE_USER_TEXT, o as uniqueName, v as stageEnds } from "./user-text-
|
|
1
|
+
import { n as CORE_USER_TEXT, o as uniqueName, v as stageEnds } from "./user-text-DZR5hfLa.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { ANNOTATE_RESET, DEFAULT_FORMAT, MERGE_TOO_COMPLEX, NAV_PROP_ANNOTATIONS, SemanticGroup, andExprs, annotatedValueKinds, componentOf, components, defPosition, documentsEpoch, entryParts, flatDefinitions, forEachAnnotationSpec, getRelPath, hasMutatingAnnotates, hasNavPropAnnotation, isAnnotate, isArray, isAsView, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isInterface, isNull, isPhantomNode, isPrimitive, isQueryLogical, isRef, isStructure, isTuple, moduleId, pastViews, resolveAtscriptFromPath, unshell, userTextFields, withoutAsExtension } from "@atscript/core";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_user_text = require('./user-text-
|
|
28
|
+
const require_user_text = require('./user-text-BvyErcKK.cjs');
|
|
29
29
|
let path = require("path");
|
|
30
30
|
path = __toESM(path);
|
|
31
31
|
let _atscript_core = require("@atscript/core");
|