piral-lazy 1.6.0-beta.7216 → 1.6.0-beta.7243

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/lib/create.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLazyApi = void 0;
4
- const react_1 = require("react");
5
- const piral_core_1 = require("piral-core");
6
- function createLazyApi() {
1
+ import { lazy, createElement } from 'react';
2
+ import { withApi } from 'piral-core';
3
+ export function createLazyApi() {
7
4
  return (context) => {
8
5
  return (api) => {
9
6
  const cache = {};
@@ -22,15 +19,15 @@ function createLazyApi() {
22
19
  };
23
20
  },
24
21
  fromLazy(load, deps = []) {
25
- return (0, react_1.lazy)(() => Promise.all(deps.map(getDependency)).then((values) => {
22
+ return lazy(() => Promise.all(deps.map(getDependency)).then((values) => {
26
23
  const depMap = deps.reduce((obj, name, index) => {
27
24
  obj[name] = values[index];
28
25
  return obj;
29
26
  }, {});
30
27
  return load()
31
- .then((comp) => (0, piral_core_1.withApi)(context, comp, api, 'unknown'))
28
+ .then((comp) => withApi(context, comp, api, 'unknown'))
32
29
  .then((compWithApi) => ({
33
- default: (props) => (0, react_1.createElement)(compWithApi, { deps: depMap, ...props }),
30
+ default: (props) => createElement(compWithApi, { deps: depMap, ...props }),
34
31
  }));
35
32
  }));
36
33
  },
@@ -38,5 +35,4 @@ function createLazyApi() {
38
35
  };
39
36
  };
40
37
  }
41
- exports.createLazyApi = createLazyApi;
42
38
  //# sourceMappingURL=create.js.map
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAAA,iCAA2D;AAC3D,2CAAkD;AAUlD,SAAgB,aAAa;IAC3B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,OAAO,CAAC,GAAG,EAAE,EAAE;YACb,MAAM,KAAK,GAAoB,EAAE,CAAC;YAEl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AAE,EAAE;4BAC9C,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC1B,OAAO,GAAG,CAAC;wBACb,CAAC,EAAE,EAAE,CAAC,CAAC;wBACP,OAAO,IAAI,EAAE;6BACV,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;6BACtD,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;4BACtB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,WAA4B,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;yBAC5F,CAAC,CAAC,CAAC;oBACR,CAAC,CAAC,CACH,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/lib/index.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./create"), exports);
5
- tslib_1.__exportStar(require("./types"), exports);
1
+ export * from './create';
2
+ export * from './types';
6
3
  //# 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,mDAAyB;AACzB,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/lib/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-lazy",
3
- "version": "1.6.0-beta.7216",
3
+ "version": "1.6.0-beta.7243",
4
4
  "description": "Plugin for lazy loading third-party framework components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -16,29 +16,16 @@
16
16
  "author": "smapiot",
17
17
  "homepage": "https://piral.io",
18
18
  "license": "MIT",
19
- "module": "esm/index.js",
19
+ "module": "lib/index.js",
20
20
  "main": "lib/index.js",
21
21
  "typings": "lib/index.d.ts",
22
22
  "exports": {
23
- ".": {
24
- "import": "./esm/index.js",
25
- "require": "./lib/index.js"
26
- },
27
- "./esm/*": {
28
- "import": "./esm/*"
29
- },
30
- "./lib/*": {
31
- "require": "./lib/*"
32
- },
33
- "./_/*": {
34
- "import": "./esm/*.js",
35
- "require": "./lib/*.js"
36
- },
23
+ ".": "./lib/index.js",
24
+ "./lib/*": "./lib/*",
37
25
  "./package.json": "./package.json"
38
26
  },
39
27
  "sideEffects": false,
40
28
  "files": [
41
- "esm",
42
29
  "lib",
43
30
  "src",
44
31
  "piral-lazy.min.js"
@@ -52,17 +39,16 @@
52
39
  },
53
40
  "scripts": {
54
41
  "cleanup": "rimraf esm lib piral-lazy.min.js",
55
- "build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
42
+ "build": "yarn build:bundle && yarn build:esnext",
56
43
  "build:bundle": "esbuild src/index.ts --outfile=piral-lazy.min.js --bundle --external:piral-core --external:react --minify --global-name=piralLazy",
57
- "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
58
- "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
44
+ "build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext",
59
45
  "typedoc": "typedoc --json ../../../docs/types/piral-lazy.json src --exclude \"src/**/*.test.*\"",
60
46
  "test": "echo \"Error: run tests from root\" && exit 1"
61
47
  },
62
48
  "devDependencies": {
63
49
  "@types/react": "^18.0.0",
64
- "piral-core": "1.6.0-beta.7216",
50
+ "piral-core": "1.6.0-beta.7243",
65
51
  "react": "^18.0.0"
66
52
  },
67
- "gitHead": "bd3742af68fc25af93ed9b37021d2d69a6f40f18"
53
+ "gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3"
68
54
  }
package/esm/create.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { PiralPlugin } from 'piral-core';
2
- import { PiletLazyApi } from './types';
3
- export declare function createLazyApi(): PiralPlugin<PiletLazyApi>;
package/esm/create.js DELETED
@@ -1,38 +0,0 @@
1
- import { lazy, createElement } from 'react';
2
- import { withApi } from 'piral-core';
3
- export function createLazyApi() {
4
- return (context) => {
5
- return (api) => {
6
- const cache = {};
7
- const getDependency = (name) => {
8
- const dep = cache[name];
9
- if (!dep) {
10
- throw new Error(`The given dependency "${name}" cannot be found. Please add it first using "defineDependency"`);
11
- }
12
- return dep.result ?? (dep.result = dep.loader());
13
- };
14
- return {
15
- defineDependency(name, loader) {
16
- cache[name] = {
17
- loader,
18
- result: undefined,
19
- };
20
- },
21
- fromLazy(load, deps = []) {
22
- return lazy(() => Promise.all(deps.map(getDependency)).then((values) => {
23
- const depMap = deps.reduce((obj, name, index) => {
24
- obj[name] = values[index];
25
- return obj;
26
- }, {});
27
- return load()
28
- .then((comp) => withApi(context, comp, api, 'unknown'))
29
- .then((compWithApi) => ({
30
- default: (props) => createElement(compWithApi, { deps: depMap, ...props }),
31
- }));
32
- }));
33
- },
34
- };
35
- };
36
- };
37
- }
38
- //# sourceMappingURL=create.js.map
package/esm/create.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAe,OAAO,EAAE,MAAM,YAAY,CAAC;AAUlD,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,OAAO,CAAC,GAAG,EAAE,EAAE;YACb,MAAM,KAAK,GAAoB,EAAE,CAAC;YAElC,MAAM,aA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AC,CAAC;oBACR,CAAC,CAAC,CACH,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/esm/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './create';
2
- export * from './types';
package/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './create';
2
- export * from './types';
3
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- import type { AnyComponent, BaseComponentProps } from 'piral-core';
3
- declare module 'piral-core/lib/types/custom' {
4
- interface PiletCustomApi extends PiletLazyApi {
5
- }
6
- }
7
- export interface LazyComponentLoader<TProps> {
8
- (): Promise<AnyComponent<TProps>>;
9
- }
10
- export interface LazyDependencyLoader {
11
- (): Promise<any>;
12
- }
13
- /**
14
- * Defines the provided set of lazy loading Pilet API extensions.
15
- */
16
- export interface PiletLazyApi {
17
- /**
18
- * Defines a dependency for lazy loading.
19
- * @param name The name of the dependency.
20
- * @param loader The associated dependency loader.
21
- */
22
- defineDependency(name: string, loader: LazyDependencyLoader): void;
23
- /**
24
- * Properly introduces a lazy loaded foreign component.
25
- * @param cb The callback to trigger when the component should be loaded.
26
- * @param deps The optional names of the dependencies to load beforehand.
27
- * @returns The lazy loading component.
28
- */
29
- fromLazy<T extends BaseComponentProps>(cb: LazyComponentLoader<T>, deps?: Array<string>): ComponentType<T & {
30
- deps?: Record<string, any>;
31
- }>;
32
- }
package/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/esm/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}