piral-aurelia 0.13.8 → 0.14.0-beta.3156
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/convert.d.ts +8 -6
- package/convert.js +17 -8
- package/esm/DefaultLoader.js +26 -32
- package/esm/DefaultLoader.js.map +1 -1
- package/esm/converter.d.ts +13 -3
- package/esm/converter.js +13 -9
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +2 -6
- package/esm/create.js +12 -21
- package/esm/create.js.map +1 -1
- package/esm/extension.d.ts +2 -2
- package/esm/extension.js +34 -30
- package/esm/extension.js.map +1 -1
- package/lib/DefaultLoader.js +27 -32
- package/lib/DefaultLoader.js.map +1 -1
- package/lib/converter.d.ts +13 -3
- package/lib/converter.js +17 -13
- 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 +3 -3
- package/lib/index.js.map +1 -1
- package/package.json +4 -5
- package/src/converter.ts +20 -6
- package/src/create.ts +11 -24
- package/src/extension.ts +7 -4
- package/convert.ts +0 -16
package/convert.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HtmlComponent } from 'piral-core';
|
|
2
|
-
import {
|
|
3
|
-
declare const convert: <TProps extends import("piral-core").BaseComponentProps>(root: any) => import("piral-core").ForeignComponent<TProps>;
|
|
2
|
+
import { createConverter } from './lib/converter';
|
|
4
3
|
export interface AureliaConverter {
|
|
5
|
-
(...params: Parameters<typeof
|
|
4
|
+
(...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
|
|
6
5
|
}
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare function createAureliaConverter(...params: Parameters<typeof createConverter>): {
|
|
7
|
+
from: AureliaConverter;
|
|
8
|
+
Extension: any;
|
|
9
|
+
};
|
|
10
|
+
declare const fromAurelia: AureliaConverter, AureliaExtension: any;
|
|
11
|
+
export { fromAurelia, AureliaExtension };
|
package/convert.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.
|
|
3
|
+
exports.AureliaExtension = exports.fromAurelia = exports.createAureliaConverter = void 0;
|
|
4
4
|
var converter_1 = require("./lib/converter");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function createAureliaConverter() {
|
|
6
|
+
var params = [];
|
|
7
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
|
+
params[_i] = arguments[_i];
|
|
9
|
+
}
|
|
10
|
+
var convert = converter_1.createConverter.apply(void 0, params);
|
|
11
|
+
var Extension = convert.Extension;
|
|
12
|
+
var from = function (root) { return ({
|
|
13
|
+
type: 'html',
|
|
14
|
+
component: convert(root)
|
|
15
|
+
}); };
|
|
16
|
+
return { from: from, Extension: Extension };
|
|
17
|
+
}
|
|
18
|
+
exports.createAureliaConverter = createAureliaConverter;
|
|
19
|
+
var _a = createAureliaConverter(), fromAurelia = _a.from, AureliaExtension = _a.Extension;
|
|
11
20
|
exports.fromAurelia = fromAurelia;
|
|
12
|
-
exports.
|
|
21
|
+
exports.AureliaExtension = AureliaExtension;
|
package/esm/DefaultLoader.js
CHANGED
|
@@ -1,91 +1,85 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
1
|
import 'aurelia-templating-binding';
|
|
3
2
|
import 'aurelia-templating-resources';
|
|
4
3
|
import 'aurelia-event-aggregator';
|
|
5
4
|
import 'aurelia-history-browser';
|
|
6
5
|
import { Loader } from 'aurelia-framework';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_this.mapping = {};
|
|
12
|
-
return _this;
|
|
6
|
+
export class DefaultLoader extends Loader {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.mapping = {};
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* Maps a module id to a source.
|
|
16
13
|
* @param id The module id.
|
|
17
14
|
* @param source The source to map the module to.
|
|
18
15
|
*/
|
|
19
|
-
|
|
16
|
+
map(id, source) {
|
|
20
17
|
this.mapping[id] = source;
|
|
21
|
-
}
|
|
18
|
+
}
|
|
22
19
|
/**
|
|
23
20
|
* Normalizes a module id.
|
|
24
21
|
* @param moduleId The module id to normalize.
|
|
25
22
|
* @param relativeTo What the module id should be normalized relative to.
|
|
26
23
|
* @return The normalized module id.
|
|
27
24
|
*/
|
|
28
|
-
|
|
25
|
+
normalizeSync(moduleId, _relativeTo) {
|
|
29
26
|
return moduleId;
|
|
30
|
-
}
|
|
27
|
+
}
|
|
31
28
|
/**
|
|
32
29
|
* Normalizes a module id.
|
|
33
30
|
* @param moduleId The module id to normalize.
|
|
34
31
|
* @param relativeTo What the module id should be normalized relative to.
|
|
35
32
|
* @return A promise for the normalized module id.
|
|
36
33
|
*/
|
|
37
|
-
|
|
34
|
+
normalize(moduleId, relativeTo) {
|
|
38
35
|
return Promise.resolve(this.normalizeSync(moduleId, relativeTo));
|
|
39
|
-
}
|
|
36
|
+
}
|
|
40
37
|
/**
|
|
41
38
|
* Loads a module.
|
|
42
39
|
* @param id The module id to normalize.
|
|
43
40
|
* @return A Promise for the loaded module.
|
|
44
41
|
*/
|
|
45
|
-
|
|
42
|
+
loadModule(id) {
|
|
46
43
|
return Promise.resolve(require(id));
|
|
47
|
-
}
|
|
44
|
+
}
|
|
48
45
|
/**
|
|
49
46
|
* Loads a collection of modules.
|
|
50
47
|
* @param ids The set of module ids to load.
|
|
51
48
|
* @return A Promise for an array of loaded modules.
|
|
52
49
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
50
|
+
loadAllModules(ids) {
|
|
51
|
+
return Promise.all(ids.map((id) => this.loadModule(id)));
|
|
52
|
+
}
|
|
57
53
|
/**
|
|
58
54
|
* Loads a template.
|
|
59
55
|
* @param url The url of the template to load.
|
|
60
56
|
* @return A Promise for a TemplateRegistryEntry containing the template.
|
|
61
57
|
*/
|
|
62
|
-
|
|
63
|
-
return fetch(url).then(
|
|
64
|
-
}
|
|
58
|
+
loadTemplate(url) {
|
|
59
|
+
return fetch(url).then((res) => res.json());
|
|
60
|
+
}
|
|
65
61
|
/**
|
|
66
62
|
* Loads a text-based resource.
|
|
67
63
|
* @param url The url of the text file to load.
|
|
68
64
|
* @return A Promise for text content.
|
|
69
65
|
*/
|
|
70
|
-
|
|
71
|
-
return fetch(url).then(
|
|
72
|
-
}
|
|
66
|
+
loadText(url) {
|
|
67
|
+
return fetch(url).then((res) => res.text());
|
|
68
|
+
}
|
|
73
69
|
/**
|
|
74
70
|
* Alters a module id so that it includes a plugin loader.
|
|
75
71
|
* @param url The url of the module to load.
|
|
76
72
|
* @param pluginName The plugin to apply to the module id.
|
|
77
73
|
* @return The plugin-based module id.
|
|
78
74
|
*/
|
|
79
|
-
|
|
80
|
-
return url
|
|
81
|
-
}
|
|
75
|
+
applyPluginToUrl(url, pluginName) {
|
|
76
|
+
return `${url}?plugin=${pluginName}`;
|
|
77
|
+
}
|
|
82
78
|
/**
|
|
83
79
|
* Registers a plugin with the loader.
|
|
84
80
|
* @param pluginName The name of the plugin.
|
|
85
81
|
* @param implementation The plugin implementation.
|
|
86
82
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}(Loader));
|
|
90
|
-
export { DefaultLoader };
|
|
83
|
+
addPlugin(_pluginName, _implementation) { }
|
|
84
|
+
}
|
|
91
85
|
//# sourceMappingURL=DefaultLoader.js.map
|
package/esm/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,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,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,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"}
|
package/esm/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 span
|
|
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
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import { Aurelia } from 'aurelia-framework';
|
|
2
2
|
import { initialize } from 'aurelia-pal-browser';
|
|
3
3
|
import { DefaultLoader } from './DefaultLoader';
|
|
4
|
-
|
|
4
|
+
import { createExtension } from './extension';
|
|
5
|
+
export function createConverter(config = {}) {
|
|
6
|
+
const { rootName = 'span' } = config;
|
|
5
7
|
initialize();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
const Extension = createExtension(rootName);
|
|
9
|
+
const convert = (root) => {
|
|
10
|
+
let aurelia = undefined;
|
|
8
11
|
return {
|
|
9
|
-
mount
|
|
10
|
-
var piral = props.piral;
|
|
12
|
+
mount(el, props, ctx) {
|
|
11
13
|
aurelia = new Aurelia(new DefaultLoader());
|
|
12
14
|
aurelia.use
|
|
13
15
|
.eventAggregator()
|
|
14
16
|
.history()
|
|
15
17
|
.defaultBindingLanguage()
|
|
16
|
-
.globalResources([
|
|
18
|
+
.globalResources([Extension])
|
|
17
19
|
.defaultResources();
|
|
18
20
|
aurelia.container.registerInstance('props', props);
|
|
19
21
|
aurelia.container.registerInstance('ctx', ctx);
|
|
20
|
-
aurelia.
|
|
22
|
+
aurelia.container.registerInstance('piral', props.piral);
|
|
23
|
+
aurelia.start().then(() => aurelia.setRoot(root, el));
|
|
21
24
|
},
|
|
22
|
-
update
|
|
25
|
+
update(_, props, ctx) {
|
|
23
26
|
aurelia.container.registerInstance('props', props);
|
|
24
27
|
aurelia.container.registerInstance('ctx', ctx);
|
|
25
28
|
},
|
|
26
|
-
unmount
|
|
29
|
+
unmount() {
|
|
27
30
|
aurelia = undefined;
|
|
28
31
|
},
|
|
29
32
|
};
|
|
30
33
|
};
|
|
34
|
+
convert.Extension = Extension;
|
|
31
35
|
return convert;
|
|
32
36
|
}
|
|
33
37
|
//# sourceMappingURL=converter.js.map
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAW9C,MAAM,UAAU,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IAErC,UAAU,EAAE,CAAC;IAEb,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE;QAC3G,IAAI,OAAO,GAAY,SAAS,CAAC;QAEjC,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;gBAE3C,OAAO,CAAC,GAAG;qBACR,eAAe,EAAE;qBACjB,OAAO,EAAE;qBACT,sBAAsB,EAAE;qBACxB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC;qBAC5B,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;gBAC/C,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAEzD,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;YACD,MAAM,CAAC,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,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/esm/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/esm/create.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { createExtension } from './extension';
|
|
2
1
|
import { createConverter } from './converter';
|
|
3
2
|
/**
|
|
4
3
|
* Creates new Pilet API extensions for integrating Aurelia.
|
|
5
4
|
*/
|
|
6
|
-
export function createAureliaApi(config) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fromAurelia: function (root) {
|
|
19
|
-
return {
|
|
20
|
-
type: 'aurelia',
|
|
21
|
-
root: root,
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
AureliaExtension: AureliaExtension,
|
|
25
|
-
};
|
|
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,
|
|
26
17
|
};
|
|
27
18
|
};
|
|
28
19
|
}
|
package/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,
|
|
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.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/esm/extension.js
CHANGED
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { inlineView, customElement, bindable } from 'aurelia-framework';
|
|
3
|
-
export function createExtension(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
attached() {
|
|
9
|
+
this.piral.renderHtmlExtension(this.host, {
|
|
10
10
|
name: this.name,
|
|
11
11
|
render: this.render,
|
|
12
12
|
empty: this.empty,
|
|
13
13
|
params: this.params,
|
|
14
14
|
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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);
|
|
38
42
|
return AureliaExtension;
|
|
39
43
|
}
|
|
40
44
|
//# sourceMappingURL=extension.js.map
|
package/esm/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
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;IAO9C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;QAOpB,YAAoB,KAAU;YAAV,UAAK,GAAL,KAAK,CAAK;QAAG,CAAC;QAElC,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;IAfa;QAAX,QAAQ,EAAE;;kDAAsB;IACrB;QAAX,QAAQ,EAAE;;oDAAqB;IACpB;QAAX,QAAQ,EAAE;;mDAAoB;IACnB;QAAX,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/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
|
-
|
|
45
|
+
loadModule(id) {
|
|
49
46
|
return Promise.resolve(require(id));
|
|
50
|
-
}
|
|
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,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,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 span
|
|
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,40 @@
|
|
|
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
|
-
|
|
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 = 'span' } = config;
|
|
10
|
+
(0, aurelia_pal_browser_1.initialize)();
|
|
11
|
+
const Extension = (0, extension_1.createExtension)(rootName);
|
|
12
|
+
const convert = (root) => {
|
|
13
|
+
let aurelia = undefined;
|
|
11
14
|
return {
|
|
12
|
-
mount
|
|
13
|
-
var piral = props.piral;
|
|
15
|
+
mount(el, props, ctx) {
|
|
14
16
|
aurelia = new aurelia_framework_1.Aurelia(new DefaultLoader_1.DefaultLoader());
|
|
15
17
|
aurelia.use
|
|
16
18
|
.eventAggregator()
|
|
17
19
|
.history()
|
|
18
20
|
.defaultBindingLanguage()
|
|
19
|
-
.globalResources([
|
|
21
|
+
.globalResources([Extension])
|
|
20
22
|
.defaultResources();
|
|
21
23
|
aurelia.container.registerInstance('props', props);
|
|
22
24
|
aurelia.container.registerInstance('ctx', ctx);
|
|
23
|
-
aurelia.
|
|
25
|
+
aurelia.container.registerInstance('piral', props.piral);
|
|
26
|
+
aurelia.start().then(() => aurelia.setRoot(root, el));
|
|
24
27
|
},
|
|
25
|
-
update
|
|
28
|
+
update(_, props, ctx) {
|
|
26
29
|
aurelia.container.registerInstance('props', props);
|
|
27
30
|
aurelia.container.registerInstance('ctx', ctx);
|
|
28
31
|
},
|
|
29
|
-
unmount
|
|
32
|
+
unmount() {
|
|
30
33
|
aurelia = undefined;
|
|
31
34
|
},
|
|
32
35
|
};
|
|
33
36
|
};
|
|
37
|
+
convert.Extension = Extension;
|
|
34
38
|
return convert;
|
|
35
39
|
}
|
|
36
40
|
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;AAW9C,SAAgB,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IAErC,IAAA,gCAAU,GAAE,CAAC;IAEb,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE;QAC3G,IAAI,OAAO,GAAY,SAAS,CAAC;QAEjC,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,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,SAAS,CAAC,CAAC;qBAC5B,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;gBAC/C,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAEzD,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;YACD,MAAM,CAAC,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,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAtCD,0CAsCC"}
|
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
|
+
(0, tslib_1.__decorate)([
|
|
21
|
+
(0, aurelia_framework_1.bindable)(),
|
|
22
|
+
(0, tslib_1.__metadata)("design:type", String)
|
|
23
|
+
], AureliaExtension.prototype, "name", void 0);
|
|
24
|
+
(0, tslib_1.__decorate)([
|
|
25
|
+
(0, aurelia_framework_1.bindable)(),
|
|
26
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
27
|
+
], AureliaExtension.prototype, "render", void 0);
|
|
28
|
+
(0, tslib_1.__decorate)([
|
|
29
|
+
(0, aurelia_framework_1.bindable)(),
|
|
30
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
31
|
+
], AureliaExtension.prototype, "empty", void 0);
|
|
32
|
+
(0, tslib_1.__decorate)([
|
|
33
|
+
(0, aurelia_framework_1.bindable)(),
|
|
34
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
35
|
+
], AureliaExtension.prototype, "params", void 0);
|
|
36
|
+
AureliaExtension = (0, 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
|
+
(0, 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;IAO9C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;QAOpB,YAAoB,KAAU;YAAV,UAAK,GAAL,KAAK,CAAK;QAAG,CAAC;QAElC,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;IAfa;QAAX,IAAA,4BAAQ,GAAE;;kDAAsB;IACrB;QAAX,IAAA,4BAAQ,GAAE;;oDAAqB;IACpB;QAAX,IAAA,4BAAQ,GAAE;;mDAAoB;IACnB;QAAX,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
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./create"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./create"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,uDAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-aurelia",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-beta.3156",
|
|
4
4
|
"description": "Plugin for integrating Aurelia components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"lib",
|
|
26
26
|
"src",
|
|
27
27
|
"convert.d.ts",
|
|
28
|
-
"convert.ts",
|
|
29
28
|
"convert.js"
|
|
30
29
|
],
|
|
31
30
|
"repository": {
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"aurelia-pal-browser": "1.8.1",
|
|
51
50
|
"aurelia-templating-binding": "1.5.3",
|
|
52
51
|
"aurelia-templating-resources": "1.13.1",
|
|
53
|
-
"piral-core": "^0.
|
|
52
|
+
"piral-core": "^0.14.0-beta.3156"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
55
|
"aurelia-event-aggregator": "^1.0.0",
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"aurelia-pal-browser": "^1.0.0",
|
|
60
59
|
"aurelia-templating-binding": "^1.0.0",
|
|
61
60
|
"aurelia-templating-resources": "^1.0.0",
|
|
62
|
-
"piral-core": "0.
|
|
61
|
+
"piral-core": "0.14.x"
|
|
63
62
|
},
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e368a181defdfca4722d7bd478a9dcd47d90a51b"
|
|
65
64
|
}
|
package/src/converter.ts
CHANGED
|
@@ -1,29 +1,42 @@
|
|
|
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 span
|
|
12
|
+
*/
|
|
13
|
+
rootName?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createConverter(config: AureliaConverterOptions = {}) {
|
|
17
|
+
const { rootName = 'span' } = config;
|
|
6
18
|
|
|
7
|
-
export function createConverter() {
|
|
8
19
|
initialize();
|
|
20
|
+
|
|
21
|
+
const Extension = createExtension(rootName);
|
|
22
|
+
|
|
9
23
|
const convert = <TProps extends BaseComponentProps>(root: AureliaModule<TProps>): ForeignComponent<TProps> => {
|
|
10
24
|
let aurelia: Aurelia = undefined;
|
|
11
25
|
|
|
12
26
|
return {
|
|
13
27
|
mount(el, props, ctx) {
|
|
14
|
-
const { piral } = props;
|
|
15
|
-
|
|
16
28
|
aurelia = new Aurelia(new DefaultLoader());
|
|
17
29
|
|
|
18
30
|
aurelia.use
|
|
19
31
|
.eventAggregator()
|
|
20
32
|
.history()
|
|
21
33
|
.defaultBindingLanguage()
|
|
22
|
-
.globalResources([
|
|
34
|
+
.globalResources([Extension])
|
|
23
35
|
.defaultResources();
|
|
24
36
|
|
|
25
37
|
aurelia.container.registerInstance('props', props);
|
|
26
38
|
aurelia.container.registerInstance('ctx', ctx);
|
|
39
|
+
aurelia.container.registerInstance('piral', props.piral);
|
|
27
40
|
|
|
28
41
|
aurelia.start().then(() => aurelia.setRoot(root, el));
|
|
29
42
|
},
|
|
@@ -36,5 +49,6 @@ export function createConverter() {
|
|
|
36
49
|
},
|
|
37
50
|
};
|
|
38
51
|
};
|
|
52
|
+
convert.Extension = Extension;
|
|
39
53
|
return convert;
|
|
40
54
|
}
|
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 } 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: any) {}
|
|
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/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;
|