Skip to content

Commit

Permalink
Merge branch 'release/0.3.0' into released
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed May 13, 2019
2 parents c64d6aa + f50c549 commit 29bf130
Show file tree
Hide file tree
Showing 150 changed files with 4,411 additions and 1,787 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
/es
/dist
/temp
.rpt2_cache
tsdoc-metadata.json
# dependencies
/node_modules
/.pnp
Expand Down
24 changes: 22 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
.DS_Store
*.log*
*.tsbuildinfo
/temp
.rpt2_cache
node_modules
tsdoc-metadata.json
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tsbuildinfo
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
"typescript.tsdk": "node_modules\\typescript\\lib",
"search.exclude": {
"**/api-document": true
}
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// 有关 tasks.json 格式的文档,请参见
// https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start-tsc",
"problemMatcher": [
"$tsc-watch"
],
"isBackground": true
}
]
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# @holoflows/kit · ![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square) [![npm version](https://img.shields.io/npm/v/@holoflows/kit.svg?style=flat-square)](https://www.npmjs.com/package/@holoflows/kit) ![Ciecle CI](https://img.shields.io/circleci/project/github/DimensionFoundation/holoflows-kit.svg?style=flat-square&logo=circleci)
# @holoflows/kit · ![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square) [![npm version](https://img.shields.io/npm/v/@holoflows/kit.svg?style=flat-square)](https://www.npmjs.com/package/@holoflows/kit) ![Ciecle CI](https://img.shields.io/circleci/project/github/DimensionDev/Holoflows-Kit.svg?style=flat-square&logo=circleci)

Toolkit for modern web browser extension developing.

## Documentation

[English documentation](./doc/en/index.md)
[Get Started](./doc/en/index.md)

[简体中文文档](./doc/zh-CN/index.md)
[初次使用](./doc/zh-CN/index.md)

[API Documentation](./api-documents/kit.md)

## License

Expand Down
84 changes: 84 additions & 0 deletions api-documents/kit.asynccall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCall](./kit.asynccall.md)

## AsyncCall() function

Async call between different context.

<b>Signature:</b>

```typescript
export declare function AsyncCall<OtherSideImplementedFunctions = {}>(implementation: Default, options?: Partial<AsyncCallOptions>): OtherSideImplementedFunctions;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| implementation | <code>Default</code> | Implementation of this side. |
| options | <code>Partial&lt;AsyncCallOptions&gt;</code> | Define your own serializer, MessageCenter or other options. |

<b>Returns:</b>

`OtherSideImplementedFunctions`

## Remarks

Async call is a high level abstraction of MessageCenter.

\# Shared code

- How to stringify/parse parameters/returns should be shared, defaults to NoSerialization.

- `key` should be shared.

\# One side

- Should provide some functions then export its type (for example, `BackgroundCalls`<!-- -->)

- `const call = AsyncCall<ForegroundCalls>(backgroundCalls)`

- Then you can `call` any method on `ForegroundCalls`

\# Other side

- Should provide some functions then export its type (for example, `ForegroundCalls`<!-- -->)

- `const call = AsyncCall<BackgroundCalls>(foregroundCalls)`

- Then you can `call` any method on `BackgroundCalls`

Note: Two sides can implement the same function

## Example

For example, here is a mono repo.

Code for UI part:

```ts
const UI = {
async dialog(text: string) {
alert(text)
},
}
export type UI = typeof UI
const callsClient = AsyncCall<Server>(UI)
callsClient.sendMail('hello world', 'what')

```
Code for server part

```ts
const Server = {
async sendMail(text: string, to: string) {
return true
}
}
export type Server = typeof Server
const calls = AsyncCall<UI>(Server)
calls.dialog('hello')

```

11 changes: 11 additions & 0 deletions api-documents/kit.asynccalloptions.dontthrowonnotimplemented.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md) &gt; [dontThrowOnNotImplemented](./kit.asynccalloptions.dontthrowonnotimplemented.md)

## AsyncCallOptions.dontThrowOnNotImplemented property

<b>Signature:</b>

```typescript
dontThrowOnNotImplemented: boolean;
```
11 changes: 11 additions & 0 deletions api-documents/kit.asynccalloptions.key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md) &gt; [key](./kit.asynccalloptions.key.md)

## AsyncCallOptions.key property

<b>Signature:</b>

```typescript
key: string;
```
24 changes: 24 additions & 0 deletions api-documents/kit.asynccalloptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md)

## AsyncCallOptions interface

Options for [AsyncCall()](./kit.asynccall.md)

<b>Signature:</b>

```typescript
export interface AsyncCallOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [dontThrowOnNotImplemented](./kit.asynccalloptions.dontthrowonnotimplemented.md) | <code>boolean</code> | |
| [key](./kit.asynccalloptions.key.md) | <code>string</code> | |
| [MessageCenter](./kit.asynccalloptions.messagecenter.md) | <code>{</code><br/><code> new (): {</code><br/><code> on(event: string, cb: (data: any) =&gt; void): void;</code><br/><code> send(event: string, data: any): void;</code><br/><code> };</code><br/><code> }</code> | |
| [serializer](./kit.asynccalloptions.serializer.md) | <code>Serialization</code> | |
| [writeToConsole](./kit.asynccalloptions.writetoconsole.md) | <code>boolean</code> | |

16 changes: 16 additions & 0 deletions api-documents/kit.asynccalloptions.messagecenter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md) &gt; [MessageCenter](./kit.asynccalloptions.messagecenter.md)

## AsyncCallOptions.MessageCenter property

<b>Signature:</b>

```typescript
MessageCenter: {
new (): {
on(event: string, cb: (data: any) => void): void;
send(event: string, data: any): void;
};
};
```
11 changes: 11 additions & 0 deletions api-documents/kit.asynccalloptions.serializer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md) &gt; [serializer](./kit.asynccalloptions.serializer.md)

## AsyncCallOptions.serializer property

<b>Signature:</b>

```typescript
serializer: Serialization;
```
11 changes: 11 additions & 0 deletions api-documents/kit.asynccalloptions.writetoconsole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AsyncCallOptions](./kit.asynccalloptions.md) &gt; [writeToConsole](./kit.asynccalloptions.writetoconsole.md)

## AsyncCallOptions.writeToConsole property

<b>Signature:</b>

```typescript
writeToConsole: boolean;
```
47 changes: 47 additions & 0 deletions api-documents/kit.automatedtabtask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTask](./kit.automatedtabtask.md)

## AutomatedTabTask() function

Open a new page in the background, execute some task, then close it automatically.

<b>Signature:</b>

```typescript
export declare function AutomatedTabTask<T extends Record<string, (...args: any[]) => Promise<any>>>(taskImplements: T, options?: Partial<AutomatedTabTaskDefineTimeOptions>): ((url: string, options?: Partial<AutomatedTabTaskRuntimeOptions>) => T) | null;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| taskImplements | <code>T</code> | All tasks that background page can call. |
| options | <code>Partial&lt;AutomatedTabTaskDefineTimeOptions&gt;</code> | Options |

<b>Returns:</b>

`((url: string, options?: Partial<AutomatedTabTaskRuntimeOptions>) => T) | null`

## Example

In content script: (You must run this in the page you wanted to run task in!)

```ts
export const task = AutomatedTabTask({
async taskA() {
return 'Done!'
},
})

```
In background script:

Open https://example.com/ then run taskA() on that page, which will return 'Done!'

```ts
import { task } from '...'
task('https://example.com/').taskA()

```

13 changes: 13 additions & 0 deletions api-documents/kit.automatedtabtaskdefinetimeoptions.concurrent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTaskDefineTimeOptions](./kit.automatedtabtaskdefinetimeoptions.md) &gt; [concurrent](./kit.automatedtabtaskdefinetimeoptions.concurrent.md)

## AutomatedTabTaskDefineTimeOptions.concurrent property

At most run `concurrent` tasks. Prevents open too many tabs at the same time.

<b>Signature:</b>

```typescript
concurrent: number;
```
13 changes: 13 additions & 0 deletions api-documents/kit.automatedtabtaskdefinetimeoptions.key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTaskDefineTimeOptions](./kit.automatedtabtaskdefinetimeoptions.md) &gt; [key](./kit.automatedtabtaskdefinetimeoptions.key.md)

## AutomatedTabTaskDefineTimeOptions.key property

A unique key

<b>Signature:</b>

```typescript
key: string;
```
22 changes: 22 additions & 0 deletions api-documents/kit.automatedtabtaskdefinetimeoptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTaskDefineTimeOptions](./kit.automatedtabtaskdefinetimeoptions.md)

## AutomatedTabTaskDefineTimeOptions interface

Define-time options for [AutomatedTabTask()](./kit.automatedtabtask.md)

<b>Signature:</b>

```typescript
export interface AutomatedTabTaskDefineTimeOptions extends AutomatedTabTaskSharedOptions
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [concurrent](./kit.automatedtabtaskdefinetimeoptions.concurrent.md) | <code>number</code> | At most run <code>concurrent</code> tasks. Prevents open too many tabs at the same time. |
| [key](./kit.automatedtabtaskdefinetimeoptions.key.md) | <code>string</code> | A unique key |
| [memorizeTTL](./kit.automatedtabtaskdefinetimeoptions.memorizettl.md) | <code>number</code> | TTL for memorize |
13 changes: 13 additions & 0 deletions api-documents/kit.automatedtabtaskdefinetimeoptions.memorizettl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTaskDefineTimeOptions](./kit.automatedtabtaskdefinetimeoptions.md) &gt; [memorizeTTL](./kit.automatedtabtaskdefinetimeoptions.memorizettl.md)

## AutomatedTabTaskDefineTimeOptions.memorizeTTL property

TTL for memorize

<b>Signature:</b>

```typescript
memorizeTTL: number;
```
13 changes: 13 additions & 0 deletions api-documents/kit.automatedtabtaskruntimeoptions.important.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [AutomatedTabTaskRuntimeOptions](./kit.automatedtabtaskruntimeoptions.md) &gt; [important](./kit.automatedtabtaskruntimeoptions.important.md)

## AutomatedTabTaskRuntimeOptions.important property

This task is important, need to start now without queue.

<b>Signature:</b>

```typescript
important: boolean;
```
Loading

0 comments on commit 29bf130

Please sign in to comment.