@sleeperhq/mini-core 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ const os = require('os');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const isWindows = os.platform() === 'win32';
8
+
9
+ const printError = (error) => {
10
+ console.error("\n\033[91m" + error + "\033[0m");
11
+ };
12
+
13
+ const printInfo = (message) => {
14
+ console.log("\n\033[96m" + message + "\033[0m");
15
+ };
16
+
17
+ const printComplete = (message) => {
18
+ console.log("\033[92m" + message + "\033[0m");
19
+ };
20
+
21
+ const main = async () => {
22
+ // Load the package.json
23
+ const packageJsonPath = path.join('package.json');
24
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
25
+
26
+ // Get the dependencies
27
+ const dependencies = packageJson.dependencies;
28
+
29
+ // Write a ./package_list.js file that imports all dependencies
30
+ const packageListPath = path.join('package_list.js');
31
+ const packageList = Object.keys(dependencies).map(
32
+ (packageName) => `import '${packageName}';`
33
+ ).join('\n');
34
+
35
+ let output = `/*
36
+ This file is automatically generated when you
37
+ add a package to your package.json and run yarn.
38
+ Please do not edit manually.
39
+ */
40
+
41
+ ${packageList}
42
+ `;
43
+
44
+ fs.writeFileSync(packageListPath, output);
45
+ process.exit(0);
46
+ };
47
+
48
+ main();
@@ -53,7 +53,7 @@ export type RostersInLeagueMap = Record<LeagueId, RostersMap>;
53
53
  export type UserMap = Record<UserId, User>;
54
54
  export type MathchupWeekMap = Record<MatchupWeek, MatchupLeg>;
55
55
  export type MatchupsInLeagueMap = Record<LeagueId, MathchupWeekMap>;
56
- export type UsersInLeagueMap = Record<LeagueId, UserId[]>;
56
+ export type UsersInLeagueMap = Record<LeagueId, Record<UserId, User>>;
57
57
  export type PlayoffsInLeagueMap = Record<LeagueId, BracketSet>;
58
58
  export type TransactionsInLeagueMap = Record<LeagueId, TransactionId[]>;
59
59
  export type TransactionsMap = Record<TransactionId, LeagueTransaction>;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@sleeperhq/mini-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Core library frameworks for developing Sleeper Mini Apps.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
7
7
  "bin": {
8
- "build-mini": "./bin/build_mini.js"
8
+ "build-mini": "./bin/build_mini.js",
9
+ "preload-packages": "./bin/preload_packages.js"
9
10
  },
10
11
  "scripts": {
11
12
  "test": "jest",
@@ -8,7 +8,6 @@ import { fetchMainVersionMap, getMainUrl } from './url_resolver';
8
8
 
9
9
  let config: Config;
10
10
  const RETRY_TIMER = 5000;
11
- const LOGS_ENABLED = false;
12
11
 
13
12
  const DevServer = props => {
14
13
  const connection = useRef<TcpSocket.Socket>();
@@ -67,7 +66,7 @@ const DevServer = props => {
67
66
  // We have the full message
68
67
  partialMessage.current += msgString;
69
68
  msgString = '';
70
- if (LOGS_ENABLED) console.log("[Sleeper] Message built.", partialMessage.current.length);
69
+ if (config.logsEnabled) console.log("[Sleeper] Message built.", partialMessage.current.length);
71
70
 
72
71
  } else {
73
72
  // We have more than the full message
@@ -76,7 +75,7 @@ const DevServer = props => {
76
75
 
77
76
  if (remainingLength <= 0) {
78
77
  // We have less than the full message
79
- if (LOGS_ENABLED) console.log("[Sleeper] Building message: ", partialMessage.current.length, messageLength.current, remainingLength);
78
+ if (config.logsEnabled) console.log("[Sleeper] Building message: ", partialMessage.current.length, messageLength.current, remainingLength);
80
79
  return;
81
80
  }
82
81
  }
@@ -88,7 +87,7 @@ const DevServer = props => {
88
87
 
89
88
  // Set connection data
90
89
  if (json._platform || json._binaryVersion || json._dist || json._isStaging) {
91
- console.log("[Sleeper] Processing context data:", json._platform, json._binaryVersion, json._dist, json._isStaging);
90
+ if (config.logsEnabled) console.log("[Sleeper] Processing context data:", json._platform, json._binaryVersion, json._dist, json._isStaging);
92
91
  setData({
93
92
  platform: json._platform,
94
93
  binaryVersion: json._binaryVersion,
@@ -157,7 +156,7 @@ const DevServer = props => {
157
156
 
158
157
  // If the value is undefined, we need to request it from the server
159
158
  if (value === undefined && isLeaf) {
160
- console.log("[Sleeper] Requesting context value: ", fullPropertyPath);
159
+ if (config.logsEnabled) console.log("[Sleeper] Requesting context value: ", fullPropertyPath);
161
160
  sendContextRequest(socket, fullPropertyPath);
162
161
  }
163
162
 
@@ -279,7 +278,7 @@ const DevServer = props => {
279
278
  });
280
279
  const query = config.dev ? {platform: Platform.OS} : undefined;
281
280
 
282
- console.log('[Sleeper] load script:', scriptId, caller, url);
281
+ if (config.logsEnabled) console.log('[Sleeper] load script:', scriptId, caller, url);
283
282
  return {url, query};
284
283
  }
285
284
 
@@ -8,4 +8,5 @@ export type Config = {
8
8
  remoteIP: string,
9
9
  remoteSocketPort?: number,
10
10
  dev?: boolean,
11
+ logsEnabled?: boolean,
11
12
  };