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

@matchlighter/common_library

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matchlighter/common_library - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

lib/components/ContextDict.d.ts

1

lib/deep/index.d.ts
export * from './deep_common';
export * from './deep';
export { deep_sync_adv } from './deep_sync_adv';
export * from './deep_common';
export * from './deep';
export { deep_sync_adv } from './deep_sync_adv';
//# sourceMappingURL=index.js.map

23

lib/macros/dig.macro.js

@@ -1,2 +0,4 @@

import { createMacro } from 'babel-plugin-macros';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var babel_plugin_macros_1 = require("babel-plugin-macros");
/**

@@ -12,6 +14,7 @@ * Macro to convert an expression into a safe-traversal expression.

*/
export default createMacro(({ references, state, babel: { types: t } }) => {
exports.default = babel_plugin_macros_1.createMacro(function (_a) {
var references = _a.references, state = _a.state, t = _a.babel.types;
function rewriteSubMemberExpression(me) {
const meObjExp = me.object;
const expCheck = t.binaryExpression('!=', meObjExp, t.nullLiteral());
var meObjExp = me.object;
var expCheck = t.binaryExpression('!=', meObjExp, t.nullLiteral());
if (meObjExp.type == 'MemberExpression' && meObjExp.object.type != 'ThisExpression') {

@@ -22,8 +25,8 @@ return t.logicalExpression('&&', rewriteSubMemberExpression(meObjExp), expCheck);

}
references.default.forEach(ref => {
const call_expr = ref.container;
const member_expr = call_expr.arguments[0];
const default_expr = call_expr.arguments[1] || t.nullLiteral();
const test_expr = rewriteSubMemberExpression(member_expr);
const nex = t.conditionalExpression(test_expr, member_expr, default_expr);
references.default.forEach(function (ref) {
var call_expr = ref.container;
var member_expr = call_expr.arguments[0];
var default_expr = call_expr.arguments[1] || t.nullLiteral();
var test_expr = rewriteSubMemberExpression(member_expr);
var nex = t.conditionalExpression(test_expr, member_expr, default_expr);
ref.parentPath.replaceWith(nex);

@@ -30,0 +33,0 @@ });

@@ -1,7 +0,9 @@

import { createMacro } from 'babel-plugin-macros';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var babel_plugin_macros_1 = require("babel-plugin-macros");
function ensureImport(t, program, importSpecifier, importSource) {
// check to see if we've already added the real import line to this file
const foundImport = program.get("body").filter((x) => {
var foundImport = program.get("body").filter(function (x) {
if (t.isImportDeclaration(x) && x.node.source.value === importSource) {
return (x.node.specifiers.filter((s) => s.local.name === importSpecifier).length > 0);
return (x.node.specifiers.filter(function (s) { return s.local.name === importSpecifier; }).length > 0);
}

@@ -27,11 +29,12 @@ return false;

*/
export default createMacro(({ references, state, babel: { types: t } }) => {
references.default.forEach(ref => {
const call_expr = ref.container;
const comp_expr = call_expr.arguments[0];
const cf_expr = t.arrowFunctionExpression([], comp_expr);
const comp_inst_expr = t.callExpression(t.identifier('computed'), [cf_expr]);
const get_expr = t.memberExpression(comp_inst_expr, t.identifier('get'));
const get_call_expr = t.callExpression(get_expr, []);
const program = ref.scope.getProgramParent().path;
exports.default = babel_plugin_macros_1.createMacro(function (_a) {
var references = _a.references, state = _a.state, t = _a.babel.types;
references.default.forEach(function (ref) {
var call_expr = ref.container;
var comp_expr = call_expr.arguments[0];
var cf_expr = t.arrowFunctionExpression([], comp_expr);
var comp_inst_expr = t.callExpression(t.identifier('computed'), [cf_expr]);
var get_expr = t.memberExpression(comp_inst_expr, t.identifier('get'));
var get_call_expr = t.callExpression(get_expr, []);
var program = ref.scope.getProgramParent().path;
ensureImport(t, program, 'computed', 'mobx');

@@ -38,0 +41,0 @@ ref.parentPath.replaceWith(get_call_expr);

@@ -0,17 +1,4 @@

import { DeepSyncOptions } from './deep/deep_sync_adv';
declare const syncedObservableSymbol: unique symbol;
declare type FilterFunc = (path: string, object: any) => boolean;
declare type FilterSelector = string | string[] | FilterFunc;
export interface SyncedObservableOptions {
/**
* Accepts a list of JSONPath patterns.
* Any objects that are set at those paths are directly stored as
* references instead of being duplicated into an observable object.
*/
refs?: FilterSelector;
/**
* Accepts a list of JSONPath patterns.
* Any objects that are set at those paths will not be included
* in the duplicated object.
*/
exclude?: FilterSelector;
interface SyncedObservableOptions extends DeepSyncOptions {
}

@@ -18,0 +5,0 @@ declare class SyncedObservable<T> {

import { observable } from 'mobx';
import * as JSONPath from 'jsonpath';
import { deepSyncInternal, normalizeFilter } from './deep/deep_sync_adv';
const syncedObservableSymbol = Symbol();

@@ -69,58 +69,6 @@ class SyncedObservable {

currentPath: ['$'],
initializeMissingValue: (v) => observable(v, {}, { deep: false }),
});
return target;
}
function deepSyncInternal(target, source, options) {
for (let [k, v] of Object.entries(source)) {
const currentPath = [...options.currentPath, k];
const currentPathSpec = JSONPath.stringify(currentPath);
if (options.excludePaths(currentPathSpec, v))
continue;
if (options.refPaths(currentPathSpec, v) || typeof v != 'object') {
target[k] = v;
}
else if (typeof v != typeof target[k]) {
target[k] = observable(v, {}, { deep: false });
}
else if (Array.isArray(v) && Array.isArray(target[k])) {
deepSyncInternal(target[k], v, Object.assign(Object.assign({}, options), { currentPath }));
}
else if (v == null || target[k] == null) {
target[k] = observable(v, {}, { deep: false });
}
else if ((Object.getPrototypeOf(v) != Object.prototype) || (Object.getPrototypeOf(target[k]) != Object.prototype)) {
target[k] = observable(v, {}, { deep: false });
}
else {
deepSyncInternal(target[k], v, Object.assign(Object.assign({}, options), { currentPath }));
}
}
const keys = Object.keys(target);
for (let k of keys) {
if (!(k in source)) {
if (Array.isArray(target))
target.splice(k, 1);
else
delete target[k];
}
}
}
function normalizeFilter(spec, obj) {
if (typeof spec == 'function')
return spec;
if (typeof spec == 'string')
spec = [spec];
const pathset = buildPathSets(obj, spec);
return (path, obj) => pathset.has(path);
}
function buildPathSets(obj, paths) {
const pathSet = new Set();
for (let path of paths || []) {
const js_paths = JSONPath.paths(obj, path);
for (let jsp of js_paths) {
pathSet.add(JSONPath.stringify(jsp));
}
}
return pathSet;
}
//# sourceMappingURL=sync_observable.js.map
{
"name": "@matchlighter/common_library",
"version": "1.2.4",
"version": "1.2.5",
"description": "Shared Functions, Helpers, Patterns & Utilities for Apps and Libraries",

@@ -26,7 +26,6 @@ "author": "Matchlighter",

"test": "jest",
"build": "node ./scripts/clean_build.js && tsc",
"build": "node ./scripts/build.js",
"prepublishOnly": "npm run-script build"
},
"peerDependencies": {
"jsonpath": "^1.0.2",
"mobx": "^5.13.0",

@@ -39,2 +38,3 @@ "mobx-react": "^6.1.3",

"classnames": "^2.2.6",
"jsonpath": "^1.0.2",
"underscore": "^1.9.1"

@@ -48,3 +48,3 @@ },

"@types/jsonpath": "^0.2.0",
"@types/node": "^13.7.0",
"@types/node": "^13.7.4",
"@types/react": "^16.9.2",

@@ -54,3 +54,2 @@ "babel-plugin-macros": "^2.8.0",

"jest": "^24.9.0",
"jsonpath": "^1.0.2",
"mobx": "^5.13.0",

@@ -57,0 +56,0 @@ "mobx-react": "^6.1.3",

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

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