Skip to content

Commit

Permalink
Handle Circular Structure JSON Error (#52)
Browse files Browse the repository at this point in the history
* Add log error for circular options instead of throw

* Update version number
  • Loading branch information
seancrowe authored Oct 17, 2023
1 parent 045d699 commit b963d17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chili-publish/publisher-interface",
"version": "1.0.0",
"version": "1.0.1",
"author": "chili-publish",
"description": "PublisherInterface is a class object that allows you to interact with the CHILI Publisher editorObject via postMessage without the complexity of postMessage.",
"repository": {
Expand Down
7 changes: 4 additions & 3 deletions src/PublisherInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export class PublisherInterface {
static async buildWithIframe(targetIframe:HTMLIFrameElement, options:CommonBuildOptions) {
return PublisherInterface.build({targetIframe, ...options})
}

static async buildOnElement(parentElement:HTMLElement, editorURL:string, options:CommonBuildOptions) {
return PublisherInterface.build({parentElement, editorURL, ...options})
}
Expand All @@ -268,11 +267,13 @@ export class PublisherInterface {
debug: options.debug ?? originalOptions["penpalDebug"]
}
}


const stringifiedOptions = ((opts:AllBuildOptions) => {try {return JSON.stringify(opts)} catch (e:any) {return e.toString()}})(options);

const publisherInterface = new PublisherInterface();
publisherInterface.creationTime = new Date().toLocaleString();
publisherInterface.debug = options.debug ?? false;
publisherInterface.createDebugLog({functionName:"build()", customMessage:"Calling build() with options: " + JSON.stringify(options)})
publisherInterface.createDebugLog({functionName:"build()", customMessage:"Calling build() with options: " + stringifiedOptions});

const iframe = options.targetIframe ?? document.createElement("iframe");
publisherInterface.iframe = iframe;
Expand Down

0 comments on commit b963d17

Please sign in to comment.