@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/test-utils.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, 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
|
let path = require("path");
|
|
5
5
|
path = require_plugin.__toESM(path);
|
|
6
6
|
let _atscript_core = require("@atscript/core");
|
package/dist/test-utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as tsPlugin } from "./plugin-
|
|
2
|
-
import { j as Validator } from "./user-text-
|
|
1
|
+
import { r as tsPlugin } from "./plugin-DUInOy5v.mjs";
|
|
2
|
+
import { j as Validator } from "./user-text-DZR5hfLa.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { build } from "@atscript/core";
|
|
5
5
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -73,10 +73,11 @@
|
|
|
73
73
|
const mapSet = Map.prototype.set;
|
|
74
74
|
/** Global mutation epoch: compiled checks bound in an older epoch re-bind before use. */ let epoch = 0;
|
|
75
75
|
/**
|
|
76
|
-
* Writes of
|
|
77
|
-
* replaced, a layer flag or intrinsic mark registered)
|
|
78
|
-
*
|
|
79
|
-
|
|
76
|
+
* Writes of type trees so far, watched or not: of metadata (any map, any key: `annotate()`, the
|
|
77
|
+
* `Map` methods, a node's map replaced, a layer flag or intrinsic mark registered) and of shape
|
|
78
|
+
* (every {@link touched} mutation, `invalidateCompiledValidators()`). What is derived from a type
|
|
79
|
+
* tree before the last write is derived again (`lazyJsonSchema`, `LayerMap`, `normalizeForType`).
|
|
80
|
+
*/ let typeWrites = 0;
|
|
80
81
|
/** Some bind has watched an object (until then no mutation can affect a compiled check). */ let tracking = false;
|
|
81
82
|
/** Objects (nodes, type defs, metadata / props maps) read by some compiled-check bind. */ const watched = /* @__PURE__ */ new WeakSet();
|
|
82
83
|
/** The current mutation epoch. */ function currentEpoch() {
|
|
@@ -86,7 +87,11 @@ const mapSet = Map.prototype.set;
|
|
|
86
87
|
tracking = true;
|
|
87
88
|
watched.add(obj);
|
|
88
89
|
}
|
|
89
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Records a tracked mutation of `obj`: a type tree write (see `typeWrites`); compiled checks
|
|
92
|
+
* re-bind when some bind has read it.
|
|
93
|
+
*/ function touched(obj) {
|
|
94
|
+
typeWrites++;
|
|
90
95
|
if (tracking && watched.has(obj)) epoch++;
|
|
91
96
|
}
|
|
92
97
|
/**
|
|
@@ -112,13 +117,13 @@ const mapSet = Map.prototype.set;
|
|
|
112
117
|
* avoid mutating validated types per request.
|
|
113
118
|
*/ function invalidateCompiledValidators() {
|
|
114
119
|
epoch++;
|
|
115
|
-
|
|
120
|
+
typeWrites++;
|
|
116
121
|
}
|
|
117
|
-
/** The number of
|
|
118
|
-
return
|
|
122
|
+
/** The number of type tree writes so far (see `typeWrites`). */ function typeWriteCount() {
|
|
123
|
+
return typeWrites;
|
|
119
124
|
}
|
|
120
125
|
/** Records a write of a node's metadata the maps do not see: the node's map replaced. */ function metadataReplaced() {
|
|
121
|
-
|
|
126
|
+
typeWrites++;
|
|
122
127
|
}
|
|
123
128
|
/**
|
|
124
129
|
* `annotate(m, key, value, true)` where map `m` holds `own` as its own value of `key`: appended in
|
|
@@ -127,7 +132,7 @@ const mapSet = Map.prototype.set;
|
|
|
127
132
|
if (Array.isArray(own)) {
|
|
128
133
|
own.push(value);
|
|
129
134
|
if (VALIDATOR_KEY_SET.has(key)) touched(m);
|
|
130
|
-
|
|
135
|
+
else typeWrites++;
|
|
131
136
|
} else m.set(key, [own, value]);
|
|
132
137
|
}
|
|
133
138
|
/**
|
|
@@ -137,21 +142,18 @@ const mapSet = Map.prototype.set;
|
|
|
137
142
|
set(key, value) {
|
|
138
143
|
super.set(key, value);
|
|
139
144
|
if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
140
|
-
|
|
145
|
+
else typeWrites++;
|
|
141
146
|
return this;
|
|
142
147
|
}
|
|
143
148
|
delete(key) {
|
|
144
149
|
const deleted = super.delete(key);
|
|
145
|
-
if (deleted)
|
|
146
|
-
|
|
147
|
-
metadataWrites++;
|
|
148
|
-
}
|
|
150
|
+
if (deleted) if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
151
|
+
else typeWrites++;
|
|
149
152
|
return deleted;
|
|
150
153
|
}
|
|
151
154
|
clear() {
|
|
152
155
|
super.clear();
|
|
153
156
|
touched(this);
|
|
154
|
-
metadataWrites++;
|
|
155
157
|
}
|
|
156
158
|
/** A new map holding `entries`: no write (a new map is in no compiled check nor schema). */ constructor(entries) {
|
|
157
159
|
super();
|
|
@@ -191,7 +193,7 @@ const mapSet = Map.prototype.set;
|
|
|
191
193
|
* a base shows through every layer over it.
|
|
192
194
|
*
|
|
193
195
|
* Reads go through a flattened view of the effective entries, rebuilt on the first read after any
|
|
194
|
-
*
|
|
196
|
+
* type tree write (one global write counter: `typeWriteCount`). The view is used only while
|
|
195
197
|
* every map below is tracked (an `AnnotationMap` or a `LayerMap`, whose writes the counter
|
|
196
198
|
* sees); otherwise the reads are live. A raw write the counter does not see (a node's map swapped,
|
|
197
199
|
* `node.metadata = X`, or edited in place) must be followed by `invalidateCompiledValidators()`,
|
|
@@ -261,7 +263,6 @@ let hiding = false;
|
|
|
261
263
|
s.add(key);
|
|
262
264
|
hiding = true;
|
|
263
265
|
touched(m);
|
|
264
|
-
metadataReplaced();
|
|
265
266
|
}
|
|
266
267
|
/** The keys map `m` hides from its bases (see {@link hideKey}), for a map replacing it. */ function moveHidden(from, to) {
|
|
267
268
|
const s = HIDDEN.get(from);
|
|
@@ -282,7 +283,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
282
283
|
* The flattened view (built again after a metadata write), `undefined`: read live. Internal:
|
|
283
284
|
* this module's readers and the validators read it (`readable`, `filledMeta`), never write.
|
|
284
285
|
*/ view() {
|
|
285
|
-
return this.w ===
|
|
286
|
+
return this.w === typeWriteCount() ? this.f : this.flatten();
|
|
286
287
|
}
|
|
287
288
|
flatten() {
|
|
288
289
|
this.w = -1;
|
|
@@ -292,7 +293,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
292
293
|
f = keys.length === 0 ? NO_ENTRIES : new AnnotationMap(keys.map((k) => [k, this.liveGet(k)]));
|
|
293
294
|
}
|
|
294
295
|
this.f = f;
|
|
295
|
-
this.w =
|
|
296
|
+
this.w = typeWriteCount();
|
|
296
297
|
return f;
|
|
297
298
|
}
|
|
298
299
|
/** The value of `key` (not concatenated), or `MISS`; `nr`: a `passedWhenReferred:false` key. */ lookup(key, nr) {
|
|
@@ -320,7 +321,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
320
321
|
return MISS;
|
|
321
322
|
}
|
|
322
323
|
get(key) {
|
|
323
|
-
const view = this.w ===
|
|
324
|
+
const view = this.w === typeWriteCount() ? this.f : this.flatten();
|
|
324
325
|
return view === void 0 ? this.liveGet(key) : mapGet.call(view, key);
|
|
325
326
|
}
|
|
326
327
|
/** `get` read through the layers (see the file comment). */ liveGet(key) {
|
|
@@ -381,7 +382,6 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
381
382
|
const deleted = super.delete(key);
|
|
382
383
|
if ((hiding ? HIDDEN.get(this) : void 0)?.delete(key)) {
|
|
383
384
|
touched(this);
|
|
384
|
-
metadataReplaced();
|
|
385
385
|
return true;
|
|
386
386
|
}
|
|
387
387
|
return deleted;
|
|
@@ -423,7 +423,7 @@ Object.defineProperty(LayerMap.prototype, "size", {
|
|
|
423
423
|
});
|
|
424
424
|
/**
|
|
425
425
|
* Every map of `m`'s layers is tracked (an `AnnotationMap` or a `LayerMap`, whose writes count in
|
|
426
|
-
* `
|
|
426
|
+
* `typeWrites`), so a flattened view of `m` stays right until the next write.
|
|
427
427
|
*/ function tracked(m, seen) {
|
|
428
428
|
const p = Object.getPrototypeOf(m);
|
|
429
429
|
if (p !== AnnotationMap.prototype && p !== LayerMap.prototype) return false;
|
|
@@ -4184,12 +4184,6 @@ Object.defineProperty(exports, 'createObjectTypeDef', {
|
|
|
4184
4184
|
return createObjectTypeDef;
|
|
4185
4185
|
}
|
|
4186
4186
|
});
|
|
4187
|
-
Object.defineProperty(exports, 'currentEpoch', {
|
|
4188
|
-
enumerable: true,
|
|
4189
|
-
get: function () {
|
|
4190
|
-
return currentEpoch;
|
|
4191
|
-
}
|
|
4192
|
-
});
|
|
4193
4187
|
Object.defineProperty(exports, 'cutAs', {
|
|
4194
4188
|
enumerable: true,
|
|
4195
4189
|
get: function () {
|
|
@@ -4280,12 +4274,6 @@ Object.defineProperty(exports, 'metaEmpty', {
|
|
|
4280
4274
|
return metaEmpty;
|
|
4281
4275
|
}
|
|
4282
4276
|
});
|
|
4283
|
-
Object.defineProperty(exports, 'metadataWriteCount', {
|
|
4284
|
-
enumerable: true,
|
|
4285
|
-
get: function () {
|
|
4286
|
-
return metadataWriteCount;
|
|
4287
|
-
}
|
|
4288
|
-
});
|
|
4289
4277
|
Object.defineProperty(exports, 'pendingStatements', {
|
|
4290
4278
|
enumerable: true,
|
|
4291
4279
|
get: function () {
|
|
@@ -4328,6 +4316,12 @@ Object.defineProperty(exports, 'touched', {
|
|
|
4328
4316
|
return touched;
|
|
4329
4317
|
}
|
|
4330
4318
|
});
|
|
4319
|
+
Object.defineProperty(exports, 'typeWriteCount', {
|
|
4320
|
+
enumerable: true,
|
|
4321
|
+
get: function () {
|
|
4322
|
+
return typeWriteCount;
|
|
4323
|
+
}
|
|
4324
|
+
});
|
|
4331
4325
|
Object.defineProperty(exports, 'unionDiscriminator', {
|
|
4332
4326
|
enumerable: true,
|
|
4333
4327
|
get: function () {
|
|
@@ -72,10 +72,11 @@
|
|
|
72
72
|
const mapSet = Map.prototype.set;
|
|
73
73
|
/** Global mutation epoch: compiled checks bound in an older epoch re-bind before use. */ let epoch = 0;
|
|
74
74
|
/**
|
|
75
|
-
* Writes of
|
|
76
|
-
* replaced, a layer flag or intrinsic mark registered)
|
|
77
|
-
*
|
|
78
|
-
|
|
75
|
+
* Writes of type trees so far, watched or not: of metadata (any map, any key: `annotate()`, the
|
|
76
|
+
* `Map` methods, a node's map replaced, a layer flag or intrinsic mark registered) and of shape
|
|
77
|
+
* (every {@link touched} mutation, `invalidateCompiledValidators()`). What is derived from a type
|
|
78
|
+
* tree before the last write is derived again (`lazyJsonSchema`, `LayerMap`, `normalizeForType`).
|
|
79
|
+
*/ let typeWrites = 0;
|
|
79
80
|
/** Some bind has watched an object (until then no mutation can affect a compiled check). */ let tracking = false;
|
|
80
81
|
/** Objects (nodes, type defs, metadata / props maps) read by some compiled-check bind. */ const watched = /* @__PURE__ */ new WeakSet();
|
|
81
82
|
/** The current mutation epoch. */ function currentEpoch() {
|
|
@@ -85,7 +86,11 @@ const mapSet = Map.prototype.set;
|
|
|
85
86
|
tracking = true;
|
|
86
87
|
watched.add(obj);
|
|
87
88
|
}
|
|
88
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Records a tracked mutation of `obj`: a type tree write (see `typeWrites`); compiled checks
|
|
91
|
+
* re-bind when some bind has read it.
|
|
92
|
+
*/ function touched(obj) {
|
|
93
|
+
typeWrites++;
|
|
89
94
|
if (tracking && watched.has(obj)) epoch++;
|
|
90
95
|
}
|
|
91
96
|
/**
|
|
@@ -111,13 +116,13 @@ const mapSet = Map.prototype.set;
|
|
|
111
116
|
* avoid mutating validated types per request.
|
|
112
117
|
*/ function invalidateCompiledValidators() {
|
|
113
118
|
epoch++;
|
|
114
|
-
|
|
119
|
+
typeWrites++;
|
|
115
120
|
}
|
|
116
|
-
/** The number of
|
|
117
|
-
return
|
|
121
|
+
/** The number of type tree writes so far (see `typeWrites`). */ function typeWriteCount() {
|
|
122
|
+
return typeWrites;
|
|
118
123
|
}
|
|
119
124
|
/** Records a write of a node's metadata the maps do not see: the node's map replaced. */ function metadataReplaced() {
|
|
120
|
-
|
|
125
|
+
typeWrites++;
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* `annotate(m, key, value, true)` where map `m` holds `own` as its own value of `key`: appended in
|
|
@@ -126,7 +131,7 @@ const mapSet = Map.prototype.set;
|
|
|
126
131
|
if (Array.isArray(own)) {
|
|
127
132
|
own.push(value);
|
|
128
133
|
if (VALIDATOR_KEY_SET.has(key)) touched(m);
|
|
129
|
-
|
|
134
|
+
else typeWrites++;
|
|
130
135
|
} else m.set(key, [own, value]);
|
|
131
136
|
}
|
|
132
137
|
/**
|
|
@@ -136,21 +141,18 @@ const mapSet = Map.prototype.set;
|
|
|
136
141
|
set(key, value) {
|
|
137
142
|
super.set(key, value);
|
|
138
143
|
if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
139
|
-
|
|
144
|
+
else typeWrites++;
|
|
140
145
|
return this;
|
|
141
146
|
}
|
|
142
147
|
delete(key) {
|
|
143
148
|
const deleted = super.delete(key);
|
|
144
|
-
if (deleted)
|
|
145
|
-
|
|
146
|
-
metadataWrites++;
|
|
147
|
-
}
|
|
149
|
+
if (deleted) if (tracking && VALIDATOR_KEY_SET.has(key)) touched(this);
|
|
150
|
+
else typeWrites++;
|
|
148
151
|
return deleted;
|
|
149
152
|
}
|
|
150
153
|
clear() {
|
|
151
154
|
super.clear();
|
|
152
155
|
touched(this);
|
|
153
|
-
metadataWrites++;
|
|
154
156
|
}
|
|
155
157
|
/** A new map holding `entries`: no write (a new map is in no compiled check nor schema). */ constructor(entries) {
|
|
156
158
|
super();
|
|
@@ -190,7 +192,7 @@ const mapSet = Map.prototype.set;
|
|
|
190
192
|
* a base shows through every layer over it.
|
|
191
193
|
*
|
|
192
194
|
* Reads go through a flattened view of the effective entries, rebuilt on the first read after any
|
|
193
|
-
*
|
|
195
|
+
* type tree write (one global write counter: `typeWriteCount`). The view is used only while
|
|
194
196
|
* every map below is tracked (an `AnnotationMap` or a `LayerMap`, whose writes the counter
|
|
195
197
|
* sees); otherwise the reads are live. A raw write the counter does not see (a node's map swapped,
|
|
196
198
|
* `node.metadata = X`, or edited in place) must be followed by `invalidateCompiledValidators()`,
|
|
@@ -260,7 +262,6 @@ let hiding = false;
|
|
|
260
262
|
s.add(key);
|
|
261
263
|
hiding = true;
|
|
262
264
|
touched(m);
|
|
263
|
-
metadataReplaced();
|
|
264
265
|
}
|
|
265
266
|
/** The keys map `m` hides from its bases (see {@link hideKey}), for a map replacing it. */ function moveHidden(from, to) {
|
|
266
267
|
const s = HIDDEN.get(from);
|
|
@@ -281,7 +282,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
281
282
|
* The flattened view (built again after a metadata write), `undefined`: read live. Internal:
|
|
282
283
|
* this module's readers and the validators read it (`readable`, `filledMeta`), never write.
|
|
283
284
|
*/ view() {
|
|
284
|
-
return this.w ===
|
|
285
|
+
return this.w === typeWriteCount() ? this.f : this.flatten();
|
|
285
286
|
}
|
|
286
287
|
flatten() {
|
|
287
288
|
this.w = -1;
|
|
@@ -291,7 +292,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
291
292
|
f = keys.length === 0 ? NO_ENTRIES : new AnnotationMap(keys.map((k) => [k, this.liveGet(k)]));
|
|
292
293
|
}
|
|
293
294
|
this.f = f;
|
|
294
|
-
this.w =
|
|
295
|
+
this.w = typeWriteCount();
|
|
295
296
|
return f;
|
|
296
297
|
}
|
|
297
298
|
/** The value of `key` (not concatenated), or `MISS`; `nr`: a `passedWhenReferred:false` key. */ lookup(key, nr) {
|
|
@@ -319,7 +320,7 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
319
320
|
return MISS;
|
|
320
321
|
}
|
|
321
322
|
get(key) {
|
|
322
|
-
const view = this.w ===
|
|
323
|
+
const view = this.w === typeWriteCount() ? this.f : this.flatten();
|
|
323
324
|
return view === void 0 ? this.liveGet(key) : mapGet.call(view, key);
|
|
324
325
|
}
|
|
325
326
|
/** `get` read through the layers (see the file comment). */ liveGet(key) {
|
|
@@ -380,7 +381,6 @@ let _Symbol_iterator = Symbol.iterator;
|
|
|
380
381
|
const deleted = super.delete(key);
|
|
381
382
|
if ((hiding ? HIDDEN.get(this) : void 0)?.delete(key)) {
|
|
382
383
|
touched(this);
|
|
383
|
-
metadataReplaced();
|
|
384
384
|
return true;
|
|
385
385
|
}
|
|
386
386
|
return deleted;
|
|
@@ -422,7 +422,7 @@ Object.defineProperty(LayerMap.prototype, "size", {
|
|
|
422
422
|
});
|
|
423
423
|
/**
|
|
424
424
|
* Every map of `m`'s layers is tracked (an `AnnotationMap` or a `LayerMap`, whose writes count in
|
|
425
|
-
* `
|
|
425
|
+
* `typeWrites`), so a flattened view of `m` stays right until the next write.
|
|
426
426
|
*/ function tracked(m, seen) {
|
|
427
427
|
const p = Object.getPrototypeOf(m);
|
|
428
428
|
if (p !== AnnotationMap.prototype && p !== LayerMap.prototype) return false;
|
|
@@ -4021,4 +4021,4 @@ const USER_TEXT = new Map(CORE_USER_TEXT);
|
|
|
4021
4021
|
}
|
|
4022
4022
|
|
|
4023
4023
|
//#endregion
|
|
4024
|
-
export {
|
|
4024
|
+
export { VALIDATOR_KEYS as $, propAtChain as A, registerCompiledCheck as B, createAnnotatedTypeNode as C, isAnnotatedType as D, defineAnnotatedType as E, VALIDATOR_MESSAGES as F, $nr as G, jsonSchemaPattern as H, formatCodeOf as I, watchLayer as J, LayerMap as K, formatValidatorMessage as L, ValidatorError as M, unionDiscriminator as N, isAnnotatedTypeOfPrimitive as O, VALIDATOR_ERROR_CODES as P, DECIMAL_RE as Q, localizeErrors as R, annotate as S, createObjectTypeDef as T, statelessRegExp as U, detectDiscriminator as V, $ak as W, touched as X, invalidateCompiledValidators as Y, typeWriteCount as Z, pendingStatements as _, userTextOf as a, cutKey as b, $blk as c, $fc as d, arrayKeyProps as et, $ft as f, appliedBlockModules as g, $sh as h, userTextKeys as i, Validator as j, isPhantomType as k, $end as l, $q as m, CORE_USER_TEXT as n, uniqueName as o, $ps as p, metaEmpty as q, registerUserText as r, $alias as s, $ut as t, boundOf as tt, $f as u, stageEnds as v, createMetadataMap as w, enterCut as x, cutAs as y, messagesTranslator as z };
|