@lit-labs/task
Advanced tools
Comparing version 1.1.2 to 1.1.3
import { ReactiveControllerHost } from '@lit/reactive-element/reactive-controller.js'; | ||
export declare type TaskFunction<D extends [...unknown[]], R = any> = (args: D) => R | typeof initialState | Promise<R | typeof initialState>; | ||
export declare type ArgsFunction<D extends [...unknown[]]> = () => D; | ||
export declare type TaskFunction<D extends ReadonlyArray<unknown>, R = any> = (args: D) => R | typeof initialState | Promise<R | typeof initialState>; | ||
export declare type ArgsFunction<D extends ReadonlyArray<unknown>> = () => D; | ||
export { ArgsFunction as DepsFunction }; | ||
@@ -26,3 +26,3 @@ /** | ||
}; | ||
export interface TaskConfig<T extends unknown[], R> { | ||
export interface TaskConfig<T extends ReadonlyArray<unknown>, R> { | ||
task: TaskFunction<T, R>; | ||
@@ -68,3 +68,3 @@ args?: ArgsFunction<T>; | ||
*/ | ||
export declare class Task<T extends [...unknown[]] = any, R = any> { | ||
export declare class Task<T extends ReadonlyArray<unknown> = ReadonlyArray<unknown>, R = unknown> { | ||
private _previousArgs?; | ||
@@ -71,0 +71,0 @@ private _task; |
@@ -72,3 +72,2 @@ /** | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export class Task { | ||
@@ -75,0 +74,0 @@ constructor(host, task, args) { |
122
package.json
{ | ||
"name": "@lit-labs/task", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A controller for Lit that renders asynchronous tasks.", | ||
@@ -21,2 +21,3 @@ "license": "BSD-3-Clause", | ||
".": { | ||
"types": "./development/index.d.ts", | ||
"development": "./development/index.js", | ||
@@ -26,2 +27,3 @@ "default": "./index.js" | ||
"./task.js": { | ||
"types": "./development/task.d.ts", | ||
"development": "./development/task.js", | ||
@@ -38,28 +40,102 @@ "default": "./task.js" | ||
"scripts": { | ||
"build": "npm run clean && npm run build:ts --build && rollup -c", | ||
"build:watch": "rollup -c --watch", | ||
"build:ts": "tsc --build && treemirror development . '**/*.d.ts{,.map}'", | ||
"build:ts:watch": "tsc --build --watch", | ||
"clean": "rm -rf {index,task}.{js,js.map,d.ts} development/ test/ *.tsbuildinfo", | ||
"dev": "scripts/dev.sh", | ||
"test": "npm run test:dev && npm run test:prod", | ||
"test:dev": "cd ../../tests && npx wtr '../labs/task/development/**/*_test.js'", | ||
"test:prod": "MODE=prod npm run test:dev", | ||
"test:watch": "npm run test:dev -- --watch", | ||
"checksize": "rollup -c --environment=CHECKSIZE", | ||
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install" | ||
"build": "wireit", | ||
"build:ts": "wireit", | ||
"build:ts:types": "wireit", | ||
"build:rollup": "wireit", | ||
"test": "wireit", | ||
"test:dev": "wireit", | ||
"test:prod": "wireit", | ||
"checksize": "wireit" | ||
}, | ||
"wireit": { | ||
"build": { | ||
"dependencies": [ | ||
"build:ts", | ||
"build:ts:types", | ||
"build:rollup", | ||
"../../reactive-element:build" | ||
] | ||
}, | ||
"build:ts": { | ||
"command": "tsc --build --pretty", | ||
"dependencies": [ | ||
"../../reactive-element:build:ts:types" | ||
], | ||
"clean": "if-file-deleted", | ||
"files": [ | ||
"src/**/*.ts", | ||
"tsconfig.json" | ||
], | ||
"output": [ | ||
"development", | ||
"tsconfig.tsbuildinfo" | ||
] | ||
}, | ||
"build:ts:types": { | ||
"command": "treemirror development . \"**/*.d.ts{,.map}\"", | ||
"dependencies": [ | ||
"../../internal-scripts:build", | ||
"build:ts" | ||
], | ||
"files": [], | ||
"output": [ | ||
"*.d.ts{,.map}", | ||
"test/**/*.d.ts{,.map}" | ||
] | ||
}, | ||
"build:rollup": { | ||
"command": "rollup -c", | ||
"dependencies": [ | ||
"build:ts" | ||
], | ||
"files": [ | ||
"rollup.config.js", | ||
"../../../rollup-common.js" | ||
], | ||
"output": [ | ||
"index.js{,.map}", | ||
"task.js{,.map}", | ||
"test/**/*.js{,.map}" | ||
] | ||
}, | ||
"checksize": { | ||
"command": "rollup -c --environment=CHECKSIZE", | ||
"dependencies": [ | ||
"build:ts" | ||
], | ||
"files": [ | ||
"rollup.config.js", | ||
"../../../rollup-common.js" | ||
], | ||
"output": [] | ||
}, | ||
"test": { | ||
"dependencies": [ | ||
"test:dev", | ||
"test:prod" | ||
] | ||
}, | ||
"test:dev": { | ||
"command": "MODE=dev node ../../tests/run-web-tests.js \"development/**/*_test.js\" --config ../../tests/web-test-runner.config.js", | ||
"dependencies": [ | ||
"build", | ||
"../../tests:build" | ||
], | ||
"files": [], | ||
"output": [] | ||
}, | ||
"test:prod": { | ||
"command": "MODE=prod node ../../tests/run-web-tests.js \"development/**/*_test.js\" --config ../../tests/web-test-runner.config.js", | ||
"dependencies": [ | ||
"build", | ||
"../../tests:build" | ||
], | ||
"files": [], | ||
"output": [] | ||
} | ||
}, | ||
"author": "Google LLC", | ||
"devDependencies": { | ||
"@esm-bundle/chai": "^4.1.5", | ||
"@types/chai": "^4.0.1", | ||
"@types/mocha": "^9.0.0", | ||
"@types/trusted-types": "^2.0.2", | ||
"@web/test-runner-mocha": "^0.7.4", | ||
"chokidar-cli": "^3.0.0", | ||
"concurrently": "^6.2.1", | ||
"mocha": "^9.1.1", | ||
"rollup": "^2.70.2", | ||
"typescript": "^4.3.5", | ||
"internal-scripts": "^1.0.0" | ||
"@lit-internal/scripts": "^1.0.0" | ||
}, | ||
@@ -66,0 +142,0 @@ "dependencies": { |
import { ReactiveControllerHost } from '@lit/reactive-element/reactive-controller.js'; | ||
export declare type TaskFunction<D extends [...unknown[]], R = any> = (args: D) => R | typeof initialState | Promise<R | typeof initialState>; | ||
export declare type ArgsFunction<D extends [...unknown[]]> = () => D; | ||
export declare type TaskFunction<D extends ReadonlyArray<unknown>, R = any> = (args: D) => R | typeof initialState | Promise<R | typeof initialState>; | ||
export declare type ArgsFunction<D extends ReadonlyArray<unknown>> = () => D; | ||
export { ArgsFunction as DepsFunction }; | ||
@@ -26,3 +26,3 @@ /** | ||
}; | ||
export interface TaskConfig<T extends unknown[], R> { | ||
export interface TaskConfig<T extends ReadonlyArray<unknown>, R> { | ||
task: TaskFunction<T, R>; | ||
@@ -68,3 +68,3 @@ args?: ArgsFunction<T>; | ||
*/ | ||
export declare class Task<T extends [...unknown[]] = any, R = any> { | ||
export declare class Task<T extends ReadonlyArray<unknown> = ReadonlyArray<unknown>, R = unknown> { | ||
private _previousArgs?; | ||
@@ -71,0 +71,0 @@ private _task; |
@@ -6,3 +6,3 @@ import{notEqual as t}from"@lit/reactive-element"; | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/const i={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},s=Symbol();class h{constructor(t,i,s){this.t=0,this.status=0,this.autoRun=!0,this.i=t,this.i.addController(this);const h="object"==typeof i?i:{task:i,args:s};this.h=h.task,this.o=h.args,void 0!==h.autoRun&&(this.autoRun=h.autoRun),this.taskComplete=new Promise(((t,i)=>{this.l=t,this.u=i}))}hostUpdated(){this.performTask()}async performTask(){var t;const i=null===(t=this.o)||void 0===t?void 0:t.call(this);this.shouldRun(i)&&this.run(i)}shouldRun(t){return this.autoRun&&this.v(t)}async run(t){var i;let h,r;null!=t||(t=null===(i=this.o)||void 0===i?void 0:i.call(this)),2!==this.status&&3!==this.status||(this.taskComplete=new Promise(((t,i)=>{this.l=t,this.u=i}))),this.status=1,this.m=void 0,this.p=void 0,this.i.requestUpdate();const o=++this.t;try{h=await this.h(t)}catch(t){r=t}this.t===o&&(h===s?this.status=0:(void 0===r?(this.status=2,this.l(h)):(this.status=3,this.u(r)),this.p=h,this.m=r),this.i.requestUpdate())}get value(){return this.p}get error(){return this.m}render(t){var i,s,h,r;switch(this.status){case 0:return null===(i=t.initial)||void 0===i?void 0:i.call(t);case 1:return null===(s=t.pending)||void 0===s?void 0:s.call(t);case 2:return null===(h=t.complete)||void 0===h?void 0:h.call(t,this.value);case 3:return null===(r=t.error)||void 0===r?void 0:r.call(t,this.error);default:this.status}}v(i){const s=this.g;return this.g=i,Array.isArray(i)&&Array.isArray(s)?i.length===s.length&&i.some(((i,h)=>t(i,s[h]))):i!==s}}export{h as Task,i as TaskStatus,s as initialState}; | ||
*/const i={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},s=Symbol();class h{constructor(t,i,s){this.o=0,this.status=0,this.autoRun=!0,this.i=t,this.i.addController(this);const h="object"==typeof i?i:{task:i,args:s};this.t=h.task,this.h=h.args,void 0!==h.autoRun&&(this.autoRun=h.autoRun),this.taskComplete=new Promise(((t,i)=>{this.l=t,this.u=i}))}hostUpdated(){this.performTask()}async performTask(){var t;const i=null===(t=this.h)||void 0===t?void 0:t.call(this);this.shouldRun(i)&&this.run(i)}shouldRun(t){return this.autoRun&&this.v(t)}async run(t){var i;let h,r;null!=t||(t=null===(i=this.h)||void 0===i?void 0:i.call(this)),2!==this.status&&3!==this.status||(this.taskComplete=new Promise(((t,i)=>{this.l=t,this.u=i}))),this.status=1,this._=void 0,this.m=void 0,this.i.requestUpdate();const o=++this.o;try{h=await this.t(t)}catch(t){r=t}this.o===o&&(h===s?this.status=0:(void 0===r?(this.status=2,this.l(h)):(this.status=3,this.u(r)),this.m=h,this._=r),this.i.requestUpdate())}get value(){return this.m}get error(){return this._}render(t){var i,s,h,r;switch(this.status){case 0:return null===(i=t.initial)||void 0===i?void 0:i.call(t);case 1:return null===(s=t.pending)||void 0===s?void 0:s.call(t);case 2:return null===(h=t.complete)||void 0===h?void 0:h.call(t,this.value);case 3:return null===(r=t.error)||void 0===r?void 0:r.call(t,this.error);default:this.status}}v(i){const s=this.T;return this.T=i,Array.isArray(i)&&Array.isArray(s)?i.length===s.length&&i.some(((i,h)=>t(i,s[h]))):i!==s}}export{h as Task,i as TaskStatus,s as initialState}; | ||
//# sourceMappingURL=task.js.map |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
54314
2
0
455