oc-template-svelte-compiler 0.0.12 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,21 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = svelteOCProviderTemplate;
4
4
  function svelteOCProviderTemplate({ viewPath, providerFunctions }) {
5
5
  return `
6
- import { mount } from 'svelte'
6
+ import { mount, unmount } from 'svelte'
7
7
  import View from '${viewPath}';
8
8
 
9
+ let app = null;
10
+
9
11
  function renderer(props, element, ssr) {
10
12
  const { _staticPath, _baseUrl, _componentName, _componentVersion, ...rest } = props;
11
13
  ${providerFunctions}
12
14
 
13
15
  rest.getData = getData;
14
16
  rest.getSetting = getSetting;
15
- const app = mount(View, {
17
+ app = mount(View, {
16
18
  target: element,
17
19
  props: rest
18
20
  });
19
21
  }
20
22
 
23
+ element.parentElement.unmount = () => {
24
+ if (app) {
25
+ unmount(app);
26
+ app = null;
27
+ }
28
+ }
29
+
21
30
  renderer.component = View;
22
31
 
23
32
  export default renderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-template-svelte-compiler",
3
- "version": "0.0.12",
3
+ "version": "1.0.1",
4
4
  "description": "Compiler for the Svelte OC template",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
32
32
  "oc-template-svelte": "^0.0.2",
33
- "oc-vite-compiler": "^4.2.4",
33
+ "oc-vite-compiler": "^4.2.9",
34
34
  "svelte": "^5.23.0"
35
35
  },
36
36
  "files": [
@@ -28,8 +28,9 @@
28
28
  "@types/testing-library__jest-dom": "^5.14.5",
29
29
  "jsdom": "^21.1.1",
30
30
  "oc-server": "^2.1.0",
31
- "oc-template-svelte-compiler": "^0.0.12",
31
+ "oc-template-svelte-compiler": "^1.0.1",
32
32
  "svelte": "^5.23.0",
33
+ "svelte-check": "^4.0.0",
33
34
  "typescript": "5.0.2",
34
35
  "vitest": "^0.29.7"
35
36
  }