@observablehq/runtime
Advanced tools
Comparing version 5.7.4 to 5.8.0
{ | ||
"name": "@observablehq/runtime", | ||
"version": "5.7.4", | ||
"version": "5.8.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Observable, Inc.", |
@@ -53,4 +53,4 @@ import {constant} from "./constant.js"; | ||
function module_variable(observer) { | ||
return new Variable(TYPE_NORMAL, this, observer); | ||
function module_variable(observer, options) { | ||
return new Variable(TYPE_NORMAL, this, observer, options); | ||
} | ||
@@ -57,0 +57,0 @@ |
@@ -13,3 +13,3 @@ import {map} from "./array.js"; | ||
export function Variable(type, module, observer) { | ||
export function Variable(type, module, observer, options) { | ||
if (!observer) observer = no_observer; | ||
@@ -30,2 +30,3 @@ Object.defineProperties(this, { | ||
_rejector: {value: variable_rejector(this)}, | ||
_shadow: {value: initShadow(module, options)}, | ||
_type: {value: type}, | ||
@@ -41,2 +42,3 @@ _value: {value: undefined, writable: true}, | ||
_rejected: {value: variable_rejected, writable: true, configurable: true}, | ||
_resolve: {value: variable_resolve, writable: true, configurable: true}, | ||
define: {value: variable_define, writable: true, configurable: true}, | ||
@@ -47,2 +49,10 @@ delete: {value: variable_delete, writable: true, configurable: true}, | ||
function initShadow(module, options) { | ||
if (!options?.shadow) return null; | ||
return new Map( | ||
Object.entries(options.shadow) | ||
.map(([name, definition]) => [name, (new Variable(TYPE_IMPLICIT, module)).define([], definition)]) | ||
); | ||
} | ||
function variable_attach(variable) { | ||
@@ -96,3 +106,3 @@ variable._module._runtime._dirty.add(variable); | ||
name == null ? null : String(name), | ||
inputs == null ? [] : map.call(inputs, this._module._resolve, this._module), | ||
inputs == null ? [] : map.call(inputs, this._resolve, this), | ||
typeof definition === "function" ? definition : constant(definition) | ||
@@ -102,2 +112,6 @@ ); | ||
function variable_resolve(name) { | ||
return this._shadow?.get(name) ?? this._module._resolve(name); | ||
} | ||
function variable_defineImpl(name, inputs, definition) { | ||
@@ -104,0 +118,0 @@ const scope = this._module._scope, runtime = this._module._runtime; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
184909
1226