piral-feeds
Advanced tools
Comparing version 1.6.0-beta.7240 to 1.6.0-beta.7243
@@ -1,9 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateFeed = exports.loadedFeed = exports.loadFeed = exports.destroyFeed = exports.createFeed = void 0; | ||
const piral_core_1 = require("piral-core"); | ||
function createFeed(ctx, id) { | ||
import { withKey, withoutKey } from 'piral-core'; | ||
export function createFeed(ctx, id) { | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
feeds: (0, piral_core_1.withKey)(state.feeds, id, { | ||
feeds: withKey(state.feeds, id, { | ||
data: undefined, | ||
@@ -16,15 +13,13 @@ error: undefined, | ||
} | ||
exports.createFeed = createFeed; | ||
function destroyFeed(ctx, id) { | ||
export function destroyFeed(ctx, id) { | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
feeds: (0, piral_core_1.withoutKey)(state.feeds, id), | ||
feeds: withoutKey(state.feeds, id), | ||
})); | ||
} | ||
exports.destroyFeed = destroyFeed; | ||
function loadFeed(ctx, options) { | ||
export function loadFeed(ctx, options) { | ||
const { id } = options; | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
feeds: (0, piral_core_1.withKey)(state.feeds, id, { | ||
feeds: withKey(state.feeds, id, { | ||
data: undefined, | ||
@@ -43,7 +38,6 @@ error: undefined, | ||
} | ||
exports.loadFeed = loadFeed; | ||
function loadedFeed(ctx, id, data, error) { | ||
export function loadedFeed(ctx, id, data, error) { | ||
ctx.dispatch((state) => ({ | ||
...state, | ||
feeds: (0, piral_core_1.withKey)(state.feeds, id, { | ||
feeds: withKey(state.feeds, id, { | ||
loading: false, | ||
@@ -56,4 +50,3 @@ loaded: true, | ||
} | ||
exports.loadedFeed = loadedFeed; | ||
function updateFeed(ctx, id, item, reducer) { | ||
export function updateFeed(ctx, id, item, reducer) { | ||
const feed = ctx.readState((state) => state.feeds[id]); | ||
@@ -70,3 +63,2 @@ const result = reducer(feed.data, item); | ||
} | ||
exports.updateFeed = updateFeed; | ||
//# sourceMappingURL=actions.js.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFeedsApi = void 0; | ||
const actions = require("./actions"); | ||
const piral_core_1 = require("piral-core"); | ||
const withFeed_1 = require("./withFeed"); | ||
const utils_1 = require("./utils"); | ||
import * as actions from './actions'; | ||
import { buildName } from 'piral-core'; | ||
import { withFeed } from './withFeed'; | ||
import { createFeedOptions } from './utils'; | ||
/** | ||
* Creates new Pilet API extensions for supporting simplified data feed connections. | ||
*/ | ||
function createFeedsApi(config = {}) { | ||
export function createFeedsApi(config = {}) { | ||
return (context) => { | ||
@@ -22,4 +19,4 @@ context.defineActions(actions); | ||
createConnector(resolver) { | ||
const id = (0, piral_core_1.buildName)(target.name, feeds++); | ||
const options = (0, utils_1.createFeedOptions)(id, resolver); | ||
const id = buildName(target.name, feeds++); | ||
const options = createFeedOptions(id, resolver); | ||
const invalidate = () => { | ||
@@ -35,3 +32,3 @@ options.dispose?.(); | ||
} | ||
const connect = ((component) => (0, withFeed_1.withFeed)(component, options)); | ||
const connect = ((component) => withFeed(component, options)); | ||
Object.keys(options.reducers).forEach((type) => { | ||
@@ -52,3 +49,2 @@ const reducer = options.reducers[type]; | ||
} | ||
exports.createFeedsApi = createFeedsApi; | ||
//# sourceMappingURL=create.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./create"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./useFeed"), exports); | ||
tslib_1.__exportStar(require("./withFeed"), exports); | ||
export * from './create'; | ||
export * from './types'; | ||
export * from './useFeed'; | ||
export * from './withFeed'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useFeed = void 0; | ||
const react_1 = require("react"); | ||
const piral_core_1 = require("piral-core"); | ||
import { useEffect } from 'react'; | ||
import { useGlobalState, useAction } from 'piral-core'; | ||
/** | ||
@@ -10,6 +7,6 @@ * Hook that returns the connected feed. | ||
*/ | ||
function useFeed(options) { | ||
const { loaded, loading, error, data } = (0, piral_core_1.useGlobalState)((s) => s.feeds[options.id]); | ||
const load = (0, piral_core_1.useAction)('loadFeed'); | ||
(0, react_1.useEffect)(() => { | ||
export function useFeed(options) { | ||
const { loaded, loading, error, data } = useGlobalState((s) => s.feeds[options.id]); | ||
const load = useAction('loadFeed'); | ||
useEffect(() => { | ||
if (!loaded && !loading) { | ||
@@ -21,3 +18,2 @@ load(options); | ||
} | ||
exports.useFeed = useFeed; | ||
//# sourceMappingURL=useFeed.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFeedOptions = void 0; | ||
const piral_core_1 = require("piral-core"); | ||
import { isfunc } from 'piral-core'; | ||
const noop = () => { }; | ||
function createFeedOptions(id, resolver) { | ||
if ((0, piral_core_1.isfunc)(resolver)) { | ||
export function createFeedOptions(id, resolver) { | ||
if (isfunc(resolver)) { | ||
return { | ||
@@ -50,3 +47,2 @@ id, | ||
} | ||
exports.createFeedOptions = createFeedOptions; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withFeed = void 0; | ||
const React = require("react"); | ||
const piral_core_1 = require("piral-core"); | ||
const useFeed_1 = require("./useFeed"); | ||
function withFeed(Component, options) { | ||
import * as React from 'react'; | ||
import { RegisteredLoadingIndicator, RegisteredErrorInfo } from 'piral-core'; | ||
import { useFeed } from './useFeed'; | ||
export function withFeed(Component, options) { | ||
const FeedView = (props) => { | ||
const [loaded, data, error] = (0, useFeed_1.useFeed)(options); | ||
const [loaded, data, error] = useFeed(options); | ||
if (!loaded) { | ||
return React.createElement(piral_core_1.RegisteredLoadingIndicator, null); | ||
return React.createElement(RegisteredLoadingIndicator, null); | ||
} | ||
@@ -17,3 +14,3 @@ else if (data) { | ||
else { | ||
return React.createElement(piral_core_1.RegisteredErrorInfo, { type: "feed", error: error }); | ||
return React.createElement(RegisteredErrorInfo, { type: "feed", error: error }); | ||
} | ||
@@ -24,3 +21,2 @@ }; | ||
} | ||
exports.withFeed = withFeed; | ||
//# sourceMappingURL=withFeed.js.map |
{ | ||
"name": "piral-feeds", | ||
"version": "1.6.0-beta.7240", | ||
"version": "1.6.0-beta.7243", | ||
"description": "Plugin for connecting data feeds in Piral.", | ||
@@ -19,20 +19,8 @@ "keywords": [ | ||
"license": "MIT", | ||
"module": "esm/index.js", | ||
"module": "lib/index.js", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.js", | ||
"require": "./lib/index.js" | ||
}, | ||
"./esm/*": { | ||
"import": "./esm/*" | ||
}, | ||
"./lib/*": { | ||
"require": "./lib/*" | ||
}, | ||
"./_/*": { | ||
"import": "./esm/*.js", | ||
"require": "./lib/*.js" | ||
}, | ||
".": "./lib/index.js", | ||
"./lib/*": "./lib/*", | ||
"./package.json": "./package.json" | ||
@@ -42,3 +30,2 @@ }, | ||
"files": [ | ||
"esm", | ||
"lib", | ||
@@ -57,6 +44,5 @@ "src", | ||
"cleanup": "rimraf esm lib piral-feeds.min.js", | ||
"build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext", | ||
"build": "yarn build:bundle && yarn build:esnext", | ||
"build:bundle": "esbuild src/index.ts --outfile=piral-feeds.min.js --bundle --external:piral-core --external:react --minify --global-name=piralFeeds", | ||
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs", | ||
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext", | ||
"build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext", | ||
"typedoc": "typedoc --json ../../../docs/types/piral-feeds.json src --exclude \"src/**/*.test.*\"", | ||
@@ -67,6 +53,6 @@ "test": "echo \"Error: run tests from root\" && exit 1" | ||
"@types/react": "^18.0.0", | ||
"piral-core": "1.6.0-beta.7240", | ||
"piral-core": "1.6.0-beta.7243", | ||
"react": "^18.0.0" | ||
}, | ||
"gitHead": "2fd8ff47d9a7e0666e4e6bc1dc5a7ef45e8e9f39" | ||
"gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61395
38
1413