@dscvr-one/canvas-client-sdk
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -21,2 +21,3 @@ import * as CanvasInterface from '@dscvr-one/canvas-interface'; | ||
createPost(htmlContent: string): Promise<CanvasInterface.User.CreatePostResponse>; | ||
createShareLink(urlData: string): Promise<CanvasInterface.User.CreateShareLinkResponse>; | ||
copyToClipboard(content: string): Promise<CanvasInterface.User.CopyToClipboardResponse>; | ||
@@ -23,0 +24,0 @@ onContentReaction(callback: (reaction: CanvasInterface.User.ContentReactionResponse) => void): void; |
@@ -117,2 +117,14 @@ // src/index.ts | ||
} | ||
createShareLink(urlData) { | ||
console.log("CREATE SHARE LINK IN SDK!"); | ||
return this.sendMessageAndWaitResponse( | ||
{ | ||
type: "user:create-share-link-request", | ||
payload: { | ||
urlData | ||
} | ||
}, | ||
CanvasInterface.User.createShareLinkResponseMessageSchema | ||
); | ||
} | ||
copyToClipboard(content) { | ||
@@ -119,0 +131,0 @@ return this.sendMessageAndWaitResponse( |
{ | ||
"name": "@dscvr-one/canvas-client-sdk", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "SDK for iframes apps to connect to dscvr host using postMessage rpc", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"main": "src/index.ts", | ||
"publishConfig": { | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"homepage": "https://github.com/dscvr-one/dscvr-canvas/tree/main/libs/canvas-client-sdk#readme", | ||
@@ -11,2 +15,9 @@ "files": [ | ||
], | ||
"scripts": { | ||
"build": "tsup", | ||
"doc": "typedoc", | ||
"release": "shipjs prepare", | ||
"release:dry": "shipjs prepare --dry-run", | ||
"release:auto": "shipjs prepare --yes" | ||
}, | ||
"keywords": [ | ||
@@ -22,3 +33,3 @@ "dscvr", | ||
"dependencies": { | ||
"@dscvr-one/canvas-interface": "~1.1.0", | ||
"@dscvr-one/canvas-interface": "~1.2.0", | ||
"eventemitter3": "^5.0.1" | ||
@@ -43,14 +54,3 @@ }, | ||
"typescript": "^5.3.3" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"doc": "typedoc", | ||
"lint:js": "npm run lint:eslint && npm run lint:prettier", | ||
"lint:eslint": "eslint \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore", | ||
"lint:prettier": "prettier --check \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore", | ||
"release": "shipjs prepare", | ||
"release:dry": "shipjs prepare --dry-run", | ||
"release:auto": "shipjs prepare --yes" | ||
}, | ||
"types": "./dist/index.d.ts" | ||
} | ||
} | ||
} |
@@ -32,3 +32,7 @@ # @dscvr-one/canvas-client-sdk | ||
```typescript | ||
import { CanvasInterface, CanvasClient } from '@dscvr-one/canvas-client-sdk'; | ||
import { | ||
createCanvasClient, | ||
type CanvasInterface, | ||
type CanvasClient, | ||
} from '@dscvr-one/canvas-client-sdk'; | ||
``` | ||
@@ -39,3 +43,3 @@ | ||
```typescript | ||
const canvasClient = new CanvasClient(); | ||
const canvasClient = createCanvasClient(); | ||
``` | ||
@@ -56,4 +60,39 @@ | ||
4. Destruction | ||
If the client is being instantiated in a react hook or in a vue component/composable (anything with a lifecycle), | ||
we recommend to destroy the client on hot refreshes to avoid `CanvasInterface.ClientAlreadyInitializedError` while on localhost. | ||
e.g `Vue` | ||
```typescript | ||
onMounted(() => { | ||
canvasClient = createCanvasClient(); | ||
if (!canvasClient) return; | ||
response = await canvasClient.ready(); | ||
}); | ||
onUnmounted(() => { | ||
canvasClient?.destroy(); | ||
}); | ||
``` | ||
e.g `React` | ||
```typescript | ||
useEffect(() => { | ||
canvasClient = createCanvasClient(); | ||
if (canvasClient) { | ||
response = await canvasClient.ready(); | ||
} | ||
// Destroy the client on effect cleanup | ||
return () => { | ||
canvasClient?.destroy(); | ||
}; | ||
}); | ||
``` | ||
## Contributing | ||
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request. |
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
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
Found 1 instance in 1 package
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
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
48624
9
570
96
1
1
+ Added@dscvr-one/canvas-interface@1.2.1(transitive)
- Removed@dscvr-one/canvas-interface@1.1.1(transitive)