Browse Source

Update dependencies

develop
Alex Mikhalev 6 years ago
parent
commit
9b959ff57b
  1. 2
      common/TypedEventEmitter.ts
  2. 2
      common/browserLogger.ts
  3. 35
      common/sprinklersRpc/schema/common.ts
  4. 38
      common/sprinklersRpc/schema/list.ts
  5. 4
      common/sprinklersRpc/schema/requests.ts
  6. 6
      package.json
  7. 3813
      yarn.lock

2
common/TypedEventEmitter.ts

@ -72,7 +72,7 @@ export function typedEventEmitter<
const NewClass = class extends Base { const NewClass = class extends Base {
constructor(...args: any[]) { constructor(...args: any[]) {
super(...args); super(...args);
EventEmitter.call(this); EventEmitter.call(this as any);
} }
}; };
Object.getOwnPropertyNames(EventEmitter.prototype).forEach(name => { Object.getOwnPropertyNames(EventEmitter.prototype).forEach(name => {

2
common/browserLogger.ts

@ -79,7 +79,7 @@ export function write(value: any) {
} else { } else {
fn = console.log; fn = console.log;
} }
fn.apply(null, args); fn.apply(null, args as any);
} }
function filter(value: any) { function filter(value: any) {

35
common/sprinklersRpc/schema/common.ts

@ -1,28 +1,29 @@
import { ModelSchema, primitive, PropSchema } from "serializr"; import {Context, custom, ModelSchema, primitive, PropSchema} from 'serializr';
import * as s from "..";
import * as s from '..';
export const duration: PropSchema = primitive(); export const duration: PropSchema = primitive();
export const date: PropSchema = { export const date: PropSchema = custom(
serializer: (jsDate: Date | null) => (jsDate: Date|null) => jsDate != null ? jsDate.toISOString() : null,
jsDate != null ? jsDate.toISOString() : null, (json: any, context: Context, oldValue: any,
deserializer: (json: any, done) => { done: (err: any, value: any) => void) => {
if (json === null) { if (json === null) {
return done(null, null); return done(null, null);
} }
try { try {
done(null, new Date(json)); done(null, new Date(json));
} catch (e) { } catch (e) {
done(e, undefined); done(e, undefined);
} }
} });
};
export const dateOfYear: ModelSchema<s.DateOfYear> = { export const dateOfYear: ModelSchema<s.DateOfYear> = {
factory: () => new s.DateOfYear(), factory: () => new s.DateOfYear(),
props: { props: {
year: primitive(), year: primitive(),
month: primitive(), // this only works if it is represented as a # from 0-12 month:
primitive(), // this only works if it is represented as a # from 0-12
day: primitive() day: primitive()
} }
}; };

38
common/sprinklersRpc/schema/list.ts

@ -1,8 +1,8 @@
import { primitive, PropSchema } from "serializr"; import {primitive, PropSchema} from 'serializr';
function invariant(cond: boolean, message?: string) { function invariant(cond: boolean, message?: string) {
if (!cond) { if (!cond) {
throw new Error("[serializr] " + (message || "Illegal ServerState")); throw new Error('[serializr] ' + (message || 'Illegal ServerState'));
} }
} }
@ -11,14 +11,11 @@ function isPropSchema(thing: any) {
} }
function isAliasedPropSchema(propSchema: any) { function isAliasedPropSchema(propSchema: any) {
return typeof propSchema === "object" && !!propSchema.jsonname; return typeof propSchema === 'object' && !!propSchema.jsonname;
} }
function parallel( function parallel(
ar: any[], ar: any[], processor: (item: any, done: any) => void, cb: any) {
processor: (item: any, done: any) => void,
cb: any
) {
if (ar.length === 0) { if (ar.length === 0) {
return void cb(null, []); return void cb(null, []);
} }
@ -43,17 +40,15 @@ function parallel(
export default function list(propSchema: PropSchema): PropSchema { export default function list(propSchema: PropSchema): PropSchema {
propSchema = propSchema || primitive(); propSchema = propSchema || primitive();
invariant(isPropSchema(propSchema), "expected prop schema as first argument"); invariant(isPropSchema(propSchema), 'expected prop schema as first argument');
invariant( invariant(
!isAliasedPropSchema(propSchema), !isAliasedPropSchema(propSchema),
"provided prop is aliased, please put aliases first" 'provided prop is aliased, please put aliases first');
);
return { return {
serializer(ar) { serializer(ar) {
invariant( invariant(
ar && typeof ar.length === "number" && typeof ar.map === "function", ar && typeof ar.length === 'number' && typeof ar.map === 'function',
"expected array (like) object" 'expected array (like) object');
);
return ar.map(propSchema.serializer); return ar.map(propSchema.serializer);
}, },
deserializer(jsonArray, done, context) { deserializer(jsonArray, done, context) {
@ -62,14 +57,15 @@ export default function list(propSchema: PropSchema): PropSchema {
return void done(null, []); return void done(null, []);
} }
if (!Array.isArray(jsonArray)) { if (!Array.isArray(jsonArray)) {
return void done("[serializr] expected JSON array", null); return void done('[serializr] expected JSON array', null);
} }
parallel( parallel(
jsonArray, jsonArray,
(item: any, itemDone: (err: any, targetPropertyValue: any) => void) => (item: any, itemDone: (err: any, targetPropertyValue: any) => void) =>
propSchema.deserializer(item, itemDone, context, undefined), propSchema.deserializer(item, itemDone, context, undefined),
done done);
); },
} beforeDeserialize: () => {},
afterDeserialize: () => {},
}; };
} }

4
common/sprinklersRpc/schema/requests.ts

@ -35,7 +35,9 @@ export const updateProgram: ModelSchema<
serializer: data => data, serializer: data => data,
deserializer: (json, done) => { deserializer: (json, done) => {
done(null, json); done(null, json);
} },
beforeDeserialize: () => {},
afterDeserialize: () => {},
} }
}); });

6
package.json

@ -148,11 +148,5 @@
"webpack-cli": "^3.1.0", "webpack-cli": "^3.1.0",
"webpack-dashboard": "^2.0.0", "webpack-dashboard": "^2.0.0",
"webpack-dev-server": "^3.1.7" "webpack-dev-server": "^3.1.7"
},
"resolutions": {
"**/@types/react": "16.7.13",
"**/@types/react-dom": "16.0.11",
"**/react": "16.6.3",
"**/react-dom": "16.6.3"
} }
} }

3813
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save