Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduces new package @dfinity/core #681

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ If you are interested in contributing to this project, please read the [contribu

### Publishing

### For @dfinity/core

@dfinity/core is published independently of the rest of the packages in this repo. To publish a new version of @dfinity/core, follow these steps;

- Update the version in `packages/core/package.json`
- `npm install`
- `npm run build --workspace @dfinity/core`
- `npm publish --workspace @dfinity/core`

### For the rest of the packages

To publish to NPM, create a branch and run the following commands;

- `git clean -dfx`. Removes all non-tracked files and directories.
Expand All @@ -57,7 +68,7 @@ Then, when you have merged the new versions and published to npm, open https://g

### Publishing Docs

Until we have an internal process and centrally owned canister, docs can be released manually for `@dfinity/agent` and `@dfinity/authentication`.
Until we have an internal process and centrally owned canister, docs can be released manually for all packages in this monorepo.

- Start from a fresh clone (or `git clean -dfx .`)
- `npm install`
Expand Down
5 changes: 4 additions & 1 deletion bin/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ const newVersion = (() => {
console.log('New version will be: ' + newVersion);

// Read workspaces from root package.json
const workspaces: string[] = rootPackage.workspaces?.packages;
const workspaces: string[] = rootPackage.workspaces?.packages.filter(
// omit @dfinity/core, whose version is not pinned
workspace => !workspace.includes('core'),
);

// Identify packages in `/packages directory
const packages = workspaces
Expand Down
13 changes: 13 additions & 0 deletions docs/generated/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ <h1>Agent-JS Changelog</h1>
<section>
<h2>Version x.x.x</h2>
<ul>
<li>
Introduces @dfinity/core, a meta-package that will be released seperately from the
versions of the rest of the agent-js monorepo. It bundles the following packages as
dependencies:
<br />
<ul>
<li>@dfnity/agent</li>
<li>@dfnity/principal</li>
<li>@dfnity/candid</li>
<li>@dfnity/identity</li>
<li>@dfnity/utils</li>
</ul>
</li>
<li>
Corrects some dev dependencies incorrectly listed as dependencies in auth-client
package.json
Expand Down
47 changes: 42 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"packages/auth-client",
"packages/assets",
"packages/identity-secp256k1",
"packages/core",
"e2e/node",
"e2e/browser",
"demos/sample-javascript"
Expand Down
17 changes: 17 additions & 0 deletions packages/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
build_info.json
node_modules/
dist/
**/*.js
**/*.js.map
**/*.d.ts

# generated docs
/docs/reference

# Cannot ignore .d.ts files in types/
!types/**/*.d.ts

# Cannot ignore setup files for webpack and jest, which are still JavaScript.
!webpack.config.js
!jest.config.js
!test-setup.js
11 changes: 11 additions & 0 deletions packages/core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# We work with a safelist here, so block everything that's not permitted, and add packages
# that are.
**

!lib/**
!types/**/*.d.ts
!package.json
!README.md

# The following line further removes all test files (which matches .js and .d.ts).
lib/**/*.test.*
32 changes: 32 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @dfinity/core

This package provides the core functionality for interacting with the Internet Computer using JavaScript.

It contains and re-exports the following packages:

- [@dfinity/agent](../agent/README.md)
- [@dfinity/candid](../candid/README.md)
- [@dfinity/principal](../principal/README.md)
- [@dfinity/identity](../identity/README.md)
- [@dfinity/utils](https://github.com/dfinity/ic-js/blob/main/packages/utils/README.md)

## Installation

```bash
npm install @dfinity/core
```

## Usage

```js
import {
Actor,
HttpAgent,
ECDSAKeyIdentity,
uint8ArrayToBigInt,
createAgent,
toNullable,
} from '@dfinity/core';
```

All the good stuff is in here. More documentation coming soon.
66 changes: 66 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@dfinity/core",
"version": "1.0.0",
"author": "DFINITY Stiftung <[email protected]>",
"license": "Apache-2.0",
"description": "JavaScript and TypeScript library to interact with the Internet Computer",
"homepage": "https://internetcomputer.org",
"repository": {
"type": "git",
"url": "https://github.com/dfinity/agent-js.git",
"directory": "packages/agent"
},
"bugs": {
"url": "https://github.com/dfinity/agent-js/issues"
},
"keywords": [
"internet computer",
"internet-computer",
"ic",
"dfinity",
"agent",
"actor",
"dfx",
"canister",
"candid",
"motoko",
"javascript",
"typescript",
"blockchain",
"crypto",
"distributed",
"api",
"sdk"
],
"main": "./lib/cjs/index",
"module": "./lib/esm/index",
"unpkg": "./lib/esm/index",
"scripts": {
"build": "tsc -b && tsc -p tsconfig-cjs.json",
"build:watch": "tsc -b --watch",
"bundle": "esbuild --bundle src/index.ts --outfile=dist/index.js",
"eslint:fix": "npm run lint -- --fix",
"eslint": "eslint --ext '.js,.jsx,.ts,.tsx' src/index.ts",
"lint": "npm run eslint",
"make:docs/reference": "typedoc src/index.ts --out ../../docs/generated/core --excludeInternal",
"release": "npm publish",
"test": "jest --verbose",
"test:coverage": "jest --verbose --collectCoverage",
"tslint:fix": "npm run lint -- --fix",
"tslint": "tslint --project tsconfig.json --config tslint.json"
},
"dependencies": {
"@dfinity/agent": "0.15.x",
"@dfinity/candid": "^0.15.x",
"@dfinity/identity": "^0.15.x",
"@dfinity/principal": "^0.15.x",
"@dfinity/utils": "^0.0.x"
},
"size-limit": [
{
"path": "./dist/index.js",
"limit": "100 kB",
"webpack": false
}
]
}
24 changes: 24 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export * from '@dfinity/agent';
export * from '@dfinity/identity';
export * from '@dfinity/principal';
export type { JsonArray, JsonObject, JsonValue } from '@dfinity/candid';
export {
IDL,
idlLabelToId,
safeRead,
safeReadUint8,
slebDecode,
slebEncode,
lebDecode,
lebEncode,
writeIntLE,
writeUIntLE,
readIntLE,
readUIntLE,
concat,
toHexString,
fromHexString,
PipeArrayBuffer,
} from '@dfinity/candid';

export * from '@dfinity/utils';
7 changes: 7 additions & 0 deletions packages/core/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "lib/cjs"
}
}
23 changes: 23 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"composite": true,
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"lib": ["dom", "es2017"],
"module": "ES2020",
"moduleResolution": "node",
"outDir": "lib/esm",
"resolveJsonModule": true,
"rootDir": "./src",
"sourceMap": true,
"inlineSources": true,
"strict": true,
"target": "es2017",
"tsBuildInfoFile": "./build_info.json"
},
"include": ["src/**/*.ts"]
}