piral-aurelia 1.0.0-pre.2093 → 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 Aurelia](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-aurelia.svg?style=flat)](https://www.npmjs.com/package/piral-aurelia) [![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 Aurelia](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-aurelia.svg?style=flat)](https://www.npmjs.com/package/piral-aurelia) [![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-aurelia` 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 `aurelia-framework` and related packages. What `piral-aurelia` 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 Aurelia converter for any component registration, as well as a `fromAurelia` shortcut and a `AureliaExtension` component.
8
8
 
@@ -47,7 +47,7 @@ Alternatively, if `piral-aurelia` has not been added to the Piral instance you c
47
47
 
48
48
  ```ts
49
49
  import { PiletApi } from '<name-of-piral-instance>';
50
- import { fromAurelia } from 'piral-aurelia';
50
+ import { fromAurelia } from 'piral-aurelia/convert';
51
51
  import { AureliaPage } from './AureliaPage';
52
52
 
53
53
  export function setup(piral: PiletApi) {
@@ -59,10 +59,16 @@ export function setup(piral: PiletApi) {
59
59
 
60
60
  ::: summary: For Piral instance developers
61
61
 
62
- Using Aurelia with Piral is as simple as installing `piral-aurelia` and `aurelia-framework`.
62
+ Using Aurelia with Piral is as simple as installing `piral-aurelia` and `aurelia-framework` together with the following Aurelia packages:
63
+
64
+ - `aurelia-event-aggregator`: 1.x
65
+ - `aurelia-framework`: 1.x
66
+ - `aurelia-history-browser`: 1.x
67
+ - `aurelia-pal-browser`: 1.x
68
+ - `aurelia-templating-binding`: 1.x
69
+ - `aurelia-templating-resources`: 1.x
63
70
 
64
71
  ```ts
65
- import 'aurelia-framework';
66
72
  import { createAureliaApi } from 'piral-aurelia';
67
73
  ```
68
74
 
@@ -80,15 +86,15 @@ The `aurelia` related packages should be shared with the pilets via the *package
80
86
 
81
87
  ```json
82
88
  {
83
- "pilets": {
84
- "externals": [
85
- "aurelia-framework",
86
- "aurelia-templating-binding",
87
- "aurelia-templating-resources",
88
- "aurelia-pal-browser",
89
- "aurelia-event-aggregator",
90
- "aurelia-history-browser"
91
- ]
89
+ "importmap": {
90
+ "imports": {
91
+ "aurelia-framework": "",
92
+ "aurelia-templating-binding": "",
93
+ "aurelia-templating-resources": "",
94
+ "aurelia-pal-browser": "",
95
+ "aurelia-event-aggregator": "",
96
+ "aurelia-history-browser": ""
97
+ }
92
98
  }
93
99
  }
94
100
  ```
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>(root: 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 AureliaConverter {
5
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
11
+ (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
6
12
  }
7
- export declare const fromAurelia: AureliaConverter;
8
- export declare const createAureliaExtension: typeof createExtension;
9
- export {};
13
+ export declare function createAureliaConverter(...params: Parameters<typeof createConverter>): {
14
+ from: AureliaConverter;
15
+ Extension: any;
16
+ };
17
+ declare const fromAurelia: AureliaConverter, AureliaExtension: any;
18
+ export { fromAurelia, AureliaExtension };
package/convert.js CHANGED
@@ -1,11 +1,16 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.createAureliaExtension = exports.fromAurelia = void 0;
4
- var converter_1 = require("./lib/converter");
5
- var extension_1 = require("./lib/extension");
6
- var convert = converter_1.createConverter();
7
- exports.fromAurelia = function (root) { return ({
8
- type: 'html',
9
- component: convert(root)
10
- }); };
11
- exports.createAureliaExtension = extension_1.createExtension;
1
+ import { createConverter } from './esm/converter';
2
+ export function createAureliaConverter() {
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 (root) { return ({
10
+ type: 'html',
11
+ component: convert(root),
12
+ }); };
13
+ return { from: from, Extension: Extension };
14
+ }
15
+ var _a = createAureliaConverter(), fromAurelia = _a.from, AureliaExtension = _a.Extension;
16
+ export { fromAurelia, AureliaExtension };
@@ -0,0 +1,66 @@
1
+ /// <reference types="systemjs" />
2
+ import 'aurelia-templating-binding';
3
+ import 'aurelia-templating-resources';
4
+ import 'aurelia-event-aggregator';
5
+ import 'aurelia-history-browser';
6
+ import { Loader } from 'aurelia-framework';
7
+ export declare class DefaultLoader extends Loader {
8
+ private mapping;
9
+ /**
10
+ * Maps a module id to a source.
11
+ * @param id The module id.
12
+ * @param source The source to map the module to.
13
+ */
14
+ map(id: any, source: any): void;
15
+ /**
16
+ * Normalizes a module id.
17
+ * @param moduleId The module id to normalize.
18
+ * @param relativeTo What the module id should be normalized relative to.
19
+ * @return The normalized module id.
20
+ */
21
+ normalizeSync(moduleId: any, _relativeTo: any): any;
22
+ /**
23
+ * Normalizes a module id.
24
+ * @param moduleId The module id to normalize.
25
+ * @param relativeTo What the module id should be normalized relative to.
26
+ * @return A promise for the normalized module id.
27
+ */
28
+ normalize(moduleId: any, relativeTo: any): Promise<any>;
29
+ /**
30
+ * Loads a module.
31
+ * @param id The module id to normalize.
32
+ * @return A Promise for the loaded module.
33
+ */
34
+ loadModule(id: any): Promise<System.Module>;
35
+ /**
36
+ * Loads a collection of modules.
37
+ * @param ids The set of module ids to load.
38
+ * @return A Promise for an array of loaded modules.
39
+ */
40
+ loadAllModules(ids: any): Promise<any[]>;
41
+ /**
42
+ * Loads a template.
43
+ * @param url The url of the template to load.
44
+ * @return A Promise for a TemplateRegistryEntry containing the template.
45
+ */
46
+ loadTemplate(url: any): Promise<any>;
47
+ /**
48
+ * Loads a text-based resource.
49
+ * @param url The url of the text file to load.
50
+ * @return A Promise for text content.
51
+ */
52
+ loadText(url: any): Promise<string>;
53
+ /**
54
+ * Alters a module id so that it includes a plugin loader.
55
+ * @param url The url of the module to load.
56
+ * @param pluginName The plugin to apply to the module id.
57
+ * @return The plugin-based module id.
58
+ */
59
+ applyPluginToUrl(url: any, pluginName: any): string;
60
+ /**
61
+ * Registers a plugin with the loader.
62
+ * @param pluginName The name of the plugin.
63
+ * @param implementation The plugin implementation.
64
+ */
65
+ addPlugin(_pluginName: any, _implementation: any): void;
66
+ }
@@ -0,0 +1,85 @@
1
+ import 'aurelia-templating-binding';
2
+ import 'aurelia-templating-resources';
3
+ import 'aurelia-event-aggregator';
4
+ import 'aurelia-history-browser';
5
+ import { Loader } from 'aurelia-framework';
6
+ export class DefaultLoader extends Loader {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.mapping = {};
10
+ }
11
+ /**
12
+ * Maps a module id to a source.
13
+ * @param id The module id.
14
+ * @param source The source to map the module to.
15
+ */
16
+ map(id, source) {
17
+ this.mapping[id] = source;
18
+ }
19
+ /**
20
+ * Normalizes a module id.
21
+ * @param moduleId The module id to normalize.
22
+ * @param relativeTo What the module id should be normalized relative to.
23
+ * @return The normalized module id.
24
+ */
25
+ normalizeSync(moduleId, _relativeTo) {
26
+ return moduleId;
27
+ }
28
+ /**
29
+ * Normalizes a module id.
30
+ * @param moduleId The module id to normalize.
31
+ * @param relativeTo What the module id should be normalized relative to.
32
+ * @return A promise for the normalized module id.
33
+ */
34
+ normalize(moduleId, relativeTo) {
35
+ return Promise.resolve(this.normalizeSync(moduleId, relativeTo));
36
+ }
37
+ /**
38
+ * Loads a module.
39
+ * @param id The module id to normalize.
40
+ * @return A Promise for the loaded module.
41
+ */
42
+ loadModule(id) {
43
+ return System.import(id);
44
+ }
45
+ /**
46
+ * Loads a collection of modules.
47
+ * @param ids The set of module ids to load.
48
+ * @return A Promise for an array of loaded modules.
49
+ */
50
+ loadAllModules(ids) {
51
+ return Promise.all(ids.map((id) => this.loadModule(id)));
52
+ }
53
+ /**
54
+ * Loads a template.
55
+ * @param url The url of the template to load.
56
+ * @return A Promise for a TemplateRegistryEntry containing the template.
57
+ */
58
+ loadTemplate(url) {
59
+ return fetch(url).then((res) => res.json());
60
+ }
61
+ /**
62
+ * Loads a text-based resource.
63
+ * @param url The url of the text file to load.
64
+ * @return A Promise for text content.
65
+ */
66
+ loadText(url) {
67
+ return fetch(url).then((res) => res.text());
68
+ }
69
+ /**
70
+ * Alters a module id so that it includes a plugin loader.
71
+ * @param url The url of the module to load.
72
+ * @param pluginName The plugin to apply to the module id.
73
+ * @return The plugin-based module id.
74
+ */
75
+ applyPluginToUrl(url, pluginName) {
76
+ return `${url}?plugin=${pluginName}`;
77
+ }
78
+ /**
79
+ * Registers a plugin with the loader.
80
+ * @param pluginName The name of the plugin.
81
+ * @param implementation The plugin implementation.
82
+ */
83
+ addPlugin(_pluginName, _implementation) { }
84
+ }
85
+ //# sourceMappingURL=DefaultLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultLoader.js","sourceRoot":"","sources":["../src/DefaultLoader.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,8BAA8B,CAAC;AACtC,OAAO,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,OAAO,aAAc,SAAQ,MAAM;IAAzC;;QACU,YAAO,GAA2B,EAAE,CAAC;IAmF/C,CAAC;IAjFC;;;;OAIG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM;QACZ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,WAAW;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,UAAU;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,GAAG;QAChB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,GAAG;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,GAAG;QACV,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,EAAE,UAAU;QAC9B,OAAO,GAAG,GAAG,WAAW,UAAU,EAAE,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,eAAe,IAAG,CAAC;CAC3C"}
@@ -0,0 +1,13 @@
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { AureliaModule } from './types';
3
+ export interface AureliaConverterOptions {
4
+ /**
5
+ * Defines the name of the root element.
6
+ * @default piral-slot
7
+ */
8
+ rootName?: string;
9
+ }
10
+ export declare function createConverter(config?: AureliaConverterOptions): {
11
+ <TProps extends BaseComponentProps>(root: any): ForeignComponent<TProps>;
12
+ Extension: any;
13
+ };
@@ -0,0 +1,30 @@
1
+ import { Aurelia } from 'aurelia-framework';
2
+ import { initialize } from 'aurelia-pal-browser';
3
+ import { DefaultLoader } from './DefaultLoader';
4
+ import { createExtension } from './extension';
5
+ export function createConverter(config = {}) {
6
+ const { rootName = 'piral-slot' } = config;
7
+ initialize();
8
+ const Extension = createExtension(rootName);
9
+ const convert = (root) => ({
10
+ mount(el, props, ctx, locals) {
11
+ const aurelia = new Aurelia(new DefaultLoader());
12
+ aurelia.use.eventAggregator().history().defaultBindingLanguage().globalResources([Extension]).defaultResources();
13
+ aurelia.container.registerInstance('props', props);
14
+ aurelia.container.registerInstance('ctx', ctx);
15
+ aurelia.container.registerInstance('piral', props.piral);
16
+ aurelia.start().then(() => aurelia.setRoot(root, el));
17
+ locals.aurelia = aurelia;
18
+ },
19
+ update(el, props, ctx, locals) {
20
+ locals.aurelia.container.registerInstance('props', props);
21
+ locals.aurelia.container.registerInstance('ctx', ctx);
22
+ },
23
+ unmount(el, locals) {
24
+ locals.aurelia = undefined;
25
+ },
26
+ });
27
+ convert.Extension = Extension;
28
+ return convert;
29
+ }
30
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAe9C,MAAM,UAAU,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAE3C,UAAU,EAAE,CAAC;IAEb,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAqB;YACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;YAEjD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,CAAC,sBAAsB,EAAE,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;YAEjH,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACnD,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/C,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAEzD,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAqB;YAC1C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1D,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAqB;YAC/B,MAAM,CAAC,OAAO,GAAG,SAAS,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 { AureliaConverterOptions } from './converter';
3
+ import type { PiletAureliaApi } from './types';
4
+ /**
5
+ * Available configuration options for the Aurelia plugin.
6
+ */
7
+ export interface AureliaConfig extends AureliaConverterOptions {
8
+ }
9
+ /**
10
+ * Creates new Pilet API extensions for integrating Aurelia.
11
+ */
12
+ export declare function createAureliaApi(config?: AureliaConfig): PiralPlugin<PiletAureliaApi>;
package/esm/create.js ADDED
@@ -0,0 +1,20 @@
1
+ import { createConverter } from './converter';
2
+ /**
3
+ * Creates new Pilet API extensions for integrating Aurelia.
4
+ */
5
+ export function createAureliaApi(config = {}) {
6
+ return (context) => {
7
+ const convert = createConverter(config);
8
+ context.converters.aurelia = ({ root }) => convert(root);
9
+ return {
10
+ fromAurelia(root) {
11
+ return {
12
+ type: 'aurelia',
13
+ root,
14
+ };
15
+ },
16
+ AureliaExtension: convert.Extension,
17
+ };
18
+ };
19
+ }
20
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA2B,MAAM,aAAa,CAAC;AAQvE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAwB,EAAE;IACzD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO;YACL,WAAW,CAAC,IAAI;gBACd,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ExtensionSlotProps } from 'piral-core';
2
+ import type { AureliaModule } from './types';
3
+ export declare function createExtension(rootName: string): AureliaModule<ExtensionSlotProps>;
@@ -0,0 +1,44 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { inlineView, customElement, bindable, inject } from 'aurelia-framework';
3
+ export function createExtension(rootName) {
4
+ let AureliaExtension = class AureliaExtension {
5
+ constructor(piral) {
6
+ this.piral = piral;
7
+ }
8
+ attached() {
9
+ this.piral.renderHtmlExtension(this.host, {
10
+ name: this.name,
11
+ render: this.render,
12
+ empty: this.empty,
13
+ params: this.params,
14
+ });
15
+ }
16
+ };
17
+ __decorate([
18
+ bindable(),
19
+ __metadata("design:type", String)
20
+ ], AureliaExtension.prototype, "name", void 0);
21
+ __decorate([
22
+ bindable(),
23
+ __metadata("design:type", Object)
24
+ ], AureliaExtension.prototype, "render", void 0);
25
+ __decorate([
26
+ bindable(),
27
+ __metadata("design:type", Object)
28
+ ], AureliaExtension.prototype, "empty", void 0);
29
+ __decorate([
30
+ bindable(),
31
+ __metadata("design:type", Object)
32
+ ], AureliaExtension.prototype, "params", void 0);
33
+ AureliaExtension = __decorate([
34
+ inject('piral'),
35
+ customElement('extension-component'),
36
+ inlineView(`
37
+ <template>
38
+ <${rootName} ref="host"></${rootName}>
39
+ <template>`),
40
+ __metadata("design:paramtypes", [Object])
41
+ ], AureliaExtension);
42
+ return AureliaExtension;
43
+ }
44
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAMM,gBAAgB,GANtB,MAMM,gBAAgB;QAOpB,YAAoB,KAAe;YAAf,UAAK,GAAL,KAAK,CAAU;QAAG,CAAC;QAEvC,QAAQ;YACN,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE;gBACxC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;QACL,CAAC;KACF,CAAA;IAfqB;QAAnB,QAAQ,EAAE;;kDAAsB;IACb;QAAnB,QAAQ,EAAE;;oDAAqB;IACZ;QAAnB,QAAQ,EAAE;;mDAAoB;IACX;QAAnB,QAAQ,EAAE;;oDAAqB;IAL5B,gBAAgB;QANrB,MAAM,CAAC,OAAO,CAAC;QACf,aAAa,CAAC,qBAAqB,CAAC;QACpC,UAAU,CAAC;;SAEL,QAAQ,iBAAiB,QAAQ;eAC3B,CAAC;;OACR,gBAAgB,CAiBrB;IAED,OAAO,gBAAgB,CAAC;AAC1B,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/types.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
+ declare module 'piral-core/lib/types/custom' {
3
+ interface PiletCustomApi extends PiletAureliaApi {
4
+ }
5
+ interface PiralCustomComponentConverters<TProps> {
6
+ aurelia(component: AureliaComponent<TProps>): ForeignComponent<TProps>;
7
+ }
8
+ }
9
+ export type AureliaModule<TProps> = any;
10
+ export interface AureliaComponent<TProps> {
11
+ /**
12
+ * The component root.
13
+ */
14
+ root: AureliaModule<TProps>;
15
+ /**
16
+ * The type of the Aurelia component.
17
+ */
18
+ type: 'aurelia';
19
+ }
20
+ /**
21
+ * Defines the provided set of Aurelia Pilet API extensions.
22
+ */
23
+ export interface PiletAureliaApi {
24
+ /**
25
+ * Wraps an Aurelia component for use in Piral.
26
+ * @param component The component root.
27
+ * @returns The Piral Aurelia component.
28
+ */
29
+ fromAurelia<TProps>(component: AureliaModule<TProps>): AureliaComponent<TProps>;
30
+ /**
31
+ * Aurelia component for displaying extensions of the given name.
32
+ */
33
+ AureliaExtension: AureliaModule<ExtensionSlotProps>;
34
+ }
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,4 @@
1
+ /// <reference types="systemjs" />
1
2
  import 'aurelia-templating-binding';
2
3
  import 'aurelia-templating-resources';
3
4
  import 'aurelia-event-aggregator';
@@ -30,13 +31,13 @@ export declare class DefaultLoader extends Loader {
30
31
  * @param id The module id to normalize.
31
32
  * @return A Promise for the loaded module.
32
33
  */
33
- loadModule(id: any): Promise<any>;
34
+ loadModule(id: any): Promise<System.Module>;
34
35
  /**
35
36
  * Loads a collection of modules.
36
37
  * @param ids The set of module ids to load.
37
38
  * @return A Promise for an array of loaded modules.
38
39
  */
39
- loadAllModules(ids: any): Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
40
+ loadAllModules(ids: any): Promise<any[]>;
40
41
  /**
41
42
  * Loads a template.
42
43
  * @param url The url of the template to load.
@@ -1,94 +1,89 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultLoader = void 0;
4
- var tslib_1 = require("tslib");
5
4
  require("aurelia-templating-binding");
6
5
  require("aurelia-templating-resources");
7
6
  require("aurelia-event-aggregator");
8
7
  require("aurelia-history-browser");
9
- var aurelia_framework_1 = require("aurelia-framework");
10
- var DefaultLoader = /** @class */ (function (_super) {
11
- tslib_1.__extends(DefaultLoader, _super);
12
- function DefaultLoader() {
13
- var _this = _super !== null && _super.apply(this, arguments) || this;
14
- _this.mapping = {};
15
- return _this;
8
+ const aurelia_framework_1 = require("aurelia-framework");
9
+ class DefaultLoader extends aurelia_framework_1.Loader {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.mapping = {};
16
13
  }
17
14
  /**
18
15
  * Maps a module id to a source.
19
16
  * @param id The module id.
20
17
  * @param source The source to map the module to.
21
18
  */
22
- DefaultLoader.prototype.map = function (id, source) {
19
+ map(id, source) {
23
20
  this.mapping[id] = source;
24
- };
21
+ }
25
22
  /**
26
23
  * Normalizes a module id.
27
24
  * @param moduleId The module id to normalize.
28
25
  * @param relativeTo What the module id should be normalized relative to.
29
26
  * @return The normalized module id.
30
27
  */
31
- DefaultLoader.prototype.normalizeSync = function (moduleId, _relativeTo) {
28
+ normalizeSync(moduleId, _relativeTo) {
32
29
  return moduleId;
33
- };
30
+ }
34
31
  /**
35
32
  * Normalizes a module id.
36
33
  * @param moduleId The module id to normalize.
37
34
  * @param relativeTo What the module id should be normalized relative to.
38
35
  * @return A promise for the normalized module id.
39
36
  */
40
- DefaultLoader.prototype.normalize = function (moduleId, relativeTo) {
37
+ normalize(moduleId, relativeTo) {
41
38
  return Promise.resolve(this.normalizeSync(moduleId, relativeTo));
42
- };
39
+ }
43
40
  /**
44
41
  * Loads a module.
45
42
  * @param id The module id to normalize.
46
43
  * @return A Promise for the loaded module.
47
44
  */
48
- DefaultLoader.prototype.loadModule = function (id) {
49
- return Promise.resolve(require(id));
50
- };
45
+ loadModule(id) {
46
+ return System.import(id);
47
+ }
51
48
  /**
52
49
  * Loads a collection of modules.
53
50
  * @param ids The set of module ids to load.
54
51
  * @return A Promise for an array of loaded modules.
55
52
  */
56
- DefaultLoader.prototype.loadAllModules = function (ids) {
57
- var _this = this;
58
- return Promise.all(ids.map(function (id) { return _this.loadModule(id); }));
59
- };
53
+ loadAllModules(ids) {
54
+ return Promise.all(ids.map((id) => this.loadModule(id)));
55
+ }
60
56
  /**
61
57
  * Loads a template.
62
58
  * @param url The url of the template to load.
63
59
  * @return A Promise for a TemplateRegistryEntry containing the template.
64
60
  */
65
- DefaultLoader.prototype.loadTemplate = function (url) {
66
- return fetch(url).then(function (res) { return res.json(); });
67
- };
61
+ loadTemplate(url) {
62
+ return fetch(url).then((res) => res.json());
63
+ }
68
64
  /**
69
65
  * Loads a text-based resource.
70
66
  * @param url The url of the text file to load.
71
67
  * @return A Promise for text content.
72
68
  */
73
- DefaultLoader.prototype.loadText = function (url) {
74
- return fetch(url).then(function (res) { return res.text(); });
75
- };
69
+ loadText(url) {
70
+ return fetch(url).then((res) => res.text());
71
+ }
76
72
  /**
77
73
  * Alters a module id so that it includes a plugin loader.
78
74
  * @param url The url of the module to load.
79
75
  * @param pluginName The plugin to apply to the module id.
80
76
  * @return The plugin-based module id.
81
77
  */
82
- DefaultLoader.prototype.applyPluginToUrl = function (url, pluginName) {
83
- return url + "?plugin=" + pluginName;
84
- };
78
+ applyPluginToUrl(url, pluginName) {
79
+ return `${url}?plugin=${pluginName}`;
80
+ }
85
81
  /**
86
82
  * Registers a plugin with the loader.
87
83
  * @param pluginName The name of the plugin.
88
84
  * @param implementation The plugin implementation.
89
85
  */
90
- DefaultLoader.prototype.addPlugin = function (_pluginName, _implementation) { };
91
- return DefaultLoader;
92
- }(aurelia_framework_1.Loader));
86
+ addPlugin(_pluginName, _implementation) { }
87
+ }
93
88
  exports.DefaultLoader = DefaultLoader;
94
89
  //# sourceMappingURL=DefaultLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultLoader.js","sourceRoot":"","sources":["../src/DefaultLoader.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,wCAAsC;AACtC,oCAAkC;AAClC,mCAAiC;AACjC,uDAA2C;AAE3C;IAAmC,yCAAM;IAAzC;QAAA,qEAoFC;QAnFS,aAAO,GAA2B,EAAE,CAAC;;IAmF/C,CAAC;IAjFC;;;;OAIG;IACH,2BAAG,GAAH,UAAI,EAAE,EAAE,MAAM;QACZ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,qCAAa,GAAb,UAAc,QAAQ,EAAE,WAAW;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,iCAAS,GAAT,UAAU,QAAQ,EAAE,UAAU;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,kCAAU,GAAV,UAAW,EAAE;QACX,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,sCAAc,GAAd,UAAe,GAAG;QAAlB,iBAEC;QADC,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,KAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAnB,CAAmB,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACH,oCAAY,GAAZ,UAAa,GAAG;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,gCAAQ,GAAR,UAAS,GAAG;QACV,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,wCAAgB,GAAhB,UAAiB,GAAG,EAAE,UAAU;QAC9B,OAAU,GAAG,gBAAW,UAAY,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,iCAAS,GAAT,UAAU,WAAW,EAAE,eAAe,IAAG,CAAC;IAC5C,oBAAC;AAAD,CAAC,AApFD,CAAmC,0BAAM,GAoFxC;AApFY,sCAAa"}
1
+ {"version":3,"file":"DefaultLoader.js","sourceRoot":"","sources":["../src/DefaultLoader.ts"],"names":[],"mappings":";;;AAAA,sCAAoC;AACpC,wCAAsC;AACtC,oCAAkC;AAClC,mCAAiC;AACjC,yDAA2C;AAE3C,MAAa,aAAc,SAAQ,0BAAM;IAAzC;;QACU,YAAO,GAA2B,EAAE,CAAC;IAmF/C,CAAC;IAjFC;;;;OAIG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM;QACZ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,WAAW;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,UAAU;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,GAAG;QAChB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,GAAG;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,GAAG;QACV,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,EAAE,UAAU;QAC9B,OAAO,GAAG,GAAG,WAAW,UAAU,EAAE,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,eAAe,IAAG,CAAC;CAC3C;AApFD,sCAoFC"}
@@ -1,3 +1,13 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- import { AureliaModule } from './types';
3
- export declare function createConverter(): <TProps extends BaseComponentProps>(root: any) => ForeignComponent<TProps>;
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { AureliaModule } from './types';
3
+ export interface AureliaConverterOptions {
4
+ /**
5
+ * Defines the name of the root element.
6
+ * @default piral-slot
7
+ */
8
+ rootName?: string;
9
+ }
10
+ export declare function createConverter(config?: AureliaConverterOptions): {
11
+ <TProps extends BaseComponentProps>(root: any): ForeignComponent<TProps>;
12
+ Extension: any;
13
+ };
package/lib/converter.js CHANGED
@@ -1,36 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConverter = void 0;
4
- var aurelia_framework_1 = require("aurelia-framework");
5
- var aurelia_pal_browser_1 = require("aurelia-pal-browser");
6
- var DefaultLoader_1 = require("./DefaultLoader");
7
- function createConverter() {
8
- aurelia_pal_browser_1.initialize();
9
- var convert = function (root) {
10
- var aurelia = undefined;
11
- return {
12
- mount: function (el, props, ctx) {
13
- var piral = props.piral;
14
- aurelia = new aurelia_framework_1.Aurelia(new DefaultLoader_1.DefaultLoader());
15
- aurelia.use
16
- .eventAggregator()
17
- .history()
18
- .defaultBindingLanguage()
19
- .globalResources([piral.AureliaExtension])
20
- .defaultResources();
21
- aurelia.container.registerInstance('props', props);
22
- aurelia.container.registerInstance('ctx', ctx);
23
- aurelia.start().then(function () { return aurelia.setRoot(root, el); });
24
- },
25
- update: function (_, props, ctx) {
26
- aurelia.container.registerInstance('props', props);
27
- aurelia.container.registerInstance('ctx', ctx);
28
- },
29
- unmount: function () {
30
- aurelia = undefined;
31
- },
32
- };
33
- };
4
+ const aurelia_framework_1 = require("aurelia-framework");
5
+ const aurelia_pal_browser_1 = require("aurelia-pal-browser");
6
+ const DefaultLoader_1 = require("./DefaultLoader");
7
+ const extension_1 = require("./extension");
8
+ function createConverter(config = {}) {
9
+ const { rootName = 'piral-slot' } = config;
10
+ (0, aurelia_pal_browser_1.initialize)();
11
+ const Extension = (0, extension_1.createExtension)(rootName);
12
+ const convert = (root) => ({
13
+ mount(el, props, ctx, locals) {
14
+ const aurelia = new aurelia_framework_1.Aurelia(new DefaultLoader_1.DefaultLoader());
15
+ aurelia.use.eventAggregator().history().defaultBindingLanguage().globalResources([Extension]).defaultResources();
16
+ aurelia.container.registerInstance('props', props);
17
+ aurelia.container.registerInstance('ctx', ctx);
18
+ aurelia.container.registerInstance('piral', props.piral);
19
+ aurelia.start().then(() => aurelia.setRoot(root, el));
20
+ locals.aurelia = aurelia;
21
+ },
22
+ update(el, props, ctx, locals) {
23
+ locals.aurelia.container.registerInstance('props', props);
24
+ locals.aurelia.container.registerInstance('ctx', ctx);
25
+ },
26
+ unmount(el, locals) {
27
+ locals.aurelia = undefined;
28
+ },
29
+ });
30
+ convert.Extension = Extension;
34
31
  return convert;
35
32
  }
36
33
  exports.createConverter = createConverter;
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,uDAA4C;AAC5C,2DAAiD;AACjD,iDAAgD;AAGhD,SAAgB,eAAe;IAC7B,gCAAU,EAAE,CAAC;IACb,IAAM,OAAO,GAAG,UAAoC,IAA2B;QAC7E,IAAI,OAAO,GAAY,SAAS,CAAC;QAEjC,OAAO;YACL,KAAK,YAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBACV,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;gBAExB,OAAO,GAAG,IAAI,2BAAO,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;gBAE3C,OAAO,CAAC,GAAG;qBACR,eAAe,EAAE;qBACjB,OAAO,EAAE;qBACT,sBAAsB,EAAE;qBACxB,eAAe,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;qBACzC,gBAAgB,EAAE,CAAC;gBAEtB,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACnD,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBAE/C,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAzB,CAAyB,CAAC,CAAC;YACxD,CAAC;YACD,MAAM,YAAC,CAAC,EAAE,KAAK,EAAE,GAAG;gBAClB,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACnD,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC;YACD,OAAO;gBACL,OAAO,GAAG,SAAS,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAjCD,0CAiCC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,yDAA4C;AAC5C,6DAAiD;AACjD,mDAAgD;AAChD,2CAA8C;AAe9C,SAAgB,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAE3C,IAAA,gCAAU,GAAE,CAAC;IAEb,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAqB;YACzC,MAAM,OAAO,GAAG,IAAI,2BAAO,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;YAEjD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,CAAC,sBAAsB,EAAE,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;YAEjH,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACnD,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/C,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAEzD,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAqB;YAC1C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1D,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAqB;YAC/B,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;QAC7B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA9BD,0CA8BC"}
package/lib/create.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
+ import { AureliaConverterOptions } from './converter';
2
3
  import type { PiletAureliaApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Aurelia plugin.
5
6
  */
6
- export interface AureliaConfig {
7
- /**
8
- * Defines the name of the root element.
9
- * @default span
10
- */
11
- rootName?: string;
7
+ export interface AureliaConfig extends AureliaConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates new Pilet API extensions for integrating Aurelia.
package/lib/create.js CHANGED
@@ -1,31 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAureliaApi = void 0;
4
- var extension_1 = require("./extension");
5
- var converter_1 = require("./converter");
4
+ const converter_1 = require("./converter");
6
5
  /**
7
6
  * Creates new Pilet API extensions for integrating Aurelia.
8
7
  */
9
- function createAureliaApi(config) {
10
- if (config === void 0) { config = {}; }
11
- var rootName = config.rootName;
12
- return function (context) {
13
- var convert = converter_1.createConverter();
14
- context.converters.aurelia = function (_a) {
15
- var root = _a.root;
16
- return convert(root);
17
- };
18
- return function (api) {
19
- var AureliaExtension = extension_1.createExtension(api, rootName);
20
- return {
21
- fromAurelia: function (root) {
22
- return {
23
- type: 'aurelia',
24
- root: root,
25
- };
26
- },
27
- AureliaExtension: AureliaExtension,
28
- };
8
+ function createAureliaApi(config = {}) {
9
+ return (context) => {
10
+ const convert = (0, converter_1.createConverter)(config);
11
+ context.converters.aurelia = ({ root }) => convert(root);
12
+ return {
13
+ fromAurelia(root) {
14
+ return {
15
+ type: 'aurelia',
16
+ root,
17
+ };
18
+ },
19
+ AureliaExtension: convert.Extension,
29
20
  };
30
21
  };
31
22
  }
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAC9C,yCAA8C;AAc9C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,MAA0B;IAA1B,uBAAA,EAAA,WAA0B;IACjD,IAAA,QAAQ,GAAK,MAAM,SAAX,CAAY;IAE5B,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,2BAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,UAAC,EAAQ;gBAAN,IAAI,UAAA;YAAO,OAAA,OAAO,CAAC,IAAI,CAAC;QAAb,CAAa,CAAC;QAEzD,OAAO,UAAC,GAAG;YACT,IAAM,gBAAgB,GAAG,2BAAe,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAExD,OAAO;gBACL,WAAW,YAAC,IAAI;oBACd,OAAO;wBACL,IAAI,EAAE,SAAS;wBACf,IAAI,MAAA;qBACL,CAAC;gBACJ,CAAC;gBACD,gBAAgB,kBAAA;aACjB,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArBD,4CAqBC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAQvE;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAAwB,EAAE;IACzD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO;YACL,WAAW,CAAC,IAAI;gBACd,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,4CAeC"}
@@ -1,3 +1,3 @@
1
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
1
+ import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { AureliaModule } from './types';
3
- export declare function createExtension(api: PiletApi, rootName?: string): AureliaModule<ExtensionSlotProps>;
3
+ export declare function createExtension(rootName: string): AureliaModule<ExtensionSlotProps>;
package/lib/extension.js CHANGED
@@ -1,43 +1,47 @@
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
- var aurelia_framework_1 = require("aurelia-framework");
6
- function createExtension(api, rootName) {
7
- if (rootName === void 0) { rootName = 'span'; }
8
- var AureliaExtension = /** @class */ (function () {
9
- function AureliaExtension() {
4
+ const tslib_1 = require("tslib");
5
+ const aurelia_framework_1 = require("aurelia-framework");
6
+ function createExtension(rootName) {
7
+ let AureliaExtension = class AureliaExtension {
8
+ constructor(piral) {
9
+ this.piral = piral;
10
10
  }
11
- AureliaExtension.prototype.attached = function () {
12
- api.renderHtmlExtension(this.host, {
11
+ attached() {
12
+ this.piral.renderHtmlExtension(this.host, {
13
13
  name: this.name,
14
14
  render: this.render,
15
15
  empty: this.empty,
16
16
  params: this.params,
17
17
  });
18
- };
19
- tslib_1.__decorate([
20
- aurelia_framework_1.bindable(),
21
- tslib_1.__metadata("design:type", String)
22
- ], AureliaExtension.prototype, "name", void 0);
23
- tslib_1.__decorate([
24
- aurelia_framework_1.bindable(),
25
- tslib_1.__metadata("design:type", Object)
26
- ], AureliaExtension.prototype, "render", void 0);
27
- tslib_1.__decorate([
28
- aurelia_framework_1.bindable(),
29
- tslib_1.__metadata("design:type", Object)
30
- ], AureliaExtension.prototype, "empty", void 0);
31
- tslib_1.__decorate([
32
- aurelia_framework_1.bindable(),
33
- tslib_1.__metadata("design:type", Object)
34
- ], AureliaExtension.prototype, "params", void 0);
35
- AureliaExtension = tslib_1.__decorate([
36
- aurelia_framework_1.customElement('extension-component'),
37
- aurelia_framework_1.inlineView("\n <template>\n <" + rootName + " ref=\"host\"></" + rootName + ">\n <template>")
38
- ], AureliaExtension);
39
- return AureliaExtension;
40
- }());
18
+ }
19
+ };
20
+ tslib_1.__decorate([
21
+ (0, aurelia_framework_1.bindable)(),
22
+ tslib_1.__metadata("design:type", String)
23
+ ], AureliaExtension.prototype, "name", void 0);
24
+ tslib_1.__decorate([
25
+ (0, aurelia_framework_1.bindable)(),
26
+ tslib_1.__metadata("design:type", Object)
27
+ ], AureliaExtension.prototype, "render", void 0);
28
+ tslib_1.__decorate([
29
+ (0, aurelia_framework_1.bindable)(),
30
+ tslib_1.__metadata("design:type", Object)
31
+ ], AureliaExtension.prototype, "empty", void 0);
32
+ tslib_1.__decorate([
33
+ (0, aurelia_framework_1.bindable)(),
34
+ tslib_1.__metadata("design:type", Object)
35
+ ], AureliaExtension.prototype, "params", void 0);
36
+ AureliaExtension = tslib_1.__decorate([
37
+ (0, aurelia_framework_1.inject)('piral'),
38
+ (0, aurelia_framework_1.customElement)('extension-component'),
39
+ (0, aurelia_framework_1.inlineView)(`
40
+ <template>
41
+ <${rootName} ref="host"></${rootName}>
42
+ <template>`),
43
+ tslib_1.__metadata("design:paramtypes", [Object])
44
+ ], AureliaExtension);
41
45
  return AureliaExtension;
42
46
  }
43
47
  exports.createExtension = createExtension;
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;AAAA,uDAAwE;AAIxE,SAAgB,eAAe,CAAC,GAAa,EAAE,QAAiB;IAAjB,yBAAA,EAAA,iBAAiB;IAM9D;QAAA;QAeA,CAAC;QARC,mCAAQ,GAAR;YACE,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE;gBACjC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;QACL,CAAC;QAZW;YAAX,4BAAQ,EAAE;;sDAAsB;QACrB;YAAX,4BAAQ,EAAE;;wDAAqB;QACpB;YAAX,4BAAQ,EAAE;;uDAAoB;QACnB;YAAX,4BAAQ,EAAE;;wDAAqB;QAL5B,gBAAgB;YALrB,iCAAa,CAAC,qBAAqB,CAAC;YACpC,8BAAU,CAAC,8BAEL,QAAQ,wBAAiB,QAAQ,sBAC3B,CAAC;WACR,gBAAgB,CAerB;QAAD,uBAAC;KAAA,AAfD,IAeC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAxBD,0CAwBC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;AAAA,yDAAgF;AAIhF,SAAgB,eAAe,CAAC,QAAgB;IAC9C,IAMM,gBAAgB,GANtB,MAMM,gBAAgB;QAOpB,YAAoB,KAAe;YAAf,UAAK,GAAL,KAAK,CAAU;QAAG,CAAC;QAEvC,QAAQ;YACN,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE;gBACxC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;QACL,CAAC;KACF,CAAA;IAfqB;QAAnB,IAAA,4BAAQ,GAAE;;kDAAsB;IACb;QAAnB,IAAA,4BAAQ,GAAE;;oDAAqB;IACZ;QAAnB,IAAA,4BAAQ,GAAE;;mDAAoB;IACX;QAAnB,IAAA,4BAAQ,GAAE;;oDAAqB;IAL5B,gBAAgB;QANrB,IAAA,0BAAM,EAAC,OAAO,CAAC;QACf,IAAA,iCAAa,EAAC,qBAAqB,CAAC;QACpC,IAAA,8BAAU,EAAC;;SAEL,QAAQ,iBAAiB,QAAQ;eAC3B,CAAC;;OACR,gBAAgB,CAiBrB;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA3BD,0CA2BC"}
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/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
2
  declare module 'piral-core/lib/types/custom' {
3
3
  interface PiletCustomApi extends PiletAureliaApi {
4
4
  }
@@ -6,7 +6,7 @@ declare module 'piral-core/lib/types/custom' {
6
6
  aurelia(component: AureliaComponent<TProps>): ForeignComponent<TProps>;
7
7
  }
8
8
  }
9
- export declare type AureliaModule<TProps> = any;
9
+ export type AureliaModule<TProps> = any;
10
10
  export interface AureliaComponent<TProps> {
11
11
  /**
12
12
  * The component root.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-aurelia",
3
- "version": "1.0.0-pre.2093",
3
+ "version": "1.0.1-beta.5640",
4
4
  "description": "Plugin for integrating Aurelia 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,27 +55,22 @@
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-aurelia.json src --exclude \"src/**/*.test.*\"",
39
64
  "test": "echo \"Error: run tests from root\" && exit 1"
40
65
  },
41
66
  "devDependencies": {
42
67
  "aurelia-event-aggregator": "1.0.3",
43
- "aurelia-framework": "1.3.1",
68
+ "aurelia-framework": "1.4.1",
44
69
  "aurelia-history-browser": "1.4.0",
45
70
  "aurelia-pal-browser": "1.8.1",
46
71
  "aurelia-templating-binding": "1.5.3",
47
- "aurelia-templating-resources": "1.12.0",
48
- "piral-core": "^1.0.0-pre.2093"
49
- },
50
- "peerDependencies": {
51
- "aurelia-event-aggregator": "^1.0.0",
52
- "aurelia-framework": "^1.0.0",
53
- "aurelia-history-browser": "^1.0.0",
54
- "aurelia-pal-browser": "^1.0.0",
55
- "aurelia-templating-binding": "^1.0.0",
56
- "aurelia-templating-resources": "^1.0.0",
57
- "piral-core": "1.x"
72
+ "aurelia-templating-resources": "1.13.1",
73
+ "piral-core": "1.0.1-beta.5640"
58
74
  },
59
- "gitHead": "fe44f381fb31094a5f8873817c4a5f3c54870b44"
75
+ "gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
60
76
  }
@@ -42,7 +42,7 @@ export class DefaultLoader extends Loader {
42
42
  * @return A Promise for the loaded module.
43
43
  */
44
44
  loadModule(id) {
45
- return Promise.resolve(require(id));
45
+ return System.import(id);
46
46
  }
47
47
 
48
48
  /**
package/src/converter.ts CHANGED
@@ -1,40 +1,50 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
2
  import { Aurelia } from 'aurelia-framework';
3
3
  import { initialize } from 'aurelia-pal-browser';
4
4
  import { DefaultLoader } from './DefaultLoader';
5
- import { AureliaModule } from './types';
5
+ import { createExtension } from './extension';
6
+ import type { AureliaModule } from './types';
7
+
8
+ export interface AureliaConverterOptions {
9
+ /**
10
+ * Defines the name of the root element.
11
+ * @default piral-slot
12
+ */
13
+ rootName?: string;
14
+ }
15
+
16
+ interface AureliaLocals {
17
+ aurelia: Aurelia;
18
+ }
19
+
20
+ export function createConverter(config: AureliaConverterOptions = {}) {
21
+ const { rootName = 'piral-slot' } = config;
6
22
 
7
- export function createConverter() {
8
23
  initialize();
9
- const convert = <TProps extends BaseComponentProps>(root: AureliaModule<TProps>): ForeignComponent<TProps> => {
10
- let aurelia: Aurelia = undefined;
11
-
12
- return {
13
- mount(el, props, ctx) {
14
- const { piral } = props;
15
-
16
- aurelia = new Aurelia(new DefaultLoader());
17
-
18
- aurelia.use
19
- .eventAggregator()
20
- .history()
21
- .defaultBindingLanguage()
22
- .globalResources([piral.AureliaExtension])
23
- .defaultResources();
24
-
25
- aurelia.container.registerInstance('props', props);
26
- aurelia.container.registerInstance('ctx', ctx);
27
-
28
- aurelia.start().then(() => aurelia.setRoot(root, el));
29
- },
30
- update(_, props, ctx) {
31
- aurelia.container.registerInstance('props', props);
32
- aurelia.container.registerInstance('ctx', ctx);
33
- },
34
- unmount() {
35
- aurelia = undefined;
36
- },
37
- };
38
- };
24
+
25
+ const Extension = createExtension(rootName);
26
+
27
+ const convert = <TProps extends BaseComponentProps>(root: AureliaModule<TProps>): ForeignComponent<TProps> => ({
28
+ mount(el, props, ctx, locals: AureliaLocals) {
29
+ const aurelia = new Aurelia(new DefaultLoader());
30
+
31
+ aurelia.use.eventAggregator().history().defaultBindingLanguage().globalResources([Extension]).defaultResources();
32
+
33
+ aurelia.container.registerInstance('props', props);
34
+ aurelia.container.registerInstance('ctx', ctx);
35
+ aurelia.container.registerInstance('piral', props.piral);
36
+
37
+ aurelia.start().then(() => aurelia.setRoot(root, el));
38
+ locals.aurelia = aurelia;
39
+ },
40
+ update(el, props, ctx, locals: AureliaLocals) {
41
+ locals.aurelia.container.registerInstance('props', props);
42
+ locals.aurelia.container.registerInstance('ctx', ctx);
43
+ },
44
+ unmount(el, locals: AureliaLocals) {
45
+ locals.aurelia = undefined;
46
+ },
47
+ });
48
+ convert.Extension = Extension;
39
49
  return convert;
40
50
  }
package/src/create.ts CHANGED
@@ -1,41 +1,28 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
- import { createExtension } from './extension';
3
- import { createConverter } from './converter';
2
+ import { createConverter, AureliaConverterOptions } from './converter';
4
3
  import type { PiletAureliaApi } from './types';
5
4
 
6
5
  /**
7
6
  * Available configuration options for the Aurelia plugin.
8
7
  */
9
- export interface AureliaConfig {
10
- /**
11
- * Defines the name of the root element.
12
- * @default span
13
- */
14
- rootName?: string;
15
- }
8
+ export interface AureliaConfig extends AureliaConverterOptions {}
16
9
 
17
10
  /**
18
11
  * Creates new Pilet API extensions for integrating Aurelia.
19
12
  */
20
13
  export function createAureliaApi(config: AureliaConfig = {}): PiralPlugin<PiletAureliaApi> {
21
- const { rootName } = config;
22
-
23
14
  return (context) => {
24
- const convert = createConverter();
15
+ const convert = createConverter(config);
25
16
  context.converters.aurelia = ({ root }) => convert(root);
26
17
 
27
- return (api) => {
28
- const AureliaExtension = createExtension(api, rootName);
29
-
30
- return {
31
- fromAurelia(root) {
32
- return {
33
- type: 'aurelia',
34
- root,
35
- };
36
- },
37
- AureliaExtension,
38
- };
18
+ return {
19
+ fromAurelia(root) {
20
+ return {
21
+ type: 'aurelia',
22
+ root,
23
+ };
24
+ },
25
+ AureliaExtension: convert.Extension,
39
26
  };
40
27
  };
41
28
  }
package/src/extension.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { inlineView, customElement, bindable } from 'aurelia-framework';
2
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
1
+ import { inlineView, customElement, bindable, inject } from 'aurelia-framework';
2
+ import type { ExtensionSlotProps, PiletApi } from 'piral-core';
3
3
  import type { AureliaModule } from './types';
4
4
 
5
- export function createExtension(api: PiletApi, rootName = 'span'): AureliaModule<ExtensionSlotProps> {
5
+ export function createExtension(rootName: string): AureliaModule<ExtensionSlotProps> {
6
+ @inject('piral')
6
7
  @customElement('extension-component')
7
8
  @inlineView(`
8
9
  <template>
@@ -15,8 +16,10 @@ export function createExtension(api: PiletApi, rootName = 'span'): AureliaModule
15
16
  @bindable() private empty: any;
16
17
  @bindable() private params: any;
17
18
 
19
+ constructor(private piral: PiletApi) {}
20
+
18
21
  attached() {
19
- api.renderHtmlExtension(this.host, {
22
+ this.piral.renderHtmlExtension(this.host, {
20
23
  name: this.name,
21
24
  render: this.render,
22
25
  empty: this.empty,
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
2
 
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletAureliaApi {}
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 AureliaConverter {
8
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
9
- }
10
-
11
- export const fromAurelia: AureliaConverter = (root) => ({
12
- type: 'html',
13
- component: convert(root),
14
- });
15
-
16
- export const createAureliaExtension = createExtension;