@sketch-hq/sketch-assistant-utils
Advanced tools
Comparing version 2.0.2 to 2.0.3
# @sketch-hq/sketch-assistant-utils | ||
## 2.0.3 | ||
### Patch Changes | ||
- ba23962: Support Assistants exported as default exports from an ES Module | ||
## 2.0.2 | ||
@@ -4,0 +10,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { AssistantDefinition, Assistant, AssistantEnv, Maybe, RuleDefinition } from '../types'; | ||
import { AssistantDefinition, Assistant, AssistantEnv, Maybe, RuleDefinition, ESModuleInterop } from '../types'; | ||
declare const assign: (...sources: AssistantDefinition[]) => AssistantDefinition; | ||
declare const prepare: (source: import("../types").ValueOrArray<Assistant>, env: AssistantEnv) => Promise<AssistantDefinition>; | ||
declare const prepare: (source: import("../types").ValueOrArray<Assistant | ESModuleInterop<Assistant>>, env: AssistantEnv) => Promise<AssistantDefinition>; | ||
declare const getRuleDefinition: (assistant: AssistantDefinition, ruleName: string) => Maybe<RuleDefinition>; | ||
export { prepare, assign, getRuleDefinition }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -27,5 +27,14 @@ "use strict"; | ||
const prepare = (source, env) => __awaiter(void 0, void 0, void 0, function* () { | ||
const functions = Array.isArray(source) ? source.flat(Infinity) : [source]; | ||
const assistants = yield Promise.all(functions.map(f => f(env))); | ||
return assign(...assistants); | ||
const definitions = yield Promise.all((Array.isArray(source) ? source : [source]) | ||
.flat(Infinity) | ||
.map((item) => { | ||
if ('__esModule' in item) { | ||
return item.default; | ||
} | ||
else { | ||
return item; | ||
} | ||
}) | ||
.map(f => f(env))); | ||
return assign(...definitions); | ||
}); | ||
@@ -32,0 +41,0 @@ exports.prepare = prepare; |
@@ -92,3 +92,7 @@ import { FileFormat3 } from '@sketch-hq/sketch-file-format-ts'; | ||
export declare type Assistant = (env: AssistantEnv) => Promise<AssistantDefinition>; | ||
export declare type AssistantPackageExport = ValueOrArray<Assistant>; | ||
export declare type ESModuleInterop<DefaultExport> = { | ||
__esModule: true; | ||
default: DefaultExport; | ||
}; | ||
export declare type AssistantPackageExport = ValueOrArray<Assistant | ESModuleInterop<Assistant>>; | ||
export declare type AssistantDefinition = { | ||
@@ -95,0 +99,0 @@ rules: RuleDefinition[]; |
@@ -1,6 +0,6 @@ | ||
import { AssistantDefinition, Assistant, AssistantEnv, Maybe, RuleDefinition } from '../types'; | ||
import { AssistantDefinition, Assistant, AssistantEnv, Maybe, RuleDefinition, ESModuleInterop } from '../types'; | ||
declare const assign: (...sources: AssistantDefinition[]) => AssistantDefinition; | ||
declare const prepare: (source: import("../types").ValueOrArray<Assistant>, env: AssistantEnv) => Promise<AssistantDefinition>; | ||
declare const prepare: (source: import("../types").ValueOrArray<Assistant | ESModuleInterop<Assistant>>, env: AssistantEnv) => Promise<AssistantDefinition>; | ||
declare const getRuleDefinition: (assistant: AssistantDefinition, ruleName: string) => Maybe<RuleDefinition>; | ||
export { prepare, assign, getRuleDefinition }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -24,5 +24,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const prepare = (source, env) => __awaiter(void 0, void 0, void 0, function* () { | ||
const functions = Array.isArray(source) ? source.flat(Infinity) : [source]; | ||
const assistants = yield Promise.all(functions.map(f => f(env))); | ||
return assign(...assistants); | ||
const definitions = yield Promise.all((Array.isArray(source) ? source : [source]) | ||
.flat(Infinity) | ||
.map((item) => { | ||
if ('__esModule' in item) { | ||
return item.default; | ||
} | ||
else { | ||
return item; | ||
} | ||
}) | ||
.map(f => f(env))); | ||
return assign(...definitions); | ||
}); | ||
@@ -29,0 +38,0 @@ const getRuleDefinition = (assistant, ruleName) => assistant.rules.find(rule => rule.name === ruleName); |
@@ -92,3 +92,7 @@ import { FileFormat3 } from '@sketch-hq/sketch-file-format-ts'; | ||
export declare type Assistant = (env: AssistantEnv) => Promise<AssistantDefinition>; | ||
export declare type AssistantPackageExport = ValueOrArray<Assistant>; | ||
export declare type ESModuleInterop<DefaultExport> = { | ||
__esModule: true; | ||
default: DefaultExport; | ||
}; | ||
export declare type AssistantPackageExport = ValueOrArray<Assistant | ESModuleInterop<Assistant>>; | ||
export declare type AssistantDefinition = { | ||
@@ -95,0 +99,0 @@ rules: RuleDefinition[]; |
{ | ||
"name": "@sketch-hq/sketch-assistant-utils", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"module": "dist/esm/index", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index", |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171889
2075