diff --git a/.kopytkorc b/.kopytkorc index 555cb90..4c5ad68 100644 --- a/.kopytkorc +++ b/.kopytkorc @@ -1,5 +1,5 @@ { - "baseManifest": "./node_modules/@dazn/kopytko-unit-testing-framework/manifest.js", + "baseManifest": "./manifest.js", "sourceDir": "./src", "pluginDefinitions": { "generate-tests": "./node_modules/@dazn/kopytko-unit-testing-framework/plugins/generate-tests" diff --git a/docs/renderer.md b/docs/renderer.md index f8e2f65..d1dcdac 100644 --- a/docs/renderer.md +++ b/docs/renderer.md @@ -174,6 +174,9 @@ these methods are called lifecycle methods: ``` - `componentDidCatch(error as Object, info as Object)` - called when a component method has thrown an error + + IMPORTANT: This catch will only work with **bs_const** `enableKopytkoComponentDidCatch: true` in the **manifest** file. + ```brightscript sub componentDidCatch(error as Object, info as Object) ' The Roku exception object diff --git a/docs/versions-migration-guide.md b/docs/versions-migration-guide.md index 4d97968..bf3498b 100644 --- a/docs/versions-migration-guide.md +++ b/docs/versions-migration-guide.md @@ -1,10 +1,20 @@ -# Update Kopytko Framework to v2 +# Update Kopytko Framework -## Highlighted breaking changes in Kopytko Framework v2 -There were no interface changes making Kopytko Framework v2 a breaking change, but, because Kopytko Packager so far doesn't handle components and functions namespacing, the introduced new [`HttpRequest`](../src/components/http/request/Http.request.xml) component may cause name collision. It can happen if there already exist a HttpRequest component in the application the framework is used and it is very probable as Kopytko team was recommending creating own HttpRequest extending the [`Request`](../src/components/http/request/Request.xml) component. We came across Kopytko users' needs and created a helpful `HttpRequest` component implementing all necessary mechanisms to make an HTTP(S) call - we recommend switching over to Kopytko's `HttpRequest` component as soon as possible. +## Update from v2 to v3 + +Version 3 introduced the `componentDidCatch` lifecycle method. It is not needed to implement componentDidCatch, but there could be a scenario where it is implemented and a developer wants to disable it (for example, for the development time). Because of that there is a new **bs_const** that needs to be defined in the **manifest** file - `enableKopytkoComponentDidCatch`. + +`enableKopytkoComponentDidCatch: true` - **enables** the `componentDidCatch` method + +`enableKopytkoComponentDidCatch: false` - **disables** the `componentDidCatch` method +## Update from v1 to v2 + +### Highlighted breaking changes in Kopytko Framework v2 + +There were no interface changes making Kopytko Framework v2 a breaking change, but, because Kopytko Packager so far doesn't handle components and functions namespacing, the introduced new [`HttpRequest`](../src/components/http/request/Http.request.xml) component may cause name collision. It can happen if there already exist a HttpRequest component in the application the framework is used and it is very probable as Kopytko team was recommending creating own HttpRequest extending the [`Request`](../src/components/http/request/Request.xml) component. We came across Kopytko users' needs and created a helpful `HttpRequest` component implementing all necessary mechanisms to make an HTTP(S) call - we recommend switching over to Kopytko's `HttpRequest` component as soon as possible. -## Deprecations highlights in Kopytko Framework v2 +### Deprecations highlights in Kopytko Framework v2 These APIs remain available in v2, but will be removed in future versions. diff --git a/manifest.js b/manifest.js new file mode 100644 index 0000000..5d3525c --- /dev/null +++ b/manifest.js @@ -0,0 +1,9 @@ +const baseManifest = require('@dazn/kopytko-unit-testing-framework/manifest'); + +module.exports = { + ...baseManifest, + bs_const: { + ...baseManifest.bs_const, + enableKopytkoComponentDidCatch: false, + }, +} diff --git a/src/components/renderer/Kopytko.brs b/src/components/renderer/Kopytko.brs index 78587f9..b3fab2f 100644 --- a/src/components/renderer/Kopytko.brs +++ b/src/components/renderer/Kopytko.brs @@ -4,7 +4,12 @@ sub init() m.state = {} m.elementToFocus = Invalid - m._enabledErrorCatching = Type(componentDidCatch) <> "" + m._enabledErrorCatching = false + #if enableKopytkoComponentDidCatch + m._enabledErrorCatching = true + #end if + m._enabledErrorCatching = m._enabledErrorCatching AND Type(componentDidCatch) <> "" + m._isInitialized = false m._previousProps = {} m._previousState = {}