( /** The set of names defined at the root-level of the scope mapped to their * corresponding definitions.**/ def: Record<string, unknown>, config?: ArkSchemaScopeConfig, isBuiltin = false )
| 364 | readonly nodesByKey: WeakCache<BaseNode> = new WeakCache() |
| 365 | |
| 366 | constructor( |
| 367 | /** The set of names defined at the root-level of the scope mapped to their |
| 368 | * corresponding definitions.**/ |
| 369 | def: Record<string, unknown>, |
| 370 | config?: ArkSchemaScopeConfig, |
| 371 | isBuiltin = false |
| 372 | ) { |
| 373 | this.name = config?.name ?? `anonymousScope${anonymousScopeCount++}` |
| 374 | this.isBuiltin = isBuiltin |
| 375 | this.scopeConfig = config |
| 376 | // a scope's would be honored for some and silently ignored for others |
| 377 | for (const k of globalOnlyConfigOptionNames) { |
| 378 | if ((config as ArkSchemaConfig | undefined)?.[k] !== undefined) |
| 379 | throwParseError(writeGlobalOnlyConfigMessage(k)) |
| 380 | } |
| 381 | assertNoProblemConfig(config as ArkSchemaConfig | undefined) |
| 382 | if (config && "clone" in config) throwParseError(removedCloneMessage) |
| 383 | if (config?.ambient !== undefined) validateAmbientConfig(config.ambient) |
| 384 | |
| 385 | const aliasEntries = Object.entries(def).map(entry => |
| 386 | this.preparseEntry(...entry) |
| 387 | ) |
| 388 | |
| 389 | for (const [k, v] of aliasEntries) { |
| 390 | if ( |
| 391 | (hasArkKind(v, "module") && !isInstanceOf(v, RootModule)) || |
| 392 | (hasArkKind(v, "generic") && !isInstanceOf(v, GenericRoot)) |
| 393 | ) |
| 394 | throwParseError(writeForeignArkMessage(k)) |
| 395 | let name = k |
| 396 | if (k[0] === "#") { |
| 397 | name = k.slice(1) |
| 398 | if (hasOwn(this.aliases, name)) |
| 399 | throwParseError(writeDuplicateAliasError(name)) |
| 400 | this.aliases[name] = v |
| 401 | } else { |
| 402 | if (hasOwn(this.aliases, name)) |
| 403 | throwParseError(writeDuplicateAliasError(k)) |
| 404 | this.aliases[name] = v |
| 405 | this.exportedNames.push(name) |
| 406 | } |
| 407 | if ( |
| 408 | !hasArkKind(v, "module") && |
| 409 | !hasArkKind(v, "generic") && |
| 410 | !isThunk(v) |
| 411 | ) { |
| 412 | const preparsed = this.preparseOwn(v, { alias: name }) |
| 413 | this.res[name] = |
| 414 | hasArkKind(preparsed, "root") ? |
| 415 | this.bindRef(preparsed) |
| 416 | : this.createParseCtx(preparsed) |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | get config(): ArkSchemaScopeConfig { |
| 422 | return mergeConfigs($ark.config, this.scopeConfig) |
nothing calls this directly
no test coverage detected