piral-aurelia 1.0.0-pre.2086 → 1.0.0
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 +1 -1
- package/README.md +13 -14
- package/convert.d.ts +16 -7
- package/convert.js +16 -11
- package/esm/DefaultLoader.d.ts +66 -0
- package/esm/DefaultLoader.js +85 -0
- package/esm/DefaultLoader.js.map +1 -0
- package/esm/converter.d.ts +13 -0
- package/esm/converter.js +30 -0
- package/esm/converter.js.map +1 -0
- package/esm/create.d.ts +12 -0
- package/esm/create.js +20 -0
- package/esm/create.js.map +1 -0
- package/esm/extension.d.ts +3 -0
- package/esm/extension.js +44 -0
- package/esm/extension.js.map +1 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/types.d.ts +34 -0
- package/esm/types.js +2 -0
- package/esm/types.js.map +1 -0
- package/lib/DefaultLoader.d.ts +3 -2
- package/lib/DefaultLoader.js +28 -33
- package/lib/DefaultLoader.js.map +1 -1
- package/lib/converter.d.ts +13 -3
- package/lib/converter.js +27 -30
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +2 -6
- package/lib/create.js +13 -22
- package/lib/create.js.map +1 -1
- package/lib/extension.d.ts +2 -2
- package/lib/extension.js +35 -31
- package/lib/extension.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/types.d.ts +2 -2
- package/package.json +33 -9
- package/src/DefaultLoader.ts +1 -1
- package/src/converter.ts +43 -33
- package/src/create.ts +11 -24
- package/src/extension.ts +7 -4
- package/src/types.ts +1 -1
- package/convert.ts +0 -16
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[](https://piral.io)
|
|
2
2
|
|
|
3
|
-
# [Piral Aurelia](https://piral.io) · [](https://github.com/smapiot/piral/blob/
|
|
3
|
+
# [Piral Aurelia](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-aurelia) [](https://jestjs.io) [](https://gitter.im/piral-io/community)
|
|
4
4
|
|
|
5
|
-
This is a plugin that only has a peer dependency to `
|
|
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) {
|
|
@@ -62,7 +62,6 @@ export function setup(piral: PiletApi) {
|
|
|
62
62
|
Using Aurelia with Piral is as simple as installing `piral-aurelia` and `aurelia-framework`.
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
-
import 'aurelia-framework';
|
|
66
65
|
import { createAureliaApi } from 'piral-aurelia';
|
|
67
66
|
```
|
|
68
67
|
|
|
@@ -80,15 +79,15 @@ The `aurelia` related packages should be shared with the pilets via the *package
|
|
|
80
79
|
|
|
81
80
|
```json
|
|
82
81
|
{
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"aurelia-framework",
|
|
86
|
-
"aurelia-templating-binding",
|
|
87
|
-
"aurelia-templating-resources",
|
|
88
|
-
"aurelia-pal-browser",
|
|
89
|
-
"aurelia-event-aggregator",
|
|
90
|
-
"aurelia-history-browser"
|
|
91
|
-
|
|
82
|
+
"importmap": {
|
|
83
|
+
"imports": {
|
|
84
|
+
"aurelia-framework": "",
|
|
85
|
+
"aurelia-templating-binding": "",
|
|
86
|
+
"aurelia-templating-resources": "",
|
|
87
|
+
"aurelia-pal-browser": "",
|
|
88
|
+
"aurelia-event-aggregator": "",
|
|
89
|
+
"aurelia-history-browser": ""
|
|
90
|
+
}
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
```
|
package/convert.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
11
|
+
(...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
|
|
6
12
|
}
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
};
|
package/esm/converter.js
ADDED
|
@@ -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"}
|
package/esm/create.d.ts
ADDED
|
@@ -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"}
|
package/esm/extension.js
ADDED
|
@@ -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
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -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
package/esm/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/lib/DefaultLoader.d.ts
CHANGED
|
@@ -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<
|
|
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<[
|
|
40
|
+
loadAllModules(ids: any): Promise<any[]>;
|
|
40
41
|
/**
|
|
41
42
|
* Loads a template.
|
|
42
43
|
* @param url The url of the template to load.
|
package/lib/DefaultLoader.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
return
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
66
|
-
return fetch(url).then(
|
|
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
|
-
|
|
74
|
-
return fetch(url).then(
|
|
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
|
-
|
|
83
|
-
return url
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
}(aurelia_framework_1.Loader));
|
|
86
|
+
addPlugin(_pluginName, _implementation) { }
|
|
87
|
+
}
|
|
93
88
|
exports.DefaultLoader = DefaultLoader;
|
|
94
89
|
//# sourceMappingURL=DefaultLoader.js.map
|
package/lib/DefaultLoader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultLoader.js","sourceRoot":"","sources":["../src/DefaultLoader.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { AureliaModule } from './types';
|
|
3
|
-
export
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,
|
|
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"}
|
package/lib/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import type { AureliaModule } from './types';
|
|
3
|
-
export declare function createExtension(
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
function createExtension(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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;
|
package/lib/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;;AAAA,
|
|
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
|
-
|
|
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
|
|
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
|
|
3
|
+
"version": "1.0.0",
|
|
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,18 +55,22 @@
|
|
|
34
55
|
"url": "https://github.com/smapiot/piral/issues"
|
|
35
56
|
},
|
|
36
57
|
"scripts": {
|
|
37
|
-
"
|
|
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.
|
|
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.
|
|
48
|
-
"piral-core": "^1.0.0
|
|
72
|
+
"aurelia-templating-resources": "1.13.1",
|
|
73
|
+
"piral-core": "^1.0.0"
|
|
49
74
|
},
|
|
50
75
|
"peerDependencies": {
|
|
51
76
|
"aurelia-event-aggregator": "^1.0.0",
|
|
@@ -53,8 +78,7 @@
|
|
|
53
78
|
"aurelia-history-browser": "^1.0.0",
|
|
54
79
|
"aurelia-pal-browser": "^1.0.0",
|
|
55
80
|
"aurelia-templating-binding": "^1.0.0",
|
|
56
|
-
"aurelia-templating-resources": "^1.0.0"
|
|
57
|
-
"piral-core": "1.x"
|
|
81
|
+
"aurelia-templating-resources": "^1.0.0"
|
|
58
82
|
},
|
|
59
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "67d9a2920bd5231baf10bc87ae8985666b18fa3a"
|
|
60
84
|
}
|
package/src/DefaultLoader.ts
CHANGED
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 {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 {
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
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
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;
|