Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lwc/wire-service

Package Overview
Dependencies
Maintainers
11
Versions
799
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lwc/wire-service - npm Package Compare versions

Comparing version 0.35.11 to 0.35.12

22

dist/commonjs/es2017/wire.js

@@ -67,3 +67,3 @@ /**

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach((metadata) => {
configListenerMetadatas.forEach(metadata => {
const { listener, statics, reactives } = metadata;

@@ -241,3 +241,3 @@ const reactiveValues = Object.create(null);

reference,
head: reference
head: reference,
};

@@ -249,3 +249,3 @@ }

head: segments.shift(),
tail: segments
tail: segments,
};

@@ -292,3 +292,3 @@ }

statics,
reactives
reactives,
};

@@ -330,3 +330,4 @@ // setup listeners for all reactive parameters

case CONFIG: {
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
const reactives = this._wireDef.params;

@@ -406,3 +407,3 @@ if (reactives) {

wiring: (cmp, data, def, context) => {
const wireContext = context[CONTEXT_ID] = Object.create(null);
const wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];

@@ -435,3 +436,4 @@ wireContext[CONTEXT_DISCONNECTED] = [];

// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
assert.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
}

@@ -446,3 +448,3 @@ });

addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});

@@ -465,3 +467,3 @@ }

invokeListener(listeners);
}
},
};

@@ -488,2 +490,2 @@ /**

exports.ValueChangedEvent = ValueChangedEvent;
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -15,12 +15,12 @@ /**

var assert = {
isTrue: function isTrue(value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
},
isFalse: function isFalse(value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
}
isTrue: function (value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
},
isFalse: function (value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
},
};

@@ -35,38 +35,16 @@

// key in engine service context for wire service context
var CONTEXT_ID = '@wire'; // key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated'; // key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected'; // key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected'; // wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect'; // wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect'; // wire event target life cycle config changed hook event type
var CONTEXT_ID = '@wire';
// key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated';
// key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected';
// key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected';
// wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect';
// wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect';
// wire event target life cycle config changed hook event type
var CONFIG = 'config';
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
/*

@@ -78,3 +56,2 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
/*

@@ -87,3 +64,2 @@ * Detects property changes by installing setter/getter overrides on the component

*/
/**

@@ -95,22 +71,17 @@ * Invokes the provided change listeners with the resolved component properties.

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener,
statics = metadata.statics,
reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
} // TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener, statics = metadata.statics, reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
}
// TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
}

@@ -123,36 +94,29 @@ /**

*/
function updated(cmp, reactiveParameter, configContext) {
if (!configContext.mutated) {
configContext.mutated = new Set(); // collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
if (!configContext.mutated) {
configContext.mutated = new Set();
// collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
}
function updatedFuture(cmp, configContext) {
var uniqueListeners = new Set(); // configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated; // pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
var uniqueListeners = new Set();
// configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated;
// pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
}

@@ -164,24 +128,16 @@ /**

*/
function getReactiveParameterValue(cmp, reactiveParameter) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (typeof value !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (_typeof(value) !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}

@@ -194,7 +150,6 @@ /**

*/
function installTrap(cmp, reactiveParameter, configContext) {
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
}

@@ -207,24 +162,17 @@ /**

*/
function findDescriptor(target, propName, protoSet) {
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
}

@@ -238,241 +186,205 @@ /**

*/
function getOverrideDescriptor(cmp, prop, callback) {
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set; // TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || descriptor.get === undefined && descriptor.set === undefined) {
var value_1 = cmp[prop];
enumerable = true;
get = function get() {
return value_1;
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set;
// TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || (descriptor.get === undefined && descriptor.set === undefined)) {
var value_1 = cmp[prop];
enumerable = true;
get = function () {
return value_1;
};
set = function (newValue) {
value_1 = newValue;
callback();
};
}
else {
var originalSet_1 = descriptor.set, originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function (newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function () {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true,
};
set = function set(newValue) {
value_1 = newValue;
callback();
};
} else {
var originalSet_1 = descriptor.set,
originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function set(newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function get() {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true
};
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function removeListener(listeners, toRemove) {
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
}
function removeConfigListener(configListenerMetadatas, toRemove) {
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
}
}
}
}
function buildReactiveParameter(reference) {
if (!reference.includes('.')) {
if (!reference.includes('.')) {
return {
reference: reference,
head: reference,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: reference
reference: reference,
head: segments.shift(),
tail: segments,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: segments.shift(),
tail: segments
};
}
var WireEventTarget =
/** @class */
function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
if (process.env.NODE_ENV !== 'production') {
assert.isFalse(connectedListeners.includes(listener), 'must not call addEventListener("connect") with the same listener');
}
connectedListeners.push(listener);
break;
var WireEventTarget = /** @class */ (function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
if (process.env.NODE_ENV !== 'production') {
assert.isFalse(connectedListeners.includes(listener), 'must not call addEventListener("connect") with the same listener');
}
connectedListeners.push(listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
if (process.env.NODE_ENV !== 'production') {
assert.isFalse(disconnectedListeners.includes(listener), 'must not call addEventListener("disconnect") with the same listener');
}
disconnectedListeners.push(listener);
break;
}
case CONFIG: {
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0;
// no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1,
};
// setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
}
else {
configListenerMetadatas.push(configListenerMetadata_1);
}
// enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
}
default:
throw new Error("unsupported event type " + type);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
if (process.env.NODE_ENV !== 'production') {
assert.isFalse(disconnectedListeners.includes(listener), 'must not call addEventListener("disconnect") with the same listener');
}
disconnectedListeners.push(listener);
break;
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
}
case CONFIG: {
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
case CONFIG:
{
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0; // no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1
}; // setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
} else {
configListenerMetadatas.push(configListenerMetadata_1);
} // enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (evt instanceof ValueChangedEvent) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
}
else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
else {
throw new Error("Invalid event " + evt + ".");
}
case CONFIG:
{
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (_instanceof(evt, ValueChangedEvent)) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
} else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
} else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
} else {
throw new Error("Invalid event " + evt + ".");
}
};
return WireEventTarget;
}();
};
return WireEventTarget;
}());
/**
* Event fired by wire adapters to emit a new value.
*/
var ValueChangedEvent = /** @class */ (function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}());
var ValueChangedEvent =
/** @class */
function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}();
/*

@@ -484,3 +396,3 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
// wire adapters: wire adapter id => adapter ctor
var adapterFactories = new Map();

@@ -491,7 +403,6 @@ /**

*/
function invokeListener(listeners) {
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
}

@@ -504,77 +415,65 @@ /**

*/
var wireService = {
wiring: function wiring(cmp, data, def, context) {
var wireContext = context[CONTEXT_ID] = Object.create(null);
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = {
listeners: {},
values: {}
}; // engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function _loop_1(i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(wireDef.adapter, "@wire on \"" + wireTarget + "\": adapter id must be truthy");
assert.isTrue(adapterFactory, "@wire on \"" + wireTarget + "\": unknown adapter id: " + String(wireDef.adapter)); // enforce restrictions of reactive parameters
if (wireDef.params) {
Object.keys(wireDef.params).forEach(function (param) {
var prop = wireDef.params[param];
var segments = prop.split('.');
segments.forEach(function (segment) {
assert.isTrue(segment.length > 0, "@wire on \"" + wireTarget + "\": reactive parameters must not be empty");
});
assert.isTrue(segments[0] !== wireTarget, "@wire on \"" + wireTarget + "\": reactive parameter \"" + segments[0] + "\" must not refer to self"); // restriction for dot-notation reactive parameters
if (segments.length > 1) {
// @wire emits a stream of immutable values. an emit sets the target property; it does not mutate a previously emitted value.
// restricting dot-notation reactive parameters to reference other @wire targets makes trapping the 'head' of the parameter
// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, "@wire on \"" + wireTarget + "\": dot-notation reactive parameter \"" + prop + "\" must refer to a @wire property");
wiring: function (cmp, data, def, context) {
var wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = { listeners: {}, values: {} };
// engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function (i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(wireDef.adapter, "@wire on \"" + wireTarget + "\": adapter id must be truthy");
assert.isTrue(adapterFactory, "@wire on \"" + wireTarget + "\": unknown adapter id: " + String(wireDef.adapter));
// enforce restrictions of reactive parameters
if (wireDef.params) {
Object.keys(wireDef.params).forEach(function (param) {
var prop = wireDef.params[param];
var segments = prop.split('.');
segments.forEach(function (segment) {
assert.isTrue(segment.length > 0, "@wire on \"" + wireTarget + "\": reactive parameters must not be empty");
});
assert.isTrue(segments[0] !== wireTarget, "@wire on \"" + wireTarget + "\": reactive parameter \"" + segments[0] + "\" must not refer to self");
// restriction for dot-notation reactive parameters
if (segments.length > 1) {
// @wire emits a stream of immutable values. an emit sets the target property; it does not mutate a previously emitted value.
// restricting dot-notation reactive parameters to reference other @wire targets makes trapping the 'head' of the parameter
// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, "@wire on \"" + wireTarget + "\": dot-notation reactive parameter \"" + prop + "\" must refer to a @wire property");
}
});
}
}
});
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
}
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
},
connected: function connected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function disconnected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
}
},
connected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
},
};

@@ -584,5 +483,4 @@ /**

*/
function registerWireService(registerService) {
registerService(wireService);
registerService(wireService);
}

@@ -592,10 +490,8 @@ /**

*/
function register(adapterId, adapterFactory) {
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(adapterId, 'adapter id must be truthy');
assert.isTrue(typeof adapterFactory === 'function', 'adapter factory must be a callable');
}
adapterFactories.set(adapterId, adapterFactory);
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(adapterId, 'adapter id must be truthy');
assert.isTrue(typeof adapterFactory === 'function', 'adapter factory must be a callable');
}
adapterFactories.set(adapterId, adapterFactory);
}

@@ -606,2 +502,2 @@

exports.ValueChangedEvent = ValueChangedEvent;
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -63,3 +63,3 @@ /**

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach((metadata) => {
configListenerMetadatas.forEach(metadata => {
const { listener, statics, reactives } = metadata;

@@ -237,3 +237,3 @@ const reactiveValues = Object.create(null);

reference,
head: reference
head: reference,
};

@@ -245,3 +245,3 @@ }

head: segments.shift(),
tail: segments
tail: segments,
};

@@ -288,3 +288,3 @@ }

statics,
reactives
reactives,
};

@@ -326,3 +326,4 @@ // setup listeners for all reactive parameters

case CONFIG: {
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
const reactives = this._wireDef.params;

@@ -402,3 +403,3 @@ if (reactives) {

wiring: (cmp, data, def, context) => {
const wireContext = context[CONTEXT_ID] = Object.create(null);
const wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];

@@ -431,3 +432,4 @@ wireContext[CONTEXT_DISCONNECTED] = [];

// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
assert.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
}

@@ -442,3 +444,3 @@ });

addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});

@@ -461,3 +463,3 @@ }

invokeListener(listeners);
}
},
};

@@ -482,2 +484,2 @@ /**

export { registerWireService, register, ValueChangedEvent };
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -55,3 +55,3 @@ /* proxy-compat-disable */

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach((metadata) => {
configListenerMetadatas.forEach(metadata => {
const { listener, statics, reactives } = metadata;

@@ -229,3 +229,3 @@ const reactiveValues = Object.create(null);

reference,
head: reference
head: reference,
};

@@ -237,3 +237,3 @@ }

head: segments.shift(),
tail: segments
tail: segments,
};

@@ -274,3 +274,3 @@ }

statics,
reactives
reactives,
};

@@ -312,3 +312,4 @@ // setup listeners for all reactive parameters

case CONFIG: {
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
const reactives = this._wireDef.params;

@@ -388,3 +389,3 @@ if (reactives) {

wiring: (cmp, data, def, context) => {
const wireContext = context[CONTEXT_ID] = Object.create(null);
const wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];

@@ -405,3 +406,3 @@ wireContext[CONTEXT_DISCONNECTED] = [];

addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});

@@ -424,3 +425,3 @@ }

invokeListener(listeners);
}
},
};

@@ -447,2 +448,2 @@ /**

})));
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -69,3 +69,3 @@ /**

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach((metadata) => {
configListenerMetadatas.forEach(metadata => {
const { listener, statics, reactives } = metadata;

@@ -243,3 +243,3 @@ const reactiveValues = Object.create(null);

reference,
head: reference
head: reference,
};

@@ -251,3 +251,3 @@ }

head: segments.shift(),
tail: segments
tail: segments,
};

@@ -294,3 +294,3 @@ }

statics,
reactives
reactives,
};

@@ -332,3 +332,4 @@ // setup listeners for all reactive parameters

case CONFIG: {
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
const paramToConfigListenerMetadata = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
const reactives = this._wireDef.params;

@@ -408,3 +409,3 @@ if (reactives) {

wiring: (cmp, data, def, context) => {
const wireContext = context[CONTEXT_ID] = Object.create(null);
const wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];

@@ -437,3 +438,4 @@ wireContext[CONTEXT_DISCONNECTED] = [];

// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
assert.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
}

@@ -448,3 +450,3 @@ });

addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});

@@ -467,3 +469,3 @@ }

invokeListener(listeners);
}
},
};

@@ -494,2 +496,2 @@ /**

})));
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -22,38 +22,16 @@ /* proxy-compat-disable */

// key in engine service context for wire service context
var CONTEXT_ID = '@wire'; // key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated'; // key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected'; // key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected'; // wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect'; // wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect'; // wire event target life cycle config changed hook event type
var CONTEXT_ID = '@wire';
// key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated';
// key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected';
// key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected';
// wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect';
// wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect';
// wire event target life cycle config changed hook event type
var CONFIG = 'config';
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
/*

@@ -65,3 +43,2 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
/*

@@ -74,3 +51,2 @@ * Detects property changes by installing setter/getter overrides on the component

*/
/**

@@ -82,22 +58,17 @@ * Invokes the provided change listeners with the resolved component properties.

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener,
statics = metadata.statics,
reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
} // TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener, statics = metadata.statics, reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
}
// TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
}

@@ -110,36 +81,29 @@ /**

*/
function updated(cmp, reactiveParameter, configContext) {
if (!configContext.mutated) {
configContext.mutated = new Set(); // collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
if (!configContext.mutated) {
configContext.mutated = new Set();
// collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
}
function updatedFuture(cmp, configContext) {
var uniqueListeners = new Set(); // configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated; // pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
var uniqueListeners = new Set();
// configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated;
// pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
}

@@ -151,24 +115,16 @@ /**

*/
function getReactiveParameterValue(cmp, reactiveParameter) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (typeof value !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (_typeof(value) !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}

@@ -181,7 +137,6 @@ /**

*/
function installTrap(cmp, reactiveParameter, configContext) {
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
}

@@ -194,24 +149,17 @@ /**

*/
function findDescriptor(target, propName, protoSet) {
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
}

@@ -225,233 +173,199 @@ /**

*/
function getOverrideDescriptor(cmp, prop, callback) {
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set; // TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || descriptor.get === undefined && descriptor.set === undefined) {
var value_1 = cmp[prop];
enumerable = true;
get = function get() {
return value_1;
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set;
// TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || (descriptor.get === undefined && descriptor.set === undefined)) {
var value_1 = cmp[prop];
enumerable = true;
get = function () {
return value_1;
};
set = function (newValue) {
value_1 = newValue;
callback();
};
}
else {
var originalSet_1 = descriptor.set, originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function (newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function () {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true,
};
set = function set(newValue) {
value_1 = newValue;
callback();
};
} else {
var originalSet_1 = descriptor.set,
originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function set(newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function get() {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true
};
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function removeListener(listeners, toRemove) {
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
}
function removeConfigListener(configListenerMetadatas, toRemove) {
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
}
}
}
}
function buildReactiveParameter(reference) {
if (!reference.includes('.')) {
if (!reference.includes('.')) {
return {
reference: reference,
head: reference,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: reference
reference: reference,
head: segments.shift(),
tail: segments,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: segments.shift(),
tail: segments
};
}
var WireEventTarget =
/** @class */
function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
connectedListeners.push(listener);
break;
var WireEventTarget = /** @class */ (function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
connectedListeners.push(listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
disconnectedListeners.push(listener);
break;
}
case CONFIG: {
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0;
// no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1,
};
// setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
}
else {
configListenerMetadatas.push(configListenerMetadata_1);
}
// enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
}
default:
throw new Error("unsupported event type " + type);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
disconnectedListeners.push(listener);
break;
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
}
case CONFIG: {
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
case CONFIG:
{
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0; // no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1
}; // setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
} else {
configListenerMetadatas.push(configListenerMetadata_1);
} // enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (evt instanceof ValueChangedEvent) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
}
else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
else {
throw new Error("Invalid event " + evt + ".");
}
case CONFIG:
{
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (_instanceof(evt, ValueChangedEvent)) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
} else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
} else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
} else {
throw new Error("Invalid event " + evt + ".");
}
};
return WireEventTarget;
}();
};
return WireEventTarget;
}());
/**
* Event fired by wire adapters to emit a new value.
*/
var ValueChangedEvent = /** @class */ (function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}());
var ValueChangedEvent =
/** @class */
function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}();
/*

@@ -463,3 +377,3 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
// wire adapters: wire adapter id => adapter ctor
var adapterFactories = new Map();

@@ -470,7 +384,6 @@ /**

*/
function invokeListener(listeners) {
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
}

@@ -483,54 +396,42 @@ /**

*/
var wireService = {
wiring: function wiring(cmp, data, def, context) {
var wireContext = context[CONTEXT_ID] = Object.create(null);
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = {
listeners: {},
values: {}
}; // engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function _loop_1(i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
},
connected: function connected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function disconnected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
}
wiring: function (cmp, data, def, context) {
var wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = { listeners: {}, values: {} };
// engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function (i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
},
connected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
},
};

@@ -540,5 +441,4 @@ /**

*/
function registerWireService(registerService) {
registerService(wireService);
registerService(wireService);
}

@@ -548,6 +448,4 @@ /**

*/
function register(adapterId, adapterFactory) {
adapterFactories.set(adapterId, adapterFactory);
adapterFactories.set(adapterId, adapterFactory);
}

@@ -562,2 +460,2 @@

})));
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -17,12 +17,12 @@ /**

var assert = {
isTrue: function isTrue(value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
},
isFalse: function isFalse(value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
}
isTrue: function (value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
},
isFalse: function (value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
},
};

@@ -37,38 +37,16 @@

// key in engine service context for wire service context
var CONTEXT_ID = '@wire'; // key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated'; // key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected'; // key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected'; // wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect'; // wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect'; // wire event target life cycle config changed hook event type
var CONTEXT_ID = '@wire';
// key in wire service context for updated listener metadata
var CONTEXT_UPDATED = 'updated';
// key in wire service context for connected listener metadata
var CONTEXT_CONNECTED = 'connected';
// key in wire service context for disconnected listener metadata
var CONTEXT_DISCONNECTED = 'disconnected';
// wire event target life cycle connectedCallback hook event type
var CONNECT = 'connect';
// wire event target life cycle disconnectedCallback hook event type
var DISCONNECT = 'disconnect';
// wire event target life cycle config changed hook event type
var CONFIG = 'config';
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
/*

@@ -80,3 +58,2 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
/*

@@ -89,3 +66,2 @@ * Detects property changes by installing setter/getter overrides on the component

*/
/**

@@ -97,22 +73,17 @@ * Invokes the provided change listeners with the resolved component properties.

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener,
statics = metadata.statics,
reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
} // TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
configListenerMetadatas.forEach(function (metadata) {
var listener = metadata.listener, statics = metadata.statics, reactives = metadata.reactives;
var reactiveValues = Object.create(null);
if (reactives) {
var keys = Object.keys(reactives);
for (var j = 0, jlen = keys.length; j < jlen; j++) {
var key = keys[j];
var value = paramValues[reactives[key]];
reactiveValues[key] = value;
}
}
// TODO - consider read-only membrane to enforce invariant of immutable config
var config = Object.assign({}, statics, reactiveValues);
listener.call(undefined, config);
});
}

@@ -125,36 +96,29 @@ /**

*/
function updated(cmp, reactiveParameter, configContext) {
if (!configContext.mutated) {
configContext.mutated = new Set(); // collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
if (!configContext.mutated) {
configContext.mutated = new Set();
// collect all prop changes via a microtask
Promise.resolve().then(updatedFuture.bind(undefined, cmp, configContext));
}
configContext.mutated.add(reactiveParameter);
}
function updatedFuture(cmp, configContext) {
var uniqueListeners = new Set(); // configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated; // pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
var uniqueListeners = new Set();
// configContext.mutated must be set prior to invoking this function
var mutated = configContext.mutated;
delete configContext.mutated;
// pull this variable out of scope to workaround babel minify issue - https://github.com/babel/minify/issues/877
var listeners;
mutated.forEach(function (reactiveParameter) {
var value = getReactiveParameterValue(cmp, reactiveParameter);
if (configContext.values[reactiveParameter.reference] === value) {
return;
}
configContext.values[reactiveParameter.reference] = value;
listeners = configContext.listeners[reactiveParameter.head];
for (var i = 0, len = listeners.length; i < len; i++) {
uniqueListeners.add(listeners[i]);
}
});
invokeConfigListeners(uniqueListeners, configContext.values);
}

@@ -166,24 +130,16 @@ /**

*/
function getReactiveParameterValue(cmp, reactiveParameter) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
var value = cmp[reactiveParameter.head];
if (!reactiveParameter.tail) {
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (typeof value !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}
var segments = reactiveParameter.tail;
for (var i = 0, len = segments.length; i < len && value != null; i++) {
var segment = segments[i];
if (_typeof(value) !== 'object' || !(segment in value)) {
return undefined;
}
value = value[segment];
}
return value;
}

@@ -196,7 +152,6 @@ /**

*/
function installTrap(cmp, reactiveParameter, configContext) {
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
var callback = updated.bind(undefined, cmp, reactiveParameter, configContext);
var newDescriptor = getOverrideDescriptor(cmp, reactiveParameter.head, callback);
Object.defineProperty(cmp, reactiveParameter.head, newDescriptor);
}

@@ -209,24 +164,17 @@ /**

*/
function findDescriptor(target, propName, protoSet) {
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
protoSet = protoSet || [];
if (!target || protoSet.indexOf(target) > -1) {
return null; // null, undefined, or circular prototype definition
}
var descriptor = Object.getOwnPropertyDescriptor(target, propName);
if (descriptor) {
return descriptor;
}
var proto = Object.getPrototypeOf(target);
if (!proto) {
return null;
}
protoSet.push(target);
return findDescriptor(proto, propName, protoSet);
}

@@ -240,241 +188,205 @@ /**

*/
function getOverrideDescriptor(cmp, prop, callback) {
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set; // TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || descriptor.get === undefined && descriptor.set === undefined) {
var value_1 = cmp[prop];
enumerable = true;
get = function get() {
return value_1;
var descriptor = findDescriptor(cmp, prop);
var enumerable;
var get;
var set;
// TODO: this does not cover the override of existing descriptors at the instance level
// and that's ok because eventually we will not need to do any of these :)
if (descriptor === null || (descriptor.get === undefined && descriptor.set === undefined)) {
var value_1 = cmp[prop];
enumerable = true;
get = function () {
return value_1;
};
set = function (newValue) {
value_1 = newValue;
callback();
};
}
else {
var originalSet_1 = descriptor.set, originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function (newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function () {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true,
};
set = function set(newValue) {
value_1 = newValue;
callback();
};
} else {
var originalSet_1 = descriptor.set,
originalGet_1 = descriptor.get;
enumerable = descriptor.enumerable;
set = function set(newValue) {
if (originalSet_1) {
originalSet_1.call(cmp, newValue);
}
callback();
};
get = function get() {
return originalGet_1 ? originalGet_1.call(cmp) : undefined;
};
}
return {
set: set,
get: get,
enumerable: enumerable,
configurable: true
};
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function removeListener(listeners, toRemove) {
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
var idx = listeners.indexOf(toRemove);
if (idx > -1) {
listeners.splice(idx, 1);
}
}
function removeConfigListener(configListenerMetadatas, toRemove) {
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
for (var i = 0, len = configListenerMetadatas.length; i < len; i++) {
if (configListenerMetadatas[i].listener === toRemove) {
configListenerMetadatas.splice(i, 1);
return;
}
}
}
}
function buildReactiveParameter(reference) {
if (!reference.includes('.')) {
if (!reference.includes('.')) {
return {
reference: reference,
head: reference,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: reference
reference: reference,
head: segments.shift(),
tail: segments,
};
}
var segments = reference.split('.');
return {
reference: reference,
head: segments.shift(),
tail: segments
};
}
var WireEventTarget =
/** @class */
function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
{
assert.isFalse(connectedListeners.includes(listener), 'must not call addEventListener("connect") with the same listener');
}
connectedListeners.push(listener);
break;
var WireEventTarget = /** @class */ (function () {
function WireEventTarget(cmp, def, context, wireDef, wireTarget) {
this._cmp = cmp;
this._def = def;
this._context = context;
this._wireDef = wireDef;
this._wireTarget = wireTarget;
}
WireEventTarget.prototype.addEventListener = function (type, listener) {
var _this = this;
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
{
assert.isFalse(connectedListeners.includes(listener), 'must not call addEventListener("connect") with the same listener');
}
connectedListeners.push(listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
{
assert.isFalse(disconnectedListeners.includes(listener), 'must not call addEventListener("disconnect") with the same listener');
}
disconnectedListeners.push(listener);
break;
}
case CONFIG: {
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0;
// no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1,
};
// setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
}
else {
configListenerMetadatas.push(configListenerMetadata_1);
}
// enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
}
default:
throw new Error("unsupported event type " + type);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
{
assert.isFalse(disconnectedListeners.includes(listener), 'must not call addEventListener("disconnect") with the same listener');
}
disconnectedListeners.push(listener);
break;
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT: {
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
}
case DISCONNECT: {
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
}
case CONFIG: {
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED]
.listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
case CONFIG:
{
var reactives_1 = this._wireDef.params;
var statics = this._wireDef.static;
var reactiveKeys = void 0; // no reactive parameters. fire config once with static parameters (if present).
if (!reactives_1 || (reactiveKeys = Object.keys(reactives_1)).length === 0) {
var config = statics || Object.create(null);
listener.call(undefined, config);
return;
}
var configListenerMetadata_1 = {
listener: listener,
statics: statics,
reactives: reactives_1
}; // setup listeners for all reactive parameters
var configContext_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED];
reactiveKeys.forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_1[key]);
var configListenerMetadatas = configContext_1.listeners[reactiveParameter.head];
if (!configListenerMetadatas) {
configListenerMetadatas = [configListenerMetadata_1];
configContext_1.listeners[reactiveParameter.head] = configListenerMetadatas;
installTrap(_this._cmp, reactiveParameter, configContext_1);
} else {
configListenerMetadatas.push(configListenerMetadata_1);
} // enqueue to pickup default values
updated(_this._cmp, reactiveParameter, configContext_1);
});
break;
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (evt instanceof ValueChangedEvent) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
}
else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.removeEventListener = function (type, listener) {
switch (type) {
case CONNECT:
{
var connectedListeners = this._context[CONTEXT_ID][CONTEXT_CONNECTED];
removeListener(connectedListeners, listener);
break;
else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
}
case DISCONNECT:
{
var disconnectedListeners = this._context[CONTEXT_ID][CONTEXT_DISCONNECTED];
removeListener(disconnectedListeners, listener);
break;
else {
throw new Error("Invalid event " + evt + ".");
}
case CONFIG:
{
var paramToConfigListenerMetadata_1 = this._context[CONTEXT_ID][CONTEXT_UPDATED].listeners;
var reactives_2 = this._wireDef.params;
if (reactives_2) {
Object.keys(reactives_2).forEach(function (key) {
var reactiveParameter = buildReactiveParameter(reactives_2[key]);
var configListenerMetadatas = paramToConfigListenerMetadata_1[reactiveParameter.head];
if (configListenerMetadatas) {
removeConfigListener(configListenerMetadatas, listener);
}
});
}
break;
}
default:
throw new Error("unsupported event type " + type);
}
};
WireEventTarget.prototype.dispatchEvent = function (evt) {
if (_instanceof(evt, ValueChangedEvent)) {
var value = evt.value;
if (this._wireDef.method) {
this._cmp[this._wireTarget](value);
} else {
this._cmp[this._wireTarget] = value;
}
return false; // canceling signal since we don't want this to propagate
} else if (evt.type === 'WireContextEvent') {
// NOTE: kill this hack
// we should only allow ValueChangedEvent
// however, doing so would require adapter to implement machinery
// that fire the intended event as DOM event and wrap inside ValueChangedEvent
return this._cmp.dispatchEvent(evt);
} else {
throw new Error("Invalid event " + evt + ".");
}
};
return WireEventTarget;
}();
};
return WireEventTarget;
}());
/**
* Event fired by wire adapters to emit a new value.
*/
var ValueChangedEvent = /** @class */ (function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}());
var ValueChangedEvent =
/** @class */
function () {
function ValueChangedEvent(value) {
this.type = 'ValueChangedEvent';
this.value = value;
}
return ValueChangedEvent;
}();
/*

@@ -486,3 +398,3 @@ * Copyright (c) 2018, salesforce.com, inc.

*/
// wire adapters: wire adapter id => adapter ctor
var adapterFactories = new Map();

@@ -493,7 +405,6 @@ /**

*/
function invokeListener(listeners) {
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
for (var i = 0, len = listeners.length; i < len; ++i) {
listeners[i].call(undefined);
}
}

@@ -506,77 +417,65 @@ /**

*/
var wireService = {
wiring: function wiring(cmp, data, def, context) {
var wireContext = context[CONTEXT_ID] = Object.create(null);
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = {
listeners: {},
values: {}
}; // engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function _loop_1(i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
{
assert.isTrue(wireDef.adapter, "@wire on \"" + wireTarget + "\": adapter id must be truthy");
assert.isTrue(adapterFactory, "@wire on \"" + wireTarget + "\": unknown adapter id: " + String(wireDef.adapter)); // enforce restrictions of reactive parameters
if (wireDef.params) {
Object.keys(wireDef.params).forEach(function (param) {
var prop = wireDef.params[param];
var segments = prop.split('.');
segments.forEach(function (segment) {
assert.isTrue(segment.length > 0, "@wire on \"" + wireTarget + "\": reactive parameters must not be empty");
});
assert.isTrue(segments[0] !== wireTarget, "@wire on \"" + wireTarget + "\": reactive parameter \"" + segments[0] + "\" must not refer to self"); // restriction for dot-notation reactive parameters
if (segments.length > 1) {
// @wire emits a stream of immutable values. an emit sets the target property; it does not mutate a previously emitted value.
// restricting dot-notation reactive parameters to reference other @wire targets makes trapping the 'head' of the parameter
// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, "@wire on \"" + wireTarget + "\": dot-notation reactive parameter \"" + prop + "\" must refer to a @wire property");
wiring: function (cmp, data, def, context) {
var wireContext = (context[CONTEXT_ID] = Object.create(null));
wireContext[CONTEXT_CONNECTED] = [];
wireContext[CONTEXT_DISCONNECTED] = [];
wireContext[CONTEXT_UPDATED] = { listeners: {}, values: {} };
// engine guarantees invocation only if def.wire is defined
var wireStaticDef = def.wire;
var wireTargets = Object.keys(wireStaticDef);
var _loop_1 = function (i, len) {
var wireTarget = wireTargets[i];
var wireDef = wireStaticDef[wireTarget];
var adapterFactory = adapterFactories.get(wireDef.adapter);
{
assert.isTrue(wireDef.adapter, "@wire on \"" + wireTarget + "\": adapter id must be truthy");
assert.isTrue(adapterFactory, "@wire on \"" + wireTarget + "\": unknown adapter id: " + String(wireDef.adapter));
// enforce restrictions of reactive parameters
if (wireDef.params) {
Object.keys(wireDef.params).forEach(function (param) {
var prop = wireDef.params[param];
var segments = prop.split('.');
segments.forEach(function (segment) {
assert.isTrue(segment.length > 0, "@wire on \"" + wireTarget + "\": reactive parameters must not be empty");
});
assert.isTrue(segments[0] !== wireTarget, "@wire on \"" + wireTarget + "\": reactive parameter \"" + segments[0] + "\" must not refer to self");
// restriction for dot-notation reactive parameters
if (segments.length > 1) {
// @wire emits a stream of immutable values. an emit sets the target property; it does not mutate a previously emitted value.
// restricting dot-notation reactive parameters to reference other @wire targets makes trapping the 'head' of the parameter
// sufficient to observe the value change.
assert.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, "@wire on \"" + wireTarget + "\": dot-notation reactive parameter \"" + prop + "\" must refer to a @wire property");
}
});
}
}
});
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
}
if (adapterFactory) {
var wireEventTarget = new WireEventTarget(cmp, def, context, wireDef, wireTarget);
adapterFactory({
dispatchEvent: wireEventTarget.dispatchEvent.bind(wireEventTarget),
addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
});
}
};
for (var i = 0, len = wireTargets.length; i < len; i++) {
_loop_1(i, len);
}
},
connected: function connected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function disconnected(cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
}
},
connected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_CONNECTED])) {
return;
}
invokeListener(listeners);
},
disconnected: function (cmp, data, def, context) {
var listeners;
if (!def.wire || !(listeners = context[CONTEXT_ID][CONTEXT_DISCONNECTED])) {
return;
}
invokeListener(listeners);
},
};

@@ -586,5 +485,4 @@ /**

*/
function registerWireService(registerService) {
registerService(wireService);
registerService(wireService);
}

@@ -594,10 +492,8 @@ /**

*/
function register(adapterId, adapterFactory) {
{
assert.isTrue(adapterId, 'adapter id must be truthy');
assert.isTrue(typeof adapterFactory === 'function', 'adapter factory must be a callable');
}
adapterFactories.set(adapterId, adapterFactory);
{
assert.isTrue(adapterId, 'adapter id must be truthy');
assert.isTrue(typeof adapterFactory === 'function', 'adapter factory must be a callable');
}
adapterFactories.set(adapterId, adapterFactory);
}

@@ -612,2 +508,2 @@

})));
/** version: 0.35.11 */
/** version: 0.35.12 */

@@ -1,1 +0,1 @@

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.WireService={})})(this,function(a){"use strict";function b(a,b){return null!=b&&"undefined"!=typeof Symbol&&b[Symbol.hasInstance]?b[Symbol.hasInstance](a):a instanceof b}function c(a){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},c(a)}function d(a,b){a.forEach(function(a){var c=a.listener,d=a.statics,e=a.reactives,f=Object.create(null);if(e)for(var g=Object.keys(e),h=0,i=g.length;h<i;h++){var k=g[h],l=b[e[k]];f[k]=l}var m=Object.assign({},d,f);c.call(void 0,m)})}function e(a,b,c){c.mutated||(c.mutated=new Set,Promise.resolve().then(f.bind(void 0,a,c))),c.mutated.add(b)}function f(a,b){var c=new Set,e=b.mutated;delete b.mutated;var f;e.forEach(function(d){var e=g(a,d);if(b.values[d.reference]!==e){b.values[d.reference]=e,f=b.listeners[d.head];for(var h=0,j=f.length;h<j;h++)c.add(f[h])}}),d(c,b.values)}function g(a,b){var d=a[b.head];if(!b.tail)return d;for(var e,f=b.tail,g=0,h=f.length;g<h&&null!=d;g++){if(e=f[g],"object"!==c(d)||!(e in d))return;d=d[e]}return d}function h(a,b,c){var d=e.bind(void 0,a,b,c),f=j(a,b.head,d);Object.defineProperty(a,b.head,f)}function i(a,b,c){if(c=c||[],!a||-1<c.indexOf(a))return null;var d=Object.getOwnPropertyDescriptor(a,b);if(d)return d;var e=Object.getPrototypeOf(a);return e?(c.push(a),i(e,b,c)):null}function j(a,b,c){var d,e,f,g=i(a,b);if(null===g||g.get===void 0&&g.set===void 0){var h=a[b];d=!0,e=function(){return h},f=function(a){h=a,c()}}else{var j=g.set,k=g.get;d=g.enumerable,f=function(b){j&&j.call(a,b),c()},e=function(){return k?k.call(a):void 0}}return{set:f,get:e,enumerable:d,configurable:!0}}function k(a,b){var c=a.indexOf(b);-1<c&&a.splice(c,1)}function l(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c].listener===b)return void a.splice(c,1)}function m(a){if(!a.includes("."))return{reference:a,head:a};var b=a.split(".");return{reference:a,head:b.shift(),tail:b}}function n(a){for(var b=0,c=a.length;b<c;++b)a[b].call(void 0)}var o="updated",p="connected",q="disconnected",r="connect",s="disconnect",t="config",u=function(){function a(a,b,c,d,e){this._cmp=a,this._def=b,this._context=c,this._wireDef=d,this._wireTarget=e}return a.prototype.addEventListener=function(a,b){var c=this;switch(a){case r:{var d=this._context["@wire"][p];d.push(b);break}case s:{var f=this._context["@wire"][q];f.push(b);break}case t:{var g=this._wireDef.params,i=this._wireDef.static,j=void 0;if(!g||0===(j=Object.keys(g)).length){var k=i||Object.create(null);return void b.call(void 0,k)}var l={listener:b,statics:i,reactives:g},n=this._context["@wire"][o];j.forEach(function(a){var b=m(g[a]),d=n.listeners[b.head];d?d.push(l):(d=[l],n.listeners[b.head]=d,h(c._cmp,b,n)),e(c._cmp,b,n)});break}default:throw new Error("unsupported event type "+a);}},a.prototype.removeEventListener=function(a,b){switch(a){case r:{var c=this._context["@wire"][p];k(c,b);break}case s:{var d=this._context["@wire"][q];k(d,b);break}case t:{var e=this._context["@wire"][o].listeners,f=this._wireDef.params;f&&Object.keys(f).forEach(function(a){var c=m(f[a]),d=e[c.head];d&&l(d,b)});break}default:throw new Error("unsupported event type "+a);}},a.prototype.dispatchEvent=function(a){if(b(a,v)){var c=a.value;return this._wireDef.method?this._cmp[this._wireTarget](c):this._cmp[this._wireTarget]=c,!1}if("WireContextEvent"===a.type)return this._cmp.dispatchEvent(a);throw new Error("Invalid event "+a+".")},a}(),v=function(){return function(a){this.type="ValueChangedEvent",this.value=a}}(),w=new Map,x={wiring:function(a,b,c,d){var e=d["@wire"]=Object.create(null);e[p]=[],e[q]=[],e[o]={listeners:{},values:{}};for(var f=c.wire,g=Object.keys(f),h=function(b){var e=g[b],h=f[e],i=w.get(h.adapter);if(i){var j=new u(a,c,d,h,e);i({dispatchEvent:j.dispatchEvent.bind(j),addEventListener:j.addEventListener.bind(j),removeEventListener:j.removeEventListener.bind(j)})}},j=0,k=g.length;j<k;j++)h(j,k)},connected:function(a,b,c,d){var e;c.wire&&(e=d["@wire"][p])&&n(e)},disconnected:function(a,b,c,d){var e;c.wire&&(e=d["@wire"][q])&&n(e)}};a.registerWireService=function(a){a(x)},a.register=function(a,b){w.set(a,b)},a.ValueChangedEvent=v,Object.defineProperty(a,"__esModule",{value:!0})});
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.WireService={})})(this,function(a){"use strict";function b(a,b){a.forEach(function(a){var c=a.listener,d=a.statics,e=a.reactives,f=Object.create(null);if(e)for(var g=Object.keys(e),h=0,i=g.length;h<i;h++){var k=g[h],l=b[e[k]];f[k]=l}var m=Object.assign({},d,f);c.call(void 0,m)})}function c(a,b,c){c.mutated||(c.mutated=new Set,Promise.resolve().then(d.bind(void 0,a,c))),c.mutated.add(b)}function d(a,c){var d=new Set,f=c.mutated;delete c.mutated;var g;f.forEach(function(b){var f=e(a,b);if(c.values[b.reference]!==f){c.values[b.reference]=f,g=c.listeners[b.head];for(var h=0,j=g.length;h<j;h++)d.add(g[h])}}),b(d,c.values)}function e(a,b){var c=a[b.head];if(!b.tail)return c;for(var d,e=b.tail,f=0,g=e.length;f<g&&null!=c;f++){if(d=e[f],"object"!=typeof c||!(d in c))return;c=c[d]}return c}function f(a,b,d){var e=c.bind(void 0,a,b,d),f=h(a,b.head,e);Object.defineProperty(a,b.head,f)}function g(a,b,c){if(c=c||[],!a||-1<c.indexOf(a))return null;var d=Object.getOwnPropertyDescriptor(a,b);if(d)return d;var e=Object.getPrototypeOf(a);return e?(c.push(a),g(e,b,c)):null}function h(a,b,c){var d,e,f,h=g(a,b);if(null===h||h.get===void 0&&h.set===void 0){var i=a[b];d=!0,e=function(){return i},f=function(a){i=a,c()}}else{var j=h.set,k=h.get;d=h.enumerable,f=function(b){j&&j.call(a,b),c()},e=function(){return k?k.call(a):void 0}}return{set:f,get:e,enumerable:d,configurable:!0}}function i(a,b){var c=a.indexOf(b);-1<c&&a.splice(c,1)}function j(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c].listener===b)return void a.splice(c,1)}function k(a){if(!a.includes("."))return{reference:a,head:a};var b=a.split(".");return{reference:a,head:b.shift(),tail:b}}function l(a){for(var b=0,c=a.length;b<c;++b)a[b].call(void 0)}var m="updated",n="connected",o="disconnected",p="connect",q="disconnect",r="config",s=function(){function a(a,b,c,d,e){this._cmp=a,this._def=b,this._context=c,this._wireDef=d,this._wireTarget=e}return a.prototype.addEventListener=function(a,b){var d=this;switch(a){case p:{var e=this._context["@wire"][n];e.push(b);break}case q:{var g=this._context["@wire"][o];g.push(b);break}case r:{var h=this._wireDef.params,i=this._wireDef.static,j=void 0;if(!h||0===(j=Object.keys(h)).length){var l=i||Object.create(null);return void b.call(void 0,l)}var s={listener:b,statics:i,reactives:h},t=this._context["@wire"][m];j.forEach(function(a){var b=k(h[a]),e=t.listeners[b.head];e?e.push(s):(e=[s],t.listeners[b.head]=e,f(d._cmp,b,t)),c(d._cmp,b,t)});break}default:throw new Error("unsupported event type "+a);}},a.prototype.removeEventListener=function(a,b){switch(a){case p:{var c=this._context["@wire"][n];i(c,b);break}case q:{var d=this._context["@wire"][o];i(d,b);break}case r:{var e=this._context["@wire"][m].listeners,f=this._wireDef.params;f&&Object.keys(f).forEach(function(a){var c=k(f[a]),d=e[c.head];d&&j(d,b)});break}default:throw new Error("unsupported event type "+a);}},a.prototype.dispatchEvent=function(a){if(a instanceof t){var b=a.value;return this._wireDef.method?this._cmp[this._wireTarget](b):this._cmp[this._wireTarget]=b,!1}if("WireContextEvent"===a.type)return this._cmp.dispatchEvent(a);throw new Error("Invalid event "+a+".")},a}(),t=function(){return function(a){this.type="ValueChangedEvent",this.value=a}}(),u=new Map,v={wiring:function(a,b,c,d){var e=d["@wire"]=Object.create(null);e[n]=[],e[o]=[],e[m]={listeners:{},values:{}};for(var f=c.wire,g=Object.keys(f),h=function(b){var e=g[b],h=f[e],i=u.get(h.adapter);if(i){var j=new s(a,c,d,h,e);i({dispatchEvent:j.dispatchEvent.bind(j),addEventListener:j.addEventListener.bind(j),removeEventListener:j.removeEventListener.bind(j)})}},j=0,k=g.length;j<k;j++)h(j,k)},connected:function(a,b,c,d){var e;c.wire&&(e=d["@wire"][n])&&l(e)},disconnected:function(a,b,c,d){var e;c.wire&&(e=d["@wire"][o])&&l(e)}};a.registerWireService=function(a){a(v)},a.register=function(a,b){u.set(a,b)},a.ValueChangedEvent=t,Object.defineProperty(a,"__esModule",{value:!0})});

@@ -40,3 +40,3 @@ "use strict";

wiring: (cmp, data, def, context) => {
const wireContext = context[constants_1.CONTEXT_ID] = Object.create(null);
const wireContext = (context[constants_1.CONTEXT_ID] = Object.create(null));
wireContext[constants_1.CONTEXT_CONNECTED] = [];

@@ -69,3 +69,4 @@ wireContext[constants_1.CONTEXT_DISCONNECTED] = [];

// sufficient to observe the value change.
assert_1.default.isTrue(wireTargets.includes(segments[0]) && wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
assert_1.default.isTrue(wireTargets.includes(segments[0]) &&
wireStaticDef[segments[0]].method !== 1, `@wire on "${wireTarget}": dot-notation reactive parameter "${prop}" must refer to a @wire property`);
}

@@ -80,3 +81,3 @@ });

addEventListener: wireEventTarget.addEventListener.bind(wireEventTarget),
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget)
removeEventListener: wireEventTarget.removeEventListener.bind(wireEventTarget),
});

@@ -99,3 +100,3 @@ }

invokeListener(listeners);
}
},
};

@@ -102,0 +103,0 @@ /**

@@ -22,3 +22,3 @@ "use strict";

function invokeConfigListeners(configListenerMetadatas, paramValues) {
configListenerMetadatas.forEach((metadata) => {
configListenerMetadatas.forEach(metadata => {
const { listener, statics, reactives } = metadata;

@@ -25,0 +25,0 @@ const reactiveValues = Object.create(null);

@@ -33,3 +33,3 @@ "use strict";

reference,
head: reference
head: reference,
};

@@ -41,3 +41,3 @@ }

head: segments.shift(),
tail: segments
tail: segments,
};

@@ -84,3 +84,3 @@ }

statics,
reactives
reactives,
};

@@ -122,3 +122,4 @@ // setup listeners for all reactive parameters

case constants_1.CONFIG: {
const paramToConfigListenerMetadata = this._context[constants_1.CONTEXT_ID][constants_1.CONTEXT_UPDATED].listeners;
const paramToConfigListenerMetadata = this._context[constants_1.CONTEXT_ID][constants_1.CONTEXT_UPDATED]
.listeners;
const reactives = this._wireDef.params;

@@ -125,0 +126,0 @@ if (reactives) {

{
"name": "@lwc/wire-service",
"version": "0.35.11",
"description": "@wire service",
"license": "MIT",
"main": "dist/commonjs/es2017/wire.js",
"module": "dist/modules/es2017/wire.js",
"scripts": {
"clean": "rm -rf dist/ lib/",
"test": "jest",
"build": "tsc && rollup --config ./scripts/rollup/rollup.config.js",
"start": "concurrently \"yarn run build:playground --watch\" \"yarn run serve:playground\"",
"build:playground": "rollup -c playground/rollup.config.js",
"serve:playground": "node playground/server.js"
},
"devDependencies": {
"@lwc/compiler": "0.35.11",
"@lwc/engine": "0.35.11",
"@lwc/jest-transformer": "0.35.11",
"@lwc/rollup-plugin": "0.35.11",
"express": "^4.15.2"
},
"lwc": {
"modules": {
"wire-service": "dist/modules/es2017/wire.js"
}
},
"publishConfig": {
"access": "public"
},
"gitHead": "59298cd9789d1beca3c32529eaa56e7cf1de3466"
"name": "@lwc/wire-service",
"version": "0.35.12",
"description": "@wire service",
"license": "MIT",
"main": "dist/commonjs/es2017/wire.js",
"module": "dist/modules/es2017/wire.js",
"scripts": {
"clean": "rm -rf dist/ lib/",
"test": "jest",
"build": "tsc && rollup --config ./scripts/rollup/rollup.config.js",
"start": "concurrently \"yarn run build:playground --watch\" \"yarn run serve:playground\"",
"build:playground": "rollup -c playground/rollup.config.js",
"serve:playground": "node playground/server.js"
},
"devDependencies": {
"@lwc/compiler": "0.35.12",
"@lwc/engine": "0.35.12",
"@lwc/jest-transformer": "0.35.12",
"@lwc/rollup-plugin": "0.35.12",
"express": "^4.15.2"
},
"lwc": {
"modules": {
"wire-service": "dist/modules/es2017/wire.js"
}
},
"publishConfig": {
"access": "public"
},
"gitHead": "3b3c278249e7751aea87e8e0b877eaa231dde808"
}

@@ -9,11 +9,11 @@ # Wire Service

* Loading data is expressed declaratively by a component using `@wire([adapterId], [adapterConfig])`
* `[adapterId]` refers to the identity of a wire adapter.
* `[adapterConfig]` is an optional parameter, of type object, that defines wire adapter-specific configuration.
* `[adapterConfig]` may contain static values or reactive references.
* A reactive reference is identified with a `$` prefix. The remainder of the string identifies a class property. A change to a referenced class property causes new data to be requested from the wire adapter.
* The wire service delegates to `wire adapters` to source, manage, and provision data. The wire service sits between wire adapters and LWC components.
* It's all data from the wire service's perspective. Nothing is metadata.
* It is assumed all data mutates over time yet a given snapshot of data is immutable.
* A component receiving data does not own that data. It is comparable to a component receiving props does not own the props.
- Loading data is expressed declaratively by a component using `@wire([adapterId], [adapterConfig])`
- `[adapterId]` refers to the identity of a wire adapter.
- `[adapterConfig]` is an optional parameter, of type object, that defines wire adapter-specific configuration.
- `[adapterConfig]` may contain static values or reactive references.
- A reactive reference is identified with a `$` prefix. The remainder of the string identifies a class property. A change to a referenced class property causes new data to be requested from the wire adapter.
- The wire service delegates to `wire adapters` to source, manage, and provision data. The wire service sits between wire adapters and LWC components.
- It's all data from the wire service's perspective. Nothing is metadata.
- It is assumed all data mutates over time yet a given snapshot of data is immutable.
- A component receiving data does not own that data. It is comparable to a component receiving props does not own the props.

@@ -36,3 +36,3 @@ ## Example Use Of `@wire`

@wire(getTodo, { id: '$id' })
todo
todo;
}

@@ -43,4 +43,4 @@ ```

<template>
<template if:true={todo}>
<input type="checkbox" checked={todo.completed}> {todo.title}
<template if:true="{todo}">
<input type="checkbox" checked="{todo.completed}" /> {todo.title}
</template>

@@ -88,6 +88,7 @@ </template>

`eventTarget` is an implementation of [Event Target](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) that supports listeners for the following events:
- `config` is delivered when the resolved configuration changes. A singular argument is provided: the resolved configuration.
- `connect` is delivered when the component is connected.
- `disconnect` is delivered when the component is disconnected.
- `config` is delivered when the resolved configuration changes. A singular argument is provided: the resolved configuration.
- `connect` is delivered when the component is connected.
- `disconnect` is delivered when the component is disconnected.
The wire service remains responsible for resolving the configuration object. `eventTarget` delivers a `config` event when the resolved configuration changes. The value of the configuration is specific to the wire adapter. The wire adapter must treat the object as immutable.

@@ -103,4 +104,2 @@

```ts

@@ -128,3 +127,3 @@ register(adapterId: WireAdapterId, wireAdapterFactory: WireAdapterFactory);

// Invoked when config is updated.
eventTarget.addListener('config', (newConfig) => {
eventTarget.addListener('config', newConfig => {
// Capture config for use during subscription.

@@ -140,8 +139,14 @@ config = newConfig;

.subscribe({
next: (data) => wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data, error: undefined })),
error: (error) => wiredEventTarget.dispatchEvent(new ValueChangedEvent({ data: undefined, error }))
next: data =>
wiredEventTarget.dispatchEvent(
new ValueChangedEvent({ data, error: undefined })
),
error: error =>
wiredEventTarget.dispatchEvent(
new ValueChangedEvent({ data: undefined, error })
),
});
})
});
// Invoked when component disconnected.
// Invoked when component disconnected.
eventTarget.addListener('disconnected', () => {

@@ -148,0 +153,0 @@ // Release all resources.

@@ -7,13 +7,8 @@ /*

*/
const COMPAT_SUFFIX = "_compat";
const DEBUG_SUFFIX = "_debug";
const PROD_SUFFIX = ".min";
const COMPAT_SUFFIX = '_compat';
const DEBUG_SUFFIX = '_debug';
const PROD_SUFFIX = '.min';
function generateTargetName({ prod, proddebug }){
return [
'wire',
proddebug ? DEBUG_SUFFIX : '',
prod ? '.min' : '',
'.js'
].join('');
function generateTargetName({ prod, proddebug }) {
return ['wire', proddebug ? DEBUG_SUFFIX : '', prod ? '.min' : '', '.js'].join('');
}

@@ -25,4 +20,3 @@

PROD_SUFFIX,
generateTargetName: generateTargetName
}
generateTargetName: generateTargetName,
};
{
"extends": "../../../tsconfig.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"noImplicitAny": false,
"compilerOptions": {
"noImplicitAny": false,
"outDir": "lib",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"lwc": ["../engine"],
}
},
"baseUrl": ".",
"paths": {
"lwc": ["../engine"]
}
},
"include": [
"src/",
]
"include": ["src/"]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc