@shopify/cli-kit 3.30.1 → 3.30.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.
- package/dist/api/partners.js +5 -0
- package/dist/api/partners.js.map +1 -1
- package/dist/content-tokens.js +3 -1
- package/dist/content-tokens.js.map +1 -1
- package/dist/http/fetch.js +4 -0
- package/dist/http/fetch.js.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/private/common/lodash.d.ts +47 -0
- package/dist/private/common/lodash.js +2 -0
- package/dist/private/common/lodash.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.js +3 -1
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/Table.js +1 -1
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/public/common/array.d.ts +20 -0
- package/dist/public/common/array.js +27 -0
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.d.ts +23 -0
- package/dist/public/common/collection.js +29 -0
- package/dist/public/common/collection.js.map +1 -0
- package/dist/public/common/function.d.ts +30 -0
- package/dist/public/common/function.js +40 -0
- package/dist/public/common/function.js.map +1 -0
- package/dist/public/common/lang.d.ts +16 -0
- package/dist/public/common/lang.js +22 -0
- package/dist/public/common/lang.js.map +1 -0
- package/dist/public/common/object.d.ts +22 -0
- package/dist/public/common/object.js +28 -0
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/node/base-command.d.ts +1 -0
- package/dist/public/node/base-command.js +13 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/api/partners.js
CHANGED
|
@@ -2,6 +2,8 @@ import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
|
|
|
2
2
|
import { ScriptServiceProxyQuery } from './graphql/index.js';
|
|
3
3
|
import { partners as partnersFqdn } from '../environment/fqdn.js';
|
|
4
4
|
import { graphqlClient } from '../http/graphql.js';
|
|
5
|
+
import { debug } from '../output.js';
|
|
6
|
+
import { performance } from 'perf_hooks';
|
|
5
7
|
export async function request(query, token, variables) {
|
|
6
8
|
const api = 'Partners';
|
|
7
9
|
return handlingErrors(api, async () => {
|
|
@@ -10,7 +12,10 @@ export async function request(query, token, variables) {
|
|
|
10
12
|
const headers = await buildHeaders(token);
|
|
11
13
|
debugLogRequest(api, query, variables, headers);
|
|
12
14
|
const client = await graphqlClient({ headers, url });
|
|
15
|
+
const t0 = performance.now();
|
|
13
16
|
const response = await client.request(query, variables);
|
|
17
|
+
const t1 = performance.now();
|
|
18
|
+
debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`);
|
|
14
19
|
return response;
|
|
15
20
|
});
|
|
16
21
|
}
|
package/dist/api/partners.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAElC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CA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C,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {debug} from '../output.js'\nimport {Variables, RequestDocument} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const t0 = performance.now()\n const response = await client.request<T>(query, variables)\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`)\n return response\n })\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
|
package/dist/content-tokens.js
CHANGED
|
@@ -19,7 +19,9 @@ export class LinkContentToken extends ContentToken {
|
|
|
19
19
|
this.link = link;
|
|
20
20
|
}
|
|
21
21
|
output() {
|
|
22
|
-
|
|
22
|
+
const text = colors.green(stringifyMessage(this.value));
|
|
23
|
+
const url = this.link ?? '';
|
|
24
|
+
return terminalLink(text, url, { fallback: () => `${text} ( ${url} )` });
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
export class CommandContentToken extends ContentToken {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../src/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,cAAc,EAAC,MAAM,WAAW,CAAA;AACtD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EAAU,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,GAAG,MAAM,YAAY,CAAA;AAG5B,MAAM,OAAgB,YAAY;IAGhC,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CAGF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAoB;IACvD,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAAqB;IAGzD,YAAY,KAAc,EAAE,IAAY;QACtC,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM;QACJ,
|
|
1
|
+
{"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../src/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,cAAc,EAAC,MAAM,WAAW,CAAA;AACtD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EAAU,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,GAAG,MAAM,YAAY,CAAA;AAG5B,M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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAAqB;IACzD,MAAM;QACJ,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAAqB;IAC5D,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAAqB;IAC/D,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAqB;IAC3D,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import {relativize as relativizePath} from './path.js'\nimport colors from './public/node/colors.js'\nimport {Message, stringifyMessage} from './output.js'\nimport terminalLink from 'terminal-link'\nimport cjs from 'color-json'\nimport type {Change} from 'diff'\n\nexport abstract class ContentToken<T> {\n value: T\n\n constructor(value: T) {\n this.value = value\n }\n\n abstract output(): string | string[]\n}\n\nexport class RawContentToken extends ContentToken<string> {\n output(): string {\n return this.value\n }\n}\n\nexport class LinkContentToken extends ContentToken<Message> {\n link: string\n\n constructor(value: Message, link: string) {\n super(value)\n this.link = link\n }\n\n output() {\n const text = colors.green(stringifyMessage(this.value))\n const url = this.link ?? ''\n return terminalLink(text, url, {fallback: () => `${text} ( ${url} )`})\n }\n}\n\nexport class CommandContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold(colors.yellow(stringifyMessage(this.value)))\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class JsonContentToken extends ContentToken<any> {\n output(): string {\n try {\n return cjs(stringifyMessage(this.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2)\n }\n }\n}\n\nexport class LinesDiffContentToken extends ContentToken<Change[]> {\n output(): string[] {\n return this.value\n .map((part) => {\n if (part.added) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.green(`+ ${line}\\n`)\n })\n } else if (part.removed) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.magenta(`- ${line}\\n`)\n })\n } else {\n return part.value\n }\n })\n .flat()\n }\n}\n\nexport class ColorContentToken extends ContentToken<Message> {\n color: (text: string) => string\n\n constructor(value: Message, color: (text: string) => string) {\n super(value)\n this.color = color\n }\n\n output(): string {\n return this.color(stringifyMessage(this.value))\n }\n}\n\nexport class ErrorContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<Message> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<Message> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
|
package/dist/http/fetch.js
CHANGED
|
@@ -2,6 +2,7 @@ import { httpsAgent } from '../http.js';
|
|
|
2
2
|
import { buildHeaders, sanitizedHeadersOutput } from '../api/common.js';
|
|
3
3
|
import { content, debug } from '../output.js';
|
|
4
4
|
import nodeFetch from 'node-fetch';
|
|
5
|
+
import { performance } from 'perf_hooks';
|
|
5
6
|
/**
|
|
6
7
|
* An interface that abstracts way node-fetch. When Node has built-in
|
|
7
8
|
* support for "fetch" in the standard library, we can drop the node-fetch
|
|
@@ -34,7 +35,10 @@ export async function shopifyFetch(url, init) {
|
|
|
34
35
|
Sending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:
|
|
35
36
|
${sanitizedHeadersOutput((options?.headers ?? {}))}
|
|
36
37
|
`);
|
|
38
|
+
const t0 = performance.now();
|
|
37
39
|
const response = await nodeFetch(url, { ...init, agent: await httpsAgent() });
|
|
40
|
+
const t1 = performance.now();
|
|
41
|
+
debug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`);
|
|
38
42
|
return response;
|
|
39
43
|
}
|
|
40
44
|
//# sourceMappingURL=fetch.js.map
|
package/dist/http/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAItC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAAM,OAAO,GAAgB;QAC3B,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,YAAY,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;SACzB;KACF,CAAA;IAED,KAAK,CAAC,OAAO,CAAA;UACL,OAAO,CAAC,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE;EAChE,sBAAsB,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAA+B,CAAC;CAC/E,CAAC,CAAA;IACA,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,CAAA;IAC3E,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,KAAK,CAAC,cAAc,GAAG,CAAC,QAAQ,EAAE,0BAA0B,QAAQ,CAAC,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IAC3G,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport {buildHeaders, sanitizedHeadersOutput} from '../api/common.js'\nimport {content, debug} from '../output.js'\nimport nodeFetch from 'node-fetch'\nimport {performance} from 'perf_hooks'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n debug(content`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n"]}
|
package/dist/output.js
CHANGED
|
@@ -219,7 +219,7 @@ export const debug = (content, logger = consoleLog) => {
|
|
|
219
219
|
if (isUnitTest())
|
|
220
220
|
collectLog('debug', content);
|
|
221
221
|
const message = colors.gray(stringifyMessage(content));
|
|
222
|
-
outputWhereAppropriate('debug', logger, message);
|
|
222
|
+
outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`);
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
225
225
|
* Outputs a warning message to the user.
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;A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AAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, message)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AA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AC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsD,EACtD,OAAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare type PartialShallow<T> = {
|
|
2
|
+
[P in keyof T]?: T[P] extends object ? object : T[P];
|
|
3
|
+
};
|
|
4
|
+
export declare type PropertyName = string | number | symbol;
|
|
5
|
+
export declare type IterateeShorthand<T> = PropertyName | [PropertyName, unknown] | PartialShallow<T>;
|
|
6
|
+
export declare type ValueIteratee<T> = ((value: T) => unknown) | IterateeShorthand<T>;
|
|
7
|
+
export interface Dictionary<T> {
|
|
8
|
+
[index: string]: T;
|
|
9
|
+
}
|
|
10
|
+
export interface DebounceSettings {
|
|
11
|
+
/**
|
|
12
|
+
* @see _.leading
|
|
13
|
+
*/
|
|
14
|
+
leading?: boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @see _.maxWait
|
|
17
|
+
*/
|
|
18
|
+
maxWait?: number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @see _.trailing
|
|
21
|
+
*/
|
|
22
|
+
trailing?: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface DebouncedFunc<T extends (...args: unknown[]) => unknown> {
|
|
25
|
+
/**
|
|
26
|
+
* Call the original function, but applying the debounce rules.
|
|
27
|
+
*
|
|
28
|
+
* If the debounced function can be run immediately, this calls it and returns its return
|
|
29
|
+
* value.
|
|
30
|
+
*
|
|
31
|
+
* Otherwise, it returns the return value of the last invocation, or undefined if the debounced
|
|
32
|
+
* function was not invoked yet.
|
|
33
|
+
*/
|
|
34
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Throw away any pending invocation of the debounced function.
|
|
37
|
+
*/
|
|
38
|
+
cancel(): void;
|
|
39
|
+
/**
|
|
40
|
+
* If there is a pending invocation of the debounced function, invoke it immediately and return
|
|
41
|
+
* its return value.
|
|
42
|
+
*
|
|
43
|
+
* Otherwise, return the value from the last invocation, or undefined if the debounced function
|
|
44
|
+
* was never invoked.
|
|
45
|
+
*/
|
|
46
|
+
flush(): ReturnType<T> | undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lodash.js","sourceRoot":"","sources":["../../../src/private/common/lodash.ts"],"names":[],"mappings":"","sourcesContent":["export type PartialShallow<T> = {\n [P in keyof T]?: T[P] extends object ? object : T[P]\n}\nexport type PropertyName = string | number | symbol\nexport type IterateeShorthand<T> = PropertyName | [PropertyName, unknown] | PartialShallow<T>\nexport type ValueIteratee<T> = ((value: T) => unknown) | IterateeShorthand<T>\nexport interface Dictionary<T> {\n [index: string]: T\n}\n\nexport interface DebounceSettings {\n /**\n * @see _.leading\n */\n leading?: boolean | undefined\n /**\n * @see _.maxWait\n */\n maxWait?: number | undefined\n /**\n * @see _.trailing\n */\n trailing?: boolean | undefined\n}\n\nexport interface DebouncedFunc<T extends (...args: unknown[]) => unknown> {\n /**\n * Call the original function, but applying the debounce rules.\n *\n * If the debounced function can be run immediately, this calls it and returns its return\n * value.\n *\n * Otherwise, it returns the return value of the last invocation, or undefined if the debounced\n * function was not invoked yet.\n */\n (...args: Parameters<T>): ReturnType<T> | undefined\n\n /**\n * Throw away any pending invocation of the debounced function.\n */\n cancel(): void\n\n /**\n * If there is a pending invocation of the debounced function, invoke it immediately and return\n * its return value.\n *\n * Otherwise, return the value from the last invocation, or undefined if the debounced function\n * was never invoked.\n */\n flush(): ReturnType<T> | undefined\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isTruthy } from '../../../../environment/utilities.js';
|
|
2
|
+
import { isEqual } from '../../../../public/common/lang.js';
|
|
3
|
+
import { groupBy } from '../../../../public/common/collection.js';
|
|
4
|
+
import { mapValues } from '../../../../public/common/object.js';
|
|
2
5
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
6
|
import { Box, Text, useApp, useInput } from 'ink';
|
|
4
|
-
import { groupBy, isEqual, mapValues } from 'lodash-es';
|
|
5
7
|
function groupItems(items) {
|
|
6
8
|
let index = 0;
|
|
7
9
|
return mapValues(groupBy(items, 'group'), (groupItems) => groupItems.map((groupItem) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/SelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/SelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAA;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,yCAAyC,CAAA;AAC/D,OAAO,EAAC,SAAS,EAAC,MAAM,qCAAqC,CAAA;AAC7D,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,OAAO,CAAA;AACrE,OAAO,EAAC,GAAG,EAAO,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,KAAK,CAAA;AAcpD,SAAS,UAAU,CAAI,KAAgB;IACrC,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CACvD,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,IAAI,GAAG,EAAC,GAAG,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAC,CAAA;QAChF,KAAK,IAAI,CAAC,CAAA;QACV,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAI,EAAC,KAAK,EAAE,QAAQ,EAAoC;IACzF,MAAM,CA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AAC,KAAK,KAAK,aAAa,CAAA;oBAE/C,OAAO,CACL,oBAAC,GAAG,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG;wBAChB,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC,IAAG,UAAU,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,GAAG,CAAQ,CAAC,CAAC,CAAC,oBAAC,IAAI,YAAS,CAAO;wBAE1F,oBAAC,IAAI,IAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAG,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,EAAE,CAAQ,CAChF,CACP,CAAA;gBACH,CAAC,CAAC,CACE,CACP,CAAA;QACH,CAAC,CAAC;QAEF,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;YAC9B,oBAAC,IAAI,IAAC,QAAQ,kDAA6C,CACvD,CACF,CACP,CAAA;AACH,CAAC","sourcesContent":["import {isTruthy} from '../../../../environment/utilities.js'\nimport {isEqual} from '../../../../public/common/lang.js'\nimport {groupBy} from '../../../../public/common/collection.js'\nimport {mapValues} from '../../../../public/common/object.js'\nimport React, {useState, useEffect, useRef, useCallback} from 'react'\nimport {Box, Key, Text, useApp, useInput} from 'ink'\n\nexport interface Props<T> {\n items: Item<T>[]\n onSelect: (value: T) => void\n}\n\nexport interface Item<T> {\n label: string\n value: T\n key?: string\n group?: string\n}\n\nfunction groupItems<T>(items: Item<T>[]) {\n let index = 0\n\n return mapValues(groupBy(items, 'group'), (groupItems) =>\n groupItems.map((groupItem) => {\n const item = {...groupItem, key: groupItem.key ?? (index + 1).toString(), index}\n index += 1\n return item\n }),\n )\n}\n\nexport default function SelectInput<T>({items, onSelect}: React.PropsWithChildren<Props<T>>): JSX.Element | null {\n const [inputStack, setInputStack] = useState<string | null>(null)\n const [inputTimeout, setInputTimeout] = useState<NodeJS.Timeout | null>(null)\n const [selectedIndex, setSelectedIndex] = useState(0)\n const keys = useRef(new Set(items.map((item) => item.key)))\n const {exit: unmountInk} = useApp()\n const groupedItems = groupItems(items)\n const groupTitles = Object.keys(groupedItems)\n\n const previousItems = useRef<Item<T>[]>(items)\n\n // reset index when items change\n useEffect(() => {\n if (\n !isEqual(\n previousItems.current.map((item) => item.value),\n items.map((item) => item.value),\n )\n ) {\n setSelectedIndex(0)\n }\n\n previousItems.current = items\n }, [items])\n\n const handleInput = useCallback(\n (input: string, key: Key) => {\n if (input === 'c' && key.ctrl) {\n // Exceptions being throw in these hooks aren't being caught by our errorHandler.\n // See also how we handle exceptions in CouncurrentOutput for reference.\n process.exit(1)\n }\n\n const parsedInput = parseInt(input, 10)\n\n if (parsedInput !== 0 && parsedInput <= items.length + 1) {\n setSelectedIndex(parsedInput - 1)\n } else if (keys.current.has(input)) {\n const index = items.findIndex((item) => item.key === input)\n if (index !== -1) {\n setSelectedIndex(index)\n }\n }\n\n if (key.upArrow) {\n const lastIndex = items.length - 1\n\n setSelectedIndex(selectedIndex === 0 ? lastIndex : selectedIndex - 1)\n } else if (key.downArrow) {\n setSelectedIndex(selectedIndex === items.length - 1 ? 0 : selectedIndex + 1)\n } else if (key.return) {\n onSelect(items[selectedIndex]!.value)\n // This is a workaround needed because Ink behaves differently in CI when\n // unmounting. See https://github.com/vadimdemedes/ink/pull/266\n if (!isTruthy(process.env.CI)) unmountInk()\n }\n },\n [selectedIndex, items, onSelect],\n )\n\n useInput((input, key) => {\n if (input.length > 0 && Object.values(key).every((value) => value === false)) {\n const newInputStack = inputStack === null ? input : inputStack + input\n\n setInputStack(newInputStack)\n\n if (inputTimeout !== null) {\n clearTimeout(inputTimeout)\n }\n\n setInputTimeout(\n setTimeout(() => {\n handleInput(newInputStack, key)\n setInputStack(null)\n setInputTimeout(null)\n }, 300),\n )\n } else {\n handleInput(input, key)\n }\n })\n\n return (\n <Box flexDirection=\"column\">\n {groupTitles.map((title) => {\n const hasTitle = title !== 'undefined'\n\n return (\n <Box key={title} flexDirection=\"column\" marginTop={hasTitle ? 1 : 0}>\n {hasTitle && (\n <Box marginLeft={3}>\n <Text bold>{title}</Text>\n </Box>\n )}\n {groupedItems[title]!.map((item) => {\n const isSelected = item.index === selectedIndex\n\n return (\n <Box key={item.key}>\n <Box marginRight={2}>{isSelected ? <Text color=\"cyan\">{`>`}</Text> : <Text> </Text>}</Box>\n\n <Text color={isSelected ? 'cyan' : undefined}>{`(${item.key}) ${item.label}`}</Text>\n </Box>\n )\n })}\n </Box>\n )\n })}\n\n <Box marginTop={1} marginLeft={3}>\n <Text dimColor>navigate with arrows, enter to select</Text>\n </Box>\n </Box>\n )\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { List } from './List.js';
|
|
2
|
+
import { capitalize } from '../../../../string.js';
|
|
2
3
|
import { Box, Text } from 'ink';
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import { capitalize } from 'lodash-es';
|
|
5
5
|
const Table = ({ table }) => {
|
|
6
6
|
const headers = Object.keys(table);
|
|
7
7
|
const headerColumnWidth = Math.max(...headers.map((header) => header.length));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,KAAK,GAAoB,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAE7E,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,IACpC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC9B,oBAAC,GAAG,IAAC,GAAG,EAAE,KAAK;QACb,oBAAC,GAAG,IAAC,KAAK,EAAE,iBAAiB,GAAG,CAAC;YAC/B,oBAAC,IAAI;gBAAE,UAAU,CAAC,MAAM,CAAC;oBAAS,CAC9B;QACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;YACd,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAE,GAAI,CAC3B,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import {List} from './List.js'\nimport {capitalize} from '../../../../string.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport interface Props {\n table: {\n [header: string]: string[]\n }\n}\n\nconst Table: React.FC<Props> = ({table}) => {\n const headers = Object.keys(table)\n const headerColumnWidth = Math.max(...headers.map((header) => header.length))\n\n return (\n <Box flexDirection=\"column\" paddingY={1}>\n {headers.map((header, index) => (\n <Box key={index}>\n <Box width={headerColumnWidth + 1}>\n <Text>{capitalize(header)}:</Text>\n </Box>\n <Box flexGrow={1}>\n <List items={table[header]!} />\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport default Table\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { List, ValueIteratee } from 'lodash';
|
|
1
2
|
/**
|
|
2
3
|
* Takes a random value from an array.
|
|
3
4
|
* @param array - Array from which we'll select a random item.
|
|
@@ -15,3 +16,22 @@ export declare function getArrayRejectingUndefined<T>(array: (T | undefined)[]):
|
|
|
15
16
|
* @returns True if the array contains duplicates.
|
|
16
17
|
*/
|
|
17
18
|
export declare function getArrayContainsDuplicates<T>(array: T[]): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* This method is like `_.uniq` except that it accepts `iteratee` which is
|
|
21
|
+
* invoked for each element in `array` to generate the criterion by which
|
|
22
|
+
* uniqueness is computed. The iteratee is invoked with one argument: (value).
|
|
23
|
+
*
|
|
24
|
+
* @param array - The array to inspect.
|
|
25
|
+
* @param iteratee - The iteratee invoked per element.
|
|
26
|
+
* @returns Returns the new duplicate free array.
|
|
27
|
+
*/
|
|
28
|
+
export declare function uniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates an array of `array` values not included in the other provided arrays using SameValueZero for
|
|
31
|
+
* equality comparisons. The order and references of result values are determined by the first array.
|
|
32
|
+
*
|
|
33
|
+
* @param array - The array to inspect.
|
|
34
|
+
* @param values - The arrays of values to exclude.
|
|
35
|
+
* @returns Returns the new array of filtered values.
|
|
36
|
+
*/
|
|
37
|
+
export declare function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
1
3
|
/**
|
|
2
4
|
* Takes a random value from an array.
|
|
3
5
|
* @param array - Array from which we'll select a random item.
|
|
@@ -21,4 +23,29 @@ export function getArrayRejectingUndefined(array) {
|
|
|
21
23
|
export function getArrayContainsDuplicates(array) {
|
|
22
24
|
return array.length !== new Set(array).size;
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* This method is like `_.uniq` except that it accepts `iteratee` which is
|
|
28
|
+
* invoked for each element in `array` to generate the criterion by which
|
|
29
|
+
* uniqueness is computed. The iteratee is invoked with one argument: (value).
|
|
30
|
+
*
|
|
31
|
+
* @param array - The array to inspect.
|
|
32
|
+
* @param iteratee - The iteratee invoked per element.
|
|
33
|
+
* @returns Returns the new duplicate free array.
|
|
34
|
+
*/
|
|
35
|
+
export function uniqBy(array, iteratee) {
|
|
36
|
+
const lodashUniqBy = require('lodash/uniqBy');
|
|
37
|
+
return lodashUniqBy(array, iteratee);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an array of `array` values not included in the other provided arrays using SameValueZero for
|
|
41
|
+
* equality comparisons. The order and references of result values are determined by the first array.
|
|
42
|
+
*
|
|
43
|
+
* @param array - The array to inspect.
|
|
44
|
+
* @param values - The arrays of values to exclude.
|
|
45
|
+
* @returns Returns the new array of filtered values.
|
|
46
|
+
*/
|
|
47
|
+
export function difference(array, ...values) {
|
|
48
|
+
const lodashDifference = require('lodash/difference');
|
|
49
|
+
return lodashDifference(array, ...values);
|
|
50
|
+
}
|
|
24
51
|
//# sourceMappingURL=array.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC","sourcesContent":["/**\n * Takes a random value from an array.\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n"]}
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAGzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAI,KAAiC,EAAE,QAA0B;IACrF,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAI,KAAiC,EAAE,GAAG,MAAiB;IACnF,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrD,OAAO,gBAAgB,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import {createRequire} from 'node:module'\nimport type {List, ValueIteratee} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Takes a random value from an array.\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n\n/**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The iteratee is invoked with one argument: (value).\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\nexport function uniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[] {\n const lodashUniqBy = require('lodash/uniqBy')\n return lodashUniqBy(array, iteratee)\n}\n\n/**\n * Creates an array of `array` values not included in the other provided arrays using SameValueZero for\n * equality comparisons. The order and references of result values are determined by the first array.\n *\n * @param array - The array to inspect.\n * @param values - The arrays of values to exclude.\n * @returns Returns the new array of filtered values.\n */\nexport function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[] {\n const lodashDifference = require('lodash/difference')\n return lodashDifference(array, ...values)\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { List, ValueIteratee } from 'lodash';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an object composed of keys generated from the results of running each element of collection through
|
|
4
|
+
* iteratee. The corresponding value of each key is an array of the elements responsible for generating the
|
|
5
|
+
* key. The iteratee is invoked with one argument: (value).
|
|
6
|
+
*
|
|
7
|
+
* @param collection - The collection to iterate over.
|
|
8
|
+
* @param iteratee - The function invoked per iteration.
|
|
9
|
+
* @returns Returns the composed aggregate object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function groupBy<T>(collection: ArrayLike<T> | null | undefined, iteratee?: ValueIteratee<T>): {
|
|
12
|
+
[index: string]: T[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for,
|
|
16
|
+
* while the second of which contains elements predicate returns falsey for.
|
|
17
|
+
* The predicate is invoked with three arguments: (value, index|key, collection).
|
|
18
|
+
*
|
|
19
|
+
* @param collection - The collection to iterate over.
|
|
20
|
+
* @param callback - The function called per iteration.
|
|
21
|
+
* @returns Returns the array of grouped elements.
|
|
22
|
+
*/
|
|
23
|
+
export declare function partition<T>(collection: List<T> | null | undefined, callback: ValueIteratee<T>): [T[], T[]];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* Creates an object composed of keys generated from the results of running each element of collection through
|
|
5
|
+
* iteratee. The corresponding value of each key is an array of the elements responsible for generating the
|
|
6
|
+
* key. The iteratee is invoked with one argument: (value).
|
|
7
|
+
*
|
|
8
|
+
* @param collection - The collection to iterate over.
|
|
9
|
+
* @param iteratee - The function invoked per iteration.
|
|
10
|
+
* @returns Returns the composed aggregate object.
|
|
11
|
+
*/
|
|
12
|
+
export function groupBy(collection, iteratee) {
|
|
13
|
+
const lodashBroupBy = require('lodash/groupBy');
|
|
14
|
+
return lodashBroupBy(collection, iteratee);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for,
|
|
18
|
+
* while the second of which contains elements predicate returns falsey for.
|
|
19
|
+
* The predicate is invoked with three arguments: (value, index|key, collection).
|
|
20
|
+
*
|
|
21
|
+
* @param collection - The collection to iterate over.
|
|
22
|
+
* @param callback - The function called per iteration.
|
|
23
|
+
* @returns Returns the array of grouped elements.
|
|
24
|
+
*/
|
|
25
|
+
export function partition(collection, callback) {
|
|
26
|
+
const lodashPartition = require('lodash/partition');
|
|
27
|
+
return lodashPartition(collection, callback);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/public/common/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAGzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CACrB,UAA2C,EAC3C,QAA2B;IAI3B,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC/C,OAAO,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;GAQG;AAEH,MAAM,UAAU,SAAS,CAAI,UAAsC,EAAE,QAA0B;IAC7F,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACnD,OAAO,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import {createRequire} from 'node:module'\nimport type {List, ValueIteratee} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Creates an object composed of keys generated from the results of running each element of collection through\n * iteratee. The corresponding value of each key is an array of the elements responsible for generating the\n * key. The iteratee is invoked with one argument: (value).\n *\n * @param collection - The collection to iterate over.\n * @param iteratee - The function invoked per iteration.\n * @returns Returns the composed aggregate object.\n */\nexport function groupBy<T>(\n collection: ArrayLike<T> | null | undefined,\n iteratee?: ValueIteratee<T>,\n): {\n [index: string]: T[]\n} {\n const lodashBroupBy = require('lodash/groupBy')\n return lodashBroupBy(collection, iteratee)\n}\n\n/**\n * Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for,\n * while the second of which contains elements predicate returns falsey for.\n * The predicate is invoked with three arguments: (value, index|key, collection).\n *\n * @param collection - The collection to iterate over.\n * @param callback - The function called per iteration.\n * @returns Returns the array of grouped elements.\n */\n\nexport function partition<T>(collection: List<T> | null | undefined, callback: ValueIteratee<T>): [T[], T[]] {\n const lodashPartition = require('lodash/partition')\n return lodashPartition(collection, callback)\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DebouncedFunc, DebounceSettings } from 'lodash';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for
|
|
4
|
+
* storing the result based on the arguments provided to the memoized function. By default, the first argument
|
|
5
|
+
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
|
|
6
|
+
* the this binding of the memoized function.
|
|
7
|
+
*
|
|
8
|
+
* @param func - The function to have its output memoized.
|
|
9
|
+
* @param resolver - The function to resolve the cache key.
|
|
10
|
+
* @returns Returns the new memoizing function.
|
|
11
|
+
*/
|
|
12
|
+
export declare function memoize<T extends (...args: any) => any>(func: T, resolver?: (...args: Parameters<T>) => unknown): T;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since
|
|
15
|
+
* the last time the debounced function was invoked. The debounced function comes with a cancel method to
|
|
16
|
+
* cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to
|
|
17
|
+
* indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent
|
|
18
|
+
* calls to the debounced function return the result of the last func invocation.
|
|
19
|
+
*
|
|
20
|
+
* Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only
|
|
21
|
+
* if the the debounced function is invoked more than once during the wait timeout.
|
|
22
|
+
*
|
|
23
|
+
* See David Corbacho’s article for details over the differences between _.debounce and _.throttle.
|
|
24
|
+
*
|
|
25
|
+
* @param func - The function to debounce.
|
|
26
|
+
* @param wait - The number of milliseconds to delay.
|
|
27
|
+
* @param options - The options object.
|
|
28
|
+
* @returns Returns the new debounced function.
|
|
29
|
+
*/
|
|
30
|
+
export declare function debounce<T extends (...args: any) => any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFunc<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for
|
|
5
|
+
* storing the result based on the arguments provided to the memoized function. By default, the first argument
|
|
6
|
+
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
|
|
7
|
+
* the this binding of the memoized function.
|
|
8
|
+
*
|
|
9
|
+
* @param func - The function to have its output memoized.
|
|
10
|
+
* @param resolver - The function to resolve the cache key.
|
|
11
|
+
* @returns Returns the new memoizing function.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export function memoize(func, resolver) {
|
|
15
|
+
const memoize = require('lodash/memoize');
|
|
16
|
+
return memoize(func, resolver);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since
|
|
20
|
+
* the last time the debounced function was invoked. The debounced function comes with a cancel method to
|
|
21
|
+
* cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to
|
|
22
|
+
* indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent
|
|
23
|
+
* calls to the debounced function return the result of the last func invocation.
|
|
24
|
+
*
|
|
25
|
+
* Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only
|
|
26
|
+
* if the the debounced function is invoked more than once during the wait timeout.
|
|
27
|
+
*
|
|
28
|
+
* See David Corbacho’s article for details over the differences between _.debounce and _.throttle.
|
|
29
|
+
*
|
|
30
|
+
* @param func - The function to debounce.
|
|
31
|
+
* @param wait - The number of milliseconds to delay.
|
|
32
|
+
* @param options - The options object.
|
|
33
|
+
* @returns Returns the new debounced function.
|
|
34
|
+
*/
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
export function debounce(func, wait, options) {
|
|
37
|
+
const lodashDebounce = require('lodash/debounce');
|
|
38
|
+
return lodashDebounce(func, wait, options);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/public/common/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAGzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;;GASG;AACH,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAkC,IAAO,EAAE,QAA8C;IAC9G,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACzC,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,8DAA8D;AAC9D,MAAM,UAAU,QAAQ,CACtB,IAAO,EACP,IAAa,EACb,OAA0B;IAE1B,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACjD,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import {createRequire} from 'node:module'\nimport type {DebouncedFunc, DebounceSettings} from 'lodash'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for\n * storing the result based on the arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with\n * the this binding of the memoized function.\n *\n * @param func - The function to have its output memoized.\n * @param resolver - The function to resolve the cache key.\n * @returns Returns the new memoizing function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function memoize<T extends (...args: any) => any>(func: T, resolver?: (...args: Parameters<T>) => unknown): T {\n const memoize = require('lodash/memoize')\n return memoize(func, resolver)\n}\n\n/**\n * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since\n * the last time the debounced function was invoked. The debounced function comes with a cancel method to\n * cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to\n * indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent\n * calls to the debounced function return the result of the last func invocation.\n *\n * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only\n * if the the debounced function is invoked more than once during the wait timeout.\n *\n * See David Corbacho’s article for details over the differences between _.debounce and _.throttle.\n *\n * @param func - The function to debounce.\n * @param wait - The number of milliseconds to delay.\n * @param options - The options object.\n * @returns Returns the new debounced function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce<T extends (...args: any) => any>(\n func: T,\n wait?: number,\n options?: DebounceSettings,\n): DebouncedFunc<T> {\n const lodashDebounce = require('lodash/debounce')\n return lodashDebounce(func, wait, options)\n}\n"]}
|