piral-ngjs 0.15.0-alpha.3816 → 0.15.0-alpha.3905
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/README.md +1 -1
- package/esm/converter.js +14 -17
- package/esm/converter.js.map +1 -1
- package/lib/converter.js +14 -17
- package/lib/converter.js.map +1 -1
- package/package.json +4 -5
- package/src/converter.ts +18 -18
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# [Piral NgJS](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-ngjs) [](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 `angular`. What `piral-ngjs` 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 Angular.js converter for any component registration, as well as a `fromNgjs` shortcut and a `NgjsExtension` component.
|
|
8
8
|
|
package/esm/converter.js
CHANGED
|
@@ -3,23 +3,20 @@ import { createExtension } from './extension';
|
|
|
3
3
|
export function createConverter(config = {}) {
|
|
4
4
|
const { rootName = 'slot' } = config;
|
|
5
5
|
const Extension = createExtension(rootName);
|
|
6
|
-
const convert = (name, root) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|
|
6
|
+
const convert = (name, root) => ({
|
|
7
|
+
mount(el, props, ctx, locals) {
|
|
8
|
+
el.appendChild(document.createElement(name));
|
|
9
|
+
root.value('props', props);
|
|
10
|
+
root.value('piral', props.piral);
|
|
11
|
+
root.value('ctx', ctx);
|
|
12
|
+
locals.injector = bootstrap(el, [root.name]);
|
|
13
|
+
},
|
|
14
|
+
unmount(el, locals) {
|
|
15
|
+
const rootScope = locals.injector.get('$rootScope');
|
|
16
|
+
rootScope.$destroy();
|
|
17
|
+
locals.injector = undefined;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
23
20
|
convert.Extension = Extension;
|
|
24
21
|
return convert;
|
|
25
22
|
}
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAW,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAW,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAc9C,MAAM,UAAU,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAAY,EAAE,IAAa,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAiB;YACrC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACvB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAiB;YAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACpD,SAAS,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/converter.js
CHANGED
|
@@ -6,23 +6,20 @@ const extension_1 = require("./extension");
|
|
|
6
6
|
function createConverter(config = {}) {
|
|
7
7
|
const { rootName = 'slot' } = config;
|
|
8
8
|
const Extension = (0, extension_1.createExtension)(rootName);
|
|
9
|
-
const convert = (name, root) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
9
|
+
const convert = (name, root) => ({
|
|
10
|
+
mount(el, props, ctx, locals) {
|
|
11
|
+
el.appendChild(document.createElement(name));
|
|
12
|
+
root.value('props', props);
|
|
13
|
+
root.value('piral', props.piral);
|
|
14
|
+
root.value('ctx', ctx);
|
|
15
|
+
locals.injector = (0, angular_1.bootstrap)(el, [root.name]);
|
|
16
|
+
},
|
|
17
|
+
unmount(el, locals) {
|
|
18
|
+
const rootScope = locals.injector.get('$rootScope');
|
|
19
|
+
rootScope.$destroy();
|
|
20
|
+
locals.injector = undefined;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
26
23
|
convert.Extension = Extension;
|
|
27
24
|
return convert;
|
|
28
25
|
}
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,qCAA6C;AAC7C,2CAA8C;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,qCAA6C;AAC7C,2CAA8C;AAc9C,SAAgB,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAAY,EAAE,IAAa,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAiB;YACrC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACvB,MAAM,CAAC,QAAQ,GAAG,IAAA,mBAAS,EAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAiB;YAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACpD,SAAS,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAnBD,0CAmBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-ngjs",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3905",
|
|
4
4
|
"description": "Plugin for integrating Angular.js components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -46,11 +46,10 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/angular": "^1.6.45",
|
|
48
48
|
"angular": "^1.7.9",
|
|
49
|
-
"piral-core": "0.15.0-alpha.
|
|
49
|
+
"piral-core": "0.15.0-alpha.3905"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"angular": "^1.7.0"
|
|
53
|
-
"piral-core": "0.14.x"
|
|
52
|
+
"angular": "^1.7.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "533d09963cfd8c901df797958ca386dbae0286e1"
|
|
56
55
|
}
|
package/src/converter.ts
CHANGED
|
@@ -10,27 +10,27 @@ export interface NgjsConverterOptions {
|
|
|
10
10
|
rootName?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface NgjsState {
|
|
14
|
+
injector: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
export function createConverter(config: NgjsConverterOptions = {}) {
|
|
14
18
|
const { rootName = 'slot' } = config;
|
|
15
19
|
const Extension = createExtension(rootName);
|
|
16
|
-
const convert = <TProps extends BaseComponentProps>(name: string, root: IModule): ForeignComponent<TProps> => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
injector = undefined;
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
20
|
+
const convert = <TProps extends BaseComponentProps>(name: string, root: IModule): ForeignComponent<TProps> => ({
|
|
21
|
+
mount(el, props, ctx, locals: NgjsState) {
|
|
22
|
+
el.appendChild(document.createElement(name));
|
|
23
|
+
root.value('props', props);
|
|
24
|
+
root.value('piral', props.piral);
|
|
25
|
+
root.value('ctx', ctx);
|
|
26
|
+
locals.injector = bootstrap(el, [root.name]);
|
|
27
|
+
},
|
|
28
|
+
unmount(el, locals: NgjsState) {
|
|
29
|
+
const rootScope = locals.injector.get('$rootScope');
|
|
30
|
+
rootScope.$destroy();
|
|
31
|
+
locals.injector = undefined;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
34
|
convert.Extension = Extension;
|
|
35
35
|
return convert;
|
|
36
36
|
}
|