@blocklet/pages-kit 0.2.228 → 0.2.229
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/cjs/builtin/call.js +24 -0
- package/lib/cjs/builtin/stream.js +28 -0
- package/lib/cjs/utils/inject-global-components.js +4 -0
- package/lib/esm/builtin/call.js +20 -0
- package/lib/esm/builtin/stream.js +24 -0
- package/lib/esm/utils/inject-global-components.js +4 -0
- package/lib/types/builtin/call.d.ts +13 -0
- package/lib/types/builtin/stream.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
function call(input) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const prefix = (0, utils_1.getComponentMountPoint)('pages-kit');
|
|
17
|
+
return fetch((0, utils_1.joinURL)(prefix, '/api/call'), {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: Object.assign(Object.assign({}, input.headers), { 'Content-Type': 'application/json' }),
|
|
20
|
+
body: JSON.stringify(input),
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.call = call;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventSourceParserStream = void 0;
|
|
4
|
+
const eventsource_parser_1 = require("eventsource-parser");
|
|
5
|
+
class EventSourceParserStream extends TransformStream {
|
|
6
|
+
constructor() {
|
|
7
|
+
let parser;
|
|
8
|
+
super({
|
|
9
|
+
start(controller) {
|
|
10
|
+
parser = (0, eventsource_parser_1.createParser)((event) => {
|
|
11
|
+
if (event.type === 'event') {
|
|
12
|
+
try {
|
|
13
|
+
const json = JSON.parse(event.data);
|
|
14
|
+
controller.enqueue(json);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error('parse chunk error', { error, data: event.data });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
transform(chunk) {
|
|
23
|
+
parser === null || parser === void 0 ? void 0 : parser.feed(chunk);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.EventSourceParserStream = EventSourceParserStream;
|
|
@@ -23,12 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const call = __importStar(require("../builtin/call"));
|
|
26
27
|
const builtinIconifyReact = __importStar(require("../builtin/iconify/react"));
|
|
27
28
|
const builtinMuiLab = __importStar(require("../builtin/mui/lab"));
|
|
28
29
|
const builtinMuiMaterial = __importStar(require("../builtin/mui/material"));
|
|
29
30
|
const builtinReact = __importStar(require("../builtin/react"));
|
|
30
31
|
const builtinReactHookForm = __importStar(require("../builtin/react-hook-form"));
|
|
31
32
|
const reactWrapBalancer = __importStar(require("../builtin/react-wrap-balancer"));
|
|
33
|
+
const stream = __importStar(require("../builtin/stream"));
|
|
32
34
|
const builtinUtils = __importStar(require("../builtin/utils"));
|
|
33
35
|
const builtinZustand = __importStar(require("../builtin/zustand"));
|
|
34
36
|
const builtinZustandMiddlewareImmer = __importStar(require("../builtin/zustand/middleware/immer"));
|
|
@@ -46,6 +48,8 @@ function injectGlobalComponents() {
|
|
|
46
48
|
'@blocklet/pages-kit/builtin/zustand': builtinZustand,
|
|
47
49
|
'@blocklet/pages-kit/builtin/zustand/middleware/immer': builtinZustandMiddlewareImmer,
|
|
48
50
|
'@blocklet/pages-kit/builtin/react-wrap-balancer': reactWrapBalancer,
|
|
51
|
+
'@blocklet/pages-kit/builtin/call': call,
|
|
52
|
+
'@blocklet/pages-kit/builtin/stream': stream,
|
|
49
53
|
},
|
|
50
54
|
require(module) {
|
|
51
55
|
return win[builtin_1.BuiltinModulesGlobalVariableName].modules[module];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getComponentMountPoint, joinURL } from './utils';
|
|
11
|
+
export function call(input) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const prefix = getComponentMountPoint('pages-kit');
|
|
14
|
+
return fetch(joinURL(prefix, '/api/call'), {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: Object.assign(Object.assign({}, input.headers), { 'Content-Type': 'application/json' }),
|
|
17
|
+
body: JSON.stringify(input),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createParser } from 'eventsource-parser';
|
|
2
|
+
export class EventSourceParserStream extends TransformStream {
|
|
3
|
+
constructor() {
|
|
4
|
+
let parser;
|
|
5
|
+
super({
|
|
6
|
+
start(controller) {
|
|
7
|
+
parser = createParser((event) => {
|
|
8
|
+
if (event.type === 'event') {
|
|
9
|
+
try {
|
|
10
|
+
const json = JSON.parse(event.data);
|
|
11
|
+
controller.enqueue(json);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error('parse chunk error', { error, data: event.data });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
transform(chunk) {
|
|
20
|
+
parser === null || parser === void 0 ? void 0 : parser.feed(chunk);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import * as call from '../builtin/call';
|
|
1
2
|
import * as builtinIconifyReact from '../builtin/iconify/react';
|
|
2
3
|
import * as builtinMuiLab from '../builtin/mui/lab';
|
|
3
4
|
import * as builtinMuiMaterial from '../builtin/mui/material';
|
|
4
5
|
import * as builtinReact from '../builtin/react';
|
|
5
6
|
import * as builtinReactHookForm from '../builtin/react-hook-form';
|
|
6
7
|
import * as reactWrapBalancer from '../builtin/react-wrap-balancer';
|
|
8
|
+
import * as stream from '../builtin/stream';
|
|
7
9
|
import * as builtinUtils from '../builtin/utils';
|
|
8
10
|
import * as builtinZustand from '../builtin/zustand';
|
|
9
11
|
import * as builtinZustandMiddlewareImmer from '../builtin/zustand/middleware/immer';
|
|
@@ -21,6 +23,8 @@ function injectGlobalComponents() {
|
|
|
21
23
|
'@blocklet/pages-kit/builtin/zustand': builtinZustand,
|
|
22
24
|
'@blocklet/pages-kit/builtin/zustand/middleware/immer': builtinZustandMiddlewareImmer,
|
|
23
25
|
'@blocklet/pages-kit/builtin/react-wrap-balancer': reactWrapBalancer,
|
|
26
|
+
'@blocklet/pages-kit/builtin/call': call,
|
|
27
|
+
'@blocklet/pages-kit/builtin/stream': stream,
|
|
24
28
|
},
|
|
25
29
|
require(module) {
|
|
26
30
|
return win[BuiltinModulesGlobalVariableName].modules[module];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.229",
|
|
4
4
|
"description": "Pages Kit components and utils",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"@blocklet/sdk": "^1.16.22",
|
|
97
97
|
"@iconify/react": "^4.1.1",
|
|
98
98
|
"axios": "^1.6.7",
|
|
99
|
+
"eventsource-parser": "^1.1.1",
|
|
99
100
|
"immer": "^10.0.3",
|
|
100
101
|
"lodash": "^4.17.21",
|
|
101
102
|
"nanoid": "^3.3.7",
|