piral-ember 1.0.0-pre.2098 → 1.0.1-beta.5640

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2021 smapiot
3
+ Copyright (c) 2019 - 2023 smapiot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io)
1
+ [![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
2
2
 
3
- # [Piral Ember](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-ember.svg?style=flat)](https://www.npmjs.com/package/piral-ember) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
3
+ # [Piral Ember](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-ember.svg?style=flat)](https://www.npmjs.com/package/piral-ember) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
- This is a plugin that only has a peer dependency to `piral-core`. What `piral-ember` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
5
+ This is a plugin that only has a peer dependency to `ember-source`. What `piral-ember` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
7
7
  The set includes an Ember.js converter for any component registration, as well as a `fromEmber` shortcut and a `EmberExtension` component.
8
8
 
@@ -16,10 +16,6 @@ The following functions are brought to the Pilet API.
16
16
 
17
17
  Transforms a standard Ember.js component into a component that can be used in Piral, essentially wrapping it with a reference to the corresponding converter.
18
18
 
19
- ### `EmberExtension`
20
-
21
- (tbd)
22
-
23
19
  ## Usage
24
20
 
25
21
  ::: summary: For pilet authors
@@ -47,7 +43,7 @@ Alternatively, if `piral-ember` has not been added to the Piral instance you can
47
43
 
48
44
  ```ts
49
45
  import { PiletApi } from '<name-of-piral-instance>';
50
- import { fromEmber } from 'piral-ember';
46
+ import { fromEmber } from 'piral-ember/convert';
51
47
  import { Page } from './Page';
52
48
 
53
49
  export function setup(piral: PiletApi) {
@@ -59,7 +55,7 @@ export function setup(piral: PiletApi) {
59
55
 
60
56
  ::: summary: For Piral instance developers
61
57
 
62
- Using Ember.js with Piral is as simple as installing `piral-ember` and `ember-source`.
58
+ Using Ember.js with Piral is as simple as installing `piral-ember` and `ember-source@^3`.
63
59
 
64
60
  ```ts
65
61
  import { createEmberApi } from 'piral-ember';
package/convert.d.ts CHANGED
@@ -1,9 +1,18 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createExtension } from './lib/extension';
3
- declare const convert: <TProps extends import("piral-core").BaseComponentProps>(App: import("./lib/types").EmberModule<TProps>, opts: any) => import("piral-core").ForeignComponent<TProps>;
1
+ import { createConverter } from './esm/converter';
2
+ export interface HtmlComponent<TProps> {
3
+ component: {
4
+ mount(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
5
+ update?(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
6
+ unmount?(element: HTMLElement, locals: any): void;
7
+ };
8
+ type: 'html';
9
+ }
4
10
  export interface EmberConverter {
5
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
11
+ (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
6
12
  }
7
- export declare const fromEmber: EmberConverter;
8
- export declare const createEmberExtension: typeof createExtension;
9
- export {};
13
+ export declare function createEmberConverter(...params: Parameters<typeof createConverter>): {
14
+ from: EmberConverter;
15
+ Extension: string;
16
+ };
17
+ declare const fromEmber: EmberConverter, EmberExtension: string;
18
+ export { fromEmber, EmberExtension };
package/convert.js CHANGED
@@ -1,11 +1,16 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.createEmberExtension = exports.fromEmber = void 0;
4
- var converter_1 = require("./lib/converter");
5
- var extension_1 = require("./lib/extension");
6
- var convert = converter_1.createConverter();
7
- exports.fromEmber = function (App, opts) { return ({
8
- type: 'html',
9
- component: convert(App, opts)
10
- }); };
11
- exports.createEmberExtension = extension_1.createExtension;
1
+ import { createConverter } from './esm/converter';
2
+ export function createEmberConverter() {
3
+ var params = [];
4
+ for (var _i = 0; _i < arguments.length; _i++) {
5
+ params[_i] = arguments[_i];
6
+ }
7
+ var convert = createConverter.apply(void 0, params);
8
+ var Extension = convert.Extension;
9
+ var from = function (App, opts) { return ({
10
+ type: 'html',
11
+ component: convert(App, opts),
12
+ }); };
13
+ return { from: from, Extension: Extension };
14
+ }
15
+ var _a = createEmberConverter(), fromEmber = _a.from, EmberExtension = _a.Extension;
16
+ export { fromEmber, EmberExtension };
@@ -0,0 +1,13 @@
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { EmberModule } from './types';
3
+ export interface EmberConverterOptions {
4
+ /**
5
+ * Defines the name of the extension component.
6
+ * @default ember-extension
7
+ */
8
+ selector?: string;
9
+ }
10
+ export declare function createConverter(config?: EmberConverterOptions): {
11
+ <TProps extends BaseComponentProps>(App: EmberModule<TProps>, opts: any): ForeignComponent<TProps>;
12
+ Extension: string;
13
+ };
@@ -0,0 +1,26 @@
1
+ import { createExtension } from './extension';
2
+ export function createConverter(config = {}) {
3
+ const { selector = 'ember-extension' } = config;
4
+ const Extension = createExtension(selector);
5
+ const convert = (App, opts) => ({
6
+ mount(rootElement, props, ctx, locals) {
7
+ locals.app = App.create(Object.assign(Object.assign({}, opts), { rootElement,
8
+ props,
9
+ ctx }));
10
+ },
11
+ update(rootElement, props, ctx, locals) {
12
+ locals.app.setProperties({
13
+ props,
14
+ ctx,
15
+ });
16
+ },
17
+ unmount(rootElement, locals) {
18
+ locals.app.destroy();
19
+ locals.app = undefined;
20
+ rootElement.innerHTML = '';
21
+ },
22
+ });
23
+ convert.Extension = Extension;
24
+ return convert;
25
+ }
26
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAe9C,MAAM,UAAU,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAEhD,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CACd,GAAwB,EACxB,IAAS,EACiB,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAA0B;YACvD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,iCAClB,IAAI,KACP,WAAW;gBACX,KAAK;gBACL,GAAG,IACH,CAAC;QACL,CAAC;QACD,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAA0B;YACxD,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;gBACvB,KAAK;gBACL,GAAG;aACJ,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,WAAW,EAAE,MAA0B;YAC7C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;YACvB,WAAW,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { PiralPlugin } from 'piral-core';
2
+ import { EmberConverterOptions } from './converter';
3
+ import type { PiletEmberApi } from './types';
4
+ /**
5
+ * Available configuration options for the Ember.js plugin.
6
+ */
7
+ export interface EmberConfig extends EmberConverterOptions {
8
+ }
9
+ /**
10
+ * Creates Pilet API extensions for integrating Ember.js.
11
+ */
12
+ export declare function createEmberApi(config?: EmberConfig): PiralPlugin<PiletEmberApi>;
package/esm/create.js ADDED
@@ -0,0 +1,23 @@
1
+ import { loadEmberApp } from './load';
2
+ import { createConverter } from './converter';
3
+ /**
4
+ * Creates Pilet API extensions for integrating Ember.js.
5
+ */
6
+ export function createEmberApi(config = {}) {
7
+ return (context) => {
8
+ const convert = createConverter(config);
9
+ context.converters.ember = ({ App, opts }) => convert(App, opts);
10
+ return {
11
+ fromEmber(App, opts) {
12
+ return {
13
+ type: 'ember',
14
+ App,
15
+ opts,
16
+ };
17
+ },
18
+ loadEmberApp,
19
+ EmberExtension: convert.Extension,
20
+ };
21
+ };
22
+ }
23
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAQrE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAAsB,EAAE;IACrD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEjE,OAAO;YACL,SAAS,CAAC,GAAG,EAAE,IAAI;gBACjB,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,GAAG;oBACH,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,YAAY;YACZ,cAAc,EAAE,OAAO,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function createExtension(selector: string): string;
@@ -0,0 +1,11 @@
1
+ export function createExtension(selector) {
2
+ const defaultExtensionSelector = 'piral-extension';
3
+ if ('customElements' in window && selector && selector !== defaultExtensionSelector) {
4
+ const ExtensionBase = customElements.get(defaultExtensionSelector);
5
+ class AliasExtension extends ExtensionBase {
6
+ }
7
+ customElements.define(selector, AliasExtension);
8
+ }
9
+ return selector || defaultExtensionSelector;
10
+ }
11
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;IAEnD,IAAI,gBAAgB,IAAI,MAAM,IAAI,QAAQ,IAAI,QAAQ,KAAK,wBAAwB,EAAE;QACnF,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,MAAM,cAAe,SAAQ,aAAa;SAAG;QAC7C,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACjD;IAED,OAAO,QAAQ,IAAI,wBAAwB,CAAC;AAC9C,CAAC"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './create';
2
+ export * from './types';
package/esm/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './create';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/esm/load.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function loadEmberApp(appName: string, appUrl: string, vendorUrl?: string): Promise<any>;
package/esm/load.js ADDED
@@ -0,0 +1,26 @@
1
+ export function loadEmberApp(appName, appUrl, vendorUrl) {
2
+ return new Promise((resolve, reject) => {
3
+ if (vendorUrl) {
4
+ const scriptVendor = document.createElement('script');
5
+ scriptVendor.src = vendorUrl;
6
+ scriptVendor.async = true;
7
+ scriptVendor.onload = loadApp;
8
+ scriptVendor.onerror = reject;
9
+ document.head.appendChild(scriptVendor);
10
+ }
11
+ else {
12
+ loadApp();
13
+ }
14
+ function loadApp() {
15
+ const scriptEl = document.createElement('script');
16
+ scriptEl.src = appUrl;
17
+ scriptEl.async = true;
18
+ scriptEl.onload = () => {
19
+ resolve(window.require(appName + '/app'));
20
+ };
21
+ scriptEl.onerror = reject;
22
+ document.head.appendChild(scriptEl);
23
+ }
24
+ });
25
+ }
26
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,MAAc,EAAE,SAAkB;IAC9E,OAAO,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI,SAAS,EAAE;YACb,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACtD,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;YAC7B,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC;YAC1B,YAAY,CAAC,MAAM,GAAG,OAAO,CAAC;YAC9B,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACzC;aAAM;YACL,OAAO,EAAE,CAAC;SACX;QAED,SAAS,OAAO;YACd,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAClD,QAAQ,CAAC,GAAG,GAAG,MAAM,CAAC;YACtB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YACtB,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBACrB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/esm/types.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import type { ForeignComponent } from 'piral-core';
2
+ declare module 'piral-core/lib/types/custom' {
3
+ interface PiletCustomApi extends PiletEmberApi {
4
+ }
5
+ interface PiralCustomComponentConverters<TProps> {
6
+ ember(component: PiralEmberComponent<TProps>): ForeignComponent<TProps>;
7
+ }
8
+ }
9
+ export interface EmberOptions<TProps> {
10
+ props: TProps;
11
+ ctx: any;
12
+ }
13
+ export interface EmberInstance<TProps> {
14
+ setProperties(opts: EmberOptions<TProps>): void;
15
+ destroy(): void;
16
+ }
17
+ export interface EmberModule<TProps> {
18
+ create(opts: EmberOptions<TProps>): EmberInstance<TProps>;
19
+ }
20
+ export interface PiralEmberComponent<TProps> {
21
+ /**
22
+ * The Ember.js component App.
23
+ */
24
+ App: EmberModule<TProps>;
25
+ /**
26
+ * The Ember.js component options.
27
+ */
28
+ opts: any;
29
+ /**
30
+ * The type of the Ember.js component.
31
+ */
32
+ type: 'ember';
33
+ }
34
+ /**
35
+ * Defines the provided set of Pilet API extensions from the Ember.js plugin.
36
+ */
37
+ export interface PiletEmberApi {
38
+ /**
39
+ * Loads an ember application via it's URLs.
40
+ * @param appName The name of the ember application.
41
+ * @param appUrl The URL of the main ember application.
42
+ * @param vendorUrl The optional URL of the (shared) ember vendor bundle.
43
+ * @returns The promise resolving to the loaded ember application.
44
+ */
45
+ loadEmberApp<T = any>(appName: string, appUrl: string, vendorUrl?: string): Promise<T>;
46
+ /**
47
+ * Wraps an Emberjs component for use in Piral.
48
+ * @param App The component root.
49
+ * @param opts The component options.
50
+ * @returns The Piral Ember.js component.
51
+ */
52
+ fromEmber<TProps>(App: EmberModule<TProps>, opts: any): PiralEmberComponent<TProps>;
53
+ /**
54
+ * Gets the name of the Ember.js extension.
55
+ */
56
+ EmberExtension: string;
57
+ }
package/esm/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,13 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- import { EmberModule } from './types';
3
- export declare function createConverter(): <TProps extends BaseComponentProps>(App: EmberModule<TProps>, opts: any) => ForeignComponent<TProps>;
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { EmberModule } from './types';
3
+ export interface EmberConverterOptions {
4
+ /**
5
+ * Defines the name of the extension component.
6
+ * @default ember-extension
7
+ */
8
+ selector?: string;
9
+ }
10
+ export declare function createConverter(config?: EmberConverterOptions): {
11
+ <TProps extends BaseComponentProps>(App: EmberModule<TProps>, opts: any): ForeignComponent<TProps>;
12
+ Extension: string;
13
+ };
package/lib/converter.js CHANGED
@@ -1,33 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConverter = void 0;
4
- var tslib_1 = require("tslib");
5
- function createConverter() {
6
- var convert = function (App, opts) {
7
- var app = undefined;
8
- return {
9
- mount: function (rootElement, props, ctx) {
10
- rootElement.addEventListener('render-html', function (ev) {
11
- var piral = props.piral;
12
- piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
13
- }, false);
14
- app = App.create(tslib_1.__assign(tslib_1.__assign({}, opts), { rootElement: rootElement,
15
- props: props,
16
- ctx: ctx }));
17
- },
18
- update: function (_, props, ctx) {
19
- app.setProperties({
20
- props: props,
21
- ctx: ctx,
22
- });
23
- },
24
- unmount: function (rootElement) {
25
- app.destroy();
26
- app = undefined;
27
- rootElement.innerHTML = '';
28
- },
29
- };
30
- };
4
+ const extension_1 = require("./extension");
5
+ function createConverter(config = {}) {
6
+ const { selector = 'ember-extension' } = config;
7
+ const Extension = (0, extension_1.createExtension)(selector);
8
+ const convert = (App, opts) => ({
9
+ mount(rootElement, props, ctx, locals) {
10
+ locals.app = App.create(Object.assign(Object.assign({}, opts), { rootElement,
11
+ props,
12
+ ctx }));
13
+ },
14
+ update(rootElement, props, ctx, locals) {
15
+ locals.app.setProperties({
16
+ props,
17
+ ctx,
18
+ });
19
+ },
20
+ unmount(rootElement, locals) {
21
+ locals.app.destroy();
22
+ locals.app = undefined;
23
+ rootElement.innerHTML = '';
24
+ },
25
+ });
26
+ convert.Extension = Extension;
31
27
  return convert;
32
28
  }
33
29
  exports.createConverter = createConverter;
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;;AAGA,SAAgB,eAAe;IAC7B,IAAM,OAAO,GAAG,UACd,GAAwB,EACxB,IAAS;QAET,IAAI,GAAG,GAA0B,SAAS,CAAC;QAE3C,OAAO;YACL,KAAK,EAAL,UAAM,WAAW,EAAE,KAAK,EAAE,GAAG;gBAC3B,WAAW,CAAC,gBAAgB,CAC1B,aAAa,EACb,UAAC,EAAe;oBACN,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;oBACxB,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC/D,CAAC,EACD,KAAK,CACN,CAAC;gBACF,GAAG,GAAG,GAAG,CAAC,MAAM,uCACX,IAAI,KACP,WAAW,aAAA;oBACX,KAAK,OAAA;oBACL,GAAG,KAAA,IACH,CAAC;YACL,CAAC;YACD,MAAM,YAAC,CAAC,EAAE,KAAK,EAAE,GAAG;gBAClB,GAAG,CAAC,aAAa,CAAC;oBAChB,KAAK,OAAA;oBACL,GAAG,KAAA;iBACJ,CAAC,CAAC;YACL,CAAC;YACD,OAAO,YAAC,WAAW;gBACjB,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,GAAG,GAAG,SAAS,CAAC;gBAChB,WAAW,CAAC,SAAS,GAAG,EAAE,CAAC;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAtCD,0CAsCC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAe9C,SAAgB,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAEhD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CACd,GAAwB,EACxB,IAAS,EACiB,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAA0B;YACvD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,iCAClB,IAAI,KACP,WAAW;gBACX,KAAK;gBACL,GAAG,IACH,CAAC;QACL,CAAC;QACD,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAA0B;YACxD,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;gBACvB,KAAK;gBACL,GAAG;aACJ,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,WAAW,EAAE,MAA0B;YAC7C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;YACvB,WAAW,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA/BD,0CA+BC"}
package/lib/create.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
+ import { EmberConverterOptions } from './converter';
2
3
  import type { PiletEmberApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Ember.js plugin.
5
6
  */
6
- export interface EmberConfig {
7
- /**
8
- * Defines the name of the extension component.
9
- * @default ember-extension
10
- */
11
- selector?: string;
7
+ export interface EmberConfig extends EmberConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates Pilet API extensions for integrating Ember.js.
package/lib/create.js CHANGED
@@ -1,32 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createEmberApi = void 0;
4
- var load_1 = require("./load");
5
- var converter_1 = require("./converter");
6
- var extension_1 = require("./extension");
4
+ const load_1 = require("./load");
5
+ const converter_1 = require("./converter");
7
6
  /**
8
7
  * Creates Pilet API extensions for integrating Ember.js.
9
8
  */
10
- function createEmberApi(config) {
11
- if (config === void 0) { config = {}; }
12
- var selector = config.selector;
13
- return function (context) {
14
- var convert = converter_1.createConverter();
15
- context.converters.ember = function (_a) {
16
- var App = _a.App, opts = _a.opts;
17
- return convert(App, opts);
18
- };
19
- extension_1.createExtension(selector);
9
+ function createEmberApi(config = {}) {
10
+ return (context) => {
11
+ const convert = (0, converter_1.createConverter)(config);
12
+ context.converters.ember = ({ App, opts }) => convert(App, opts);
20
13
  return {
21
- fromEmber: function (App, opts) {
14
+ fromEmber(App, opts) {
22
15
  return {
23
16
  type: 'ember',
24
- App: App,
25
- opts: opts,
17
+ App,
18
+ opts,
26
19
  };
27
20
  },
28
21
  loadEmberApp: load_1.loadEmberApp,
29
- EmberExtension: selector,
22
+ EmberExtension: convert.Extension,
30
23
  };
31
24
  };
32
25
  }
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,+BAAsC;AACtC,yCAA8C;AAC9C,yCAA8C;AAc9C;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAwB;IAAxB,uBAAA,EAAA,WAAwB;IAC7C,IAAA,QAAQ,GAAK,MAAM,SAAX,CAAY;IAE5B,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,2BAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,UAAC,EAAa;gBAAX,GAAG,SAAA,EAAE,IAAI,UAAA;YAAO,OAAA,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;QAAlB,CAAkB,CAAC;QAEjE,2BAAe,CAAC,QAAQ,CAAC,CAAC;QAE1B,OAAO;YACL,SAAS,YAAC,GAAG,EAAE,IAAI;gBACjB,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,GAAG,KAAA;oBACH,IAAI,MAAA;iBACL,CAAC;YACJ,CAAC;YACD,YAAY,qBAAA;YACZ,cAAc,EAAE,QAAQ;SACzB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArBD,wCAqBC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,iCAAsC;AACtC,2CAAqE;AAQrE;;GAEG;AACH,SAAgB,cAAc,CAAC,SAAsB,EAAE;IACrD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEjE,OAAO;YACL,SAAS,CAAC,GAAG,EAAE,IAAI;gBACjB,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,GAAG;oBACH,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,YAAY,EAAZ,mBAAY;YACZ,cAAc,EAAE,OAAO,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,wCAiBC"}
@@ -1 +1 @@
1
- export declare function createExtension(selector?: string): void;
1
+ export declare function createExtension(selector: string): string;
package/lib/extension.js CHANGED
@@ -1,32 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExtension = void 0;
4
- var tslib_1 = require("tslib");
5
4
  function createExtension(selector) {
6
- if (selector === void 0) { selector = 'ember-extension'; }
7
- if ('customElements' in window) {
8
- var EmberExtension = /** @class */ (function (_super) {
9
- tslib_1.__extends(EmberExtension, _super);
10
- function EmberExtension() {
11
- return _super !== null && _super.apply(this, arguments) || this;
12
- }
13
- EmberExtension.prototype.connectedCallback = function () {
14
- if (this.isConnected) {
15
- this.dispatchEvent(new CustomEvent('render-html', {
16
- bubbles: true,
17
- detail: {
18
- target: this,
19
- props: {
20
- name: this.getAttribute('name'),
21
- },
22
- },
23
- }));
24
- }
25
- };
26
- return EmberExtension;
27
- }(HTMLElement));
28
- customElements.define(selector, EmberExtension);
5
+ const defaultExtensionSelector = 'piral-extension';
6
+ if ('customElements' in window && selector && selector !== defaultExtensionSelector) {
7
+ const ExtensionBase = customElements.get(defaultExtensionSelector);
8
+ class AliasExtension extends ExtensionBase {
9
+ }
10
+ customElements.define(selector, AliasExtension);
29
11
  }
12
+ return selector || defaultExtensionSelector;
30
13
  }
31
14
  exports.createExtension = createExtension;
32
15
  //# sourceMappingURL=extension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;AAAA,SAAgB,eAAe,CAAC,QAA4B;IAA5B,yBAAA,EAAA,4BAA4B;IAC1D,IAAI,gBAAgB,IAAI,MAAM,EAAE;QAC9B;YAA6B,0CAAW;YAAxC;;YAgBA,CAAC;YAfC,0CAAiB,GAAjB;gBACE,IAAI,IAAI,CAAC,WAAW,EAAE;oBACpB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,aAAa,EAAE;wBAC7B,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE;4BACN,MAAM,EAAE,IAAI;4BACZ,KAAK,EAAE;gCACL,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;6BAChC;yBACF;qBACF,CAAC,CACH,CAAC;iBACH;YACH,CAAC;YACH,qBAAC;QAAD,CAAC,AAhBD,CAA6B,WAAW,GAgBvC;QAED,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACjD;AACH,CAAC;AAtBD,0CAsBC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,QAAgB;IAC9C,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;IAEnD,IAAI,gBAAgB,IAAI,MAAM,IAAI,QAAQ,IAAI,QAAQ,KAAK,wBAAwB,EAAE;QACnF,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,MAAM,cAAe,SAAQ,aAAa;SAAG;QAC7C,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACjD;IAED,OAAO,QAAQ,IAAI,wBAAwB,CAAC;AAC9C,CAAC;AAVD,0CAUC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./create"), exports);
5
5
  tslib_1.__exportStar(require("./types"), exports);
6
6
  //# sourceMappingURL=index.js.map
package/lib/load.js CHANGED
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadEmberApp = void 0;
4
4
  function loadEmberApp(appName, appUrl, vendorUrl) {
5
- return new Promise(function (resolve, reject) {
5
+ return new Promise((resolve, reject) => {
6
6
  if (vendorUrl) {
7
- var scriptVendor = document.createElement('script');
7
+ const scriptVendor = document.createElement('script');
8
8
  scriptVendor.src = vendorUrl;
9
9
  scriptVendor.async = true;
10
10
  scriptVendor.onload = loadApp;
@@ -15,10 +15,10 @@ function loadEmberApp(appName, appUrl, vendorUrl) {
15
15
  loadApp();
16
16
  }
17
17
  function loadApp() {
18
- var scriptEl = document.createElement('script');
18
+ const scriptEl = document.createElement('script');
19
19
  scriptEl.src = appUrl;
20
20
  scriptEl.async = true;
21
- scriptEl.onload = function () {
21
+ scriptEl.onload = () => {
22
22
  resolve(window.require(appName + '/app'));
23
23
  };
24
24
  scriptEl.onerror = reject;
package/lib/load.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,OAAe,EAAE,MAAc,EAAE,SAAkB;IAC9E,OAAO,IAAI,OAAO,CAAM,UAAC,OAAO,EAAE,MAAM;QACtC,IAAI,SAAS,EAAE;YACb,IAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACtD,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;YAC7B,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC;YAC1B,YAAY,CAAC,MAAM,GAAG,OAAO,CAAC;YAC9B,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACzC;aAAM;YACL,OAAO,EAAE,CAAC;SACX;QAED,SAAS,OAAO;YACd,IAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAClD,QAAQ,CAAC,GAAG,GAAG,MAAM,CAAC;YACtB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YACtB,QAAQ,CAAC,MAAM,GAAG;gBAChB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAxBD,oCAwBC"}
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,OAAe,EAAE,MAAc,EAAE,SAAkB;IAC9E,OAAO,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI,SAAS,EAAE;YACb,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACtD,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;YAC7B,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC;YAC1B,YAAY,CAAC,MAAM,GAAG,OAAO,CAAC;YAC9B,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACzC;aAAM;YACL,OAAO,EAAE,CAAC;SACX;QAED,SAAS,OAAO;YACd,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAClD,QAAQ,CAAC,GAAG,GAAG,MAAM,CAAC;YACtB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YACtB,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBACrB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAxBD,oCAwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-ember",
3
- "version": "1.0.0-pre.2098",
3
+ "version": "1.0.1-beta.5640",
4
4
  "description": "Plugin for integrating Ember.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -16,14 +16,35 @@
16
16
  "author": "smapiot",
17
17
  "homepage": "https://piral.io",
18
18
  "license": "MIT",
19
+ "module": "esm/index.js",
19
20
  "main": "lib/index.js",
20
21
  "typings": "lib/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./esm/index.js",
25
+ "require": "./lib/index.js"
26
+ },
27
+ "./convert": {
28
+ "import": "./convert.js"
29
+ },
30
+ "./esm/*": {
31
+ "import": "./esm/*"
32
+ },
33
+ "./lib/*": {
34
+ "require": "./lib/*"
35
+ },
36
+ "./_/*": {
37
+ "import": "./esm/*.js",
38
+ "require": "./lib/*.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
21
42
  "sideEffects": false,
22
43
  "files": [
44
+ "esm",
23
45
  "lib",
24
46
  "src",
25
47
  "convert.d.ts",
26
- "convert.ts",
27
48
  "convert.js"
28
49
  ],
29
50
  "repository": {
@@ -34,18 +55,18 @@
34
55
  "url": "https://github.com/smapiot/piral/issues"
35
56
  },
36
57
  "scripts": {
37
- "build": "tsc && tsc convert.ts --skipLibCheck --declaration",
58
+ "cleanup": "rimraf esm lib convert.d.ts convert.js",
59
+ "build": "yarn build:commonjs && yarn build:esnext && yarn build:convert",
60
+ "build:convert": "tsc convert.ts --skipLibCheck --declaration --module esnext",
61
+ "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
62
+ "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
38
63
  "typedoc": "typedoc --json ../../../docs/types/piral-ember.json src --exclude \"src/**/*.test.*\"",
39
64
  "test": "echo \"Error: run tests from root\" && exit 1"
40
65
  },
41
66
  "devDependencies": {
42
67
  "@types/ember": "^3.1.1",
43
68
  "ember-source": "^3.15.0",
44
- "piral-core": "^1.0.0-pre.2098"
45
- },
46
- "peerDependencies": {
47
- "ember-source": "^3.0.0",
48
- "piral-core": "1.x"
69
+ "piral-core": "1.0.1-beta.5640"
49
70
  },
50
- "gitHead": "cbb7df31a4361db11c2c250a37ca8f2c610539fc"
71
+ "gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
51
72
  }
package/src/converter.ts CHANGED
@@ -1,42 +1,48 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- import { EmberInstance, EmberModule } from './types';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import { createExtension } from './extension';
3
+ import type { EmberInstance, EmberModule } from './types';
4
+
5
+ export interface EmberConverterOptions {
6
+ /**
7
+ * Defines the name of the extension component.
8
+ * @default ember-extension
9
+ */
10
+ selector?: string;
11
+ }
12
+
13
+ interface EmberState<TProps> {
14
+ app: EmberInstance<TProps>;
15
+ }
16
+
17
+ export function createConverter(config: EmberConverterOptions = {}) {
18
+ const { selector = 'ember-extension' } = config;
19
+
20
+ const Extension = createExtension(selector);
3
21
 
4
- export function createConverter() {
5
22
  const convert = <TProps extends BaseComponentProps>(
6
23
  App: EmberModule<TProps>,
7
24
  opts: any,
8
- ): ForeignComponent<TProps> => {
9
- let app: EmberInstance<TProps> = undefined;
10
-
11
- return {
12
- mount(rootElement, props, ctx) {
13
- rootElement.addEventListener(
14
- 'render-html',
15
- (ev: CustomEvent) => {
16
- const { piral } = props;
17
- piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
18
- },
19
- false,
20
- );
21
- app = App.create({
22
- ...opts,
23
- rootElement,
24
- props,
25
- ctx,
26
- });
27
- },
28
- update(_, props, ctx) {
29
- app.setProperties({
30
- props,
31
- ctx,
32
- });
33
- },
34
- unmount(rootElement) {
35
- app.destroy();
36
- app = undefined;
37
- rootElement.innerHTML = '';
38
- },
39
- };
40
- };
25
+ ): ForeignComponent<TProps> => ({
26
+ mount(rootElement, props, ctx, locals: EmberState<TProps>) {
27
+ locals.app = App.create({
28
+ ...opts,
29
+ rootElement,
30
+ props,
31
+ ctx,
32
+ });
33
+ },
34
+ update(rootElement, props, ctx, locals: EmberState<TProps>) {
35
+ locals.app.setProperties({
36
+ props,
37
+ ctx,
38
+ });
39
+ },
40
+ unmount(rootElement, locals: EmberState<TProps>) {
41
+ locals.app.destroy();
42
+ locals.app = undefined;
43
+ rootElement.innerHTML = '';
44
+ },
45
+ });
46
+ convert.Extension = Extension;
41
47
  return convert;
42
48
  }
package/src/create.ts CHANGED
@@ -1,32 +1,21 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
2
  import { loadEmberApp } from './load';
3
- import { createConverter } from './converter';
4
- import { createExtension } from './extension';
3
+ import { createConverter, EmberConverterOptions } from './converter';
5
4
  import type { PiletEmberApi } from './types';
6
5
 
7
6
  /**
8
7
  * Available configuration options for the Ember.js plugin.
9
8
  */
10
- export interface EmberConfig {
11
- /**
12
- * Defines the name of the extension component.
13
- * @default ember-extension
14
- */
15
- selector?: string;
16
- }
9
+ export interface EmberConfig extends EmberConverterOptions {}
17
10
 
18
11
  /**
19
12
  * Creates Pilet API extensions for integrating Ember.js.
20
13
  */
21
14
  export function createEmberApi(config: EmberConfig = {}): PiralPlugin<PiletEmberApi> {
22
- const { selector } = config;
23
-
24
15
  return (context) => {
25
- const convert = createConverter();
16
+ const convert = createConverter(config);
26
17
  context.converters.ember = ({ App, opts }) => convert(App, opts);
27
18
 
28
- createExtension(selector);
29
-
30
19
  return {
31
20
  fromEmber(App, opts) {
32
21
  return {
@@ -36,7 +25,7 @@ export function createEmberApi(config: EmberConfig = {}): PiralPlugin<PiletEmber
36
25
  };
37
26
  },
38
27
  loadEmberApp,
39
- EmberExtension: selector,
28
+ EmberExtension: convert.Extension,
40
29
  };
41
30
  };
42
31
  }
package/src/extension.ts CHANGED
@@ -1,23 +1,11 @@
1
- export function createExtension(selector = 'ember-extension') {
2
- if ('customElements' in window) {
3
- class EmberExtension extends HTMLElement {
4
- connectedCallback() {
5
- if (this.isConnected) {
6
- this.dispatchEvent(
7
- new CustomEvent('render-html', {
8
- bubbles: true,
9
- detail: {
10
- target: this,
11
- props: {
12
- name: this.getAttribute('name'),
13
- },
14
- },
15
- }),
16
- );
17
- }
18
- }
19
- }
1
+ export function createExtension(selector: string) {
2
+ const defaultExtensionSelector = 'piral-extension';
20
3
 
21
- customElements.define(selector, EmberExtension);
4
+ if ('customElements' in window && selector && selector !== defaultExtensionSelector) {
5
+ const ExtensionBase = customElements.get(defaultExtensionSelector);
6
+ class AliasExtension extends ExtensionBase {}
7
+ customElements.define(selector, AliasExtension);
22
8
  }
9
+
10
+ return selector || defaultExtensionSelector;
23
11
  }
package/convert.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createConverter } from './lib/converter';
3
- import { createExtension } from './lib/extension';
4
-
5
- const convert = createConverter();
6
-
7
- export interface EmberConverter {
8
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
9
- }
10
-
11
- export const fromEmber: EmberConverter = (App, opts) => ({
12
- type: 'html',
13
- component: convert(App, opts),
14
- });
15
-
16
- export const createEmberExtension = createExtension;