@blocklet/pages-kit 0.2.231 → 0.2.233
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/react-wrap-balancer.js +5 -0
- package/lib/cjs/builtin/react.js +25 -0
- package/lib/cjs/builtin/session.js +1 -3
- package/lib/cjs/utils/typescript/builtin-module-transformer.js +8 -5
- package/lib/cjs/utils/typescript/imports-removal-transformer.js +41 -0
- package/lib/esm/builtin/react-wrap-balancer.js +2 -0
- package/lib/esm/builtin/react.js +2 -0
- package/lib/esm/builtin/session.js +0 -1
- package/lib/esm/utils/typescript/builtin-module-transformer.js +8 -5
- package/lib/esm/utils/typescript/imports-removal-transformer.js +37 -0
- package/lib/types/builtin/react-wrap-balancer.d.ts +2 -0
- package/lib/types/builtin/react.d.ts +2 -0
- package/lib/types/builtin/session.d.ts +0 -1
- package/lib/types/utils/typescript/imports-removal-transformer.d.ts +2 -0
- package/package.json +1 -1
|
@@ -13,5 +13,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const react_wrap_balancer_1 = __importDefault(require("react-wrap-balancer"));
|
|
21
|
+
exports.default = react_wrap_balancer_1.default;
|
|
17
22
|
__exportStar(require("react-wrap-balancer"), exports);
|
package/lib/cjs/builtin/react.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.version = exports.useTransition = exports.useSyncExternalStore = exports.useState = exports.useRef = exports.useReducer = exports.useMemo = exports.useLayoutEffect = exports.useInsertionEffect = exports.useImperativeHandle = exports.useId = exports.useEffect = exports.useDeferredValue = exports.useDebugValue = exports.useContext = exports.useCallback = exports.startTransition = exports.memo = exports.lazy = exports.isValidElement = exports.forwardRef = exports.createRef = exports.createFactory = exports.createElement = exports.createContext = exports.cloneElement = exports.Suspense = exports.StrictMode = exports.PureComponent = exports.Profiler = exports.Fragment = exports.Component = exports.Children = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
exports.default = React;
|
|
4
29
|
var react_1 = require("react");
|
|
5
30
|
Object.defineProperty(exports, "Children", { enumerable: true, get: function () { return react_1.Children; } });
|
|
6
31
|
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return react_1.Component; } });
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSessionContext =
|
|
3
|
+
exports.useSessionContext = void 0;
|
|
4
4
|
const Session_1 = require("@arcblock/did-connect/lib/Session");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
var Session_2 = require("@arcblock/did-connect/lib/Session");
|
|
7
|
-
Object.defineProperty(exports, "SessionContext", { enumerable: true, get: function () { return Session_2.SessionContext; } });
|
|
8
6
|
function useSessionContext() {
|
|
9
7
|
return (0, react_1.useContext)(Session_1.SessionContext);
|
|
10
8
|
}
|
|
@@ -15,10 +15,11 @@ const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
15
15
|
name: (_b = (_a = s.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.text,
|
|
16
16
|
members: [],
|
|
17
17
|
};
|
|
18
|
+
builtins.push(builtin);
|
|
18
19
|
const namedBindings = (_c = s.importClause) === null || _c === void 0 ? void 0 : _c.namedBindings;
|
|
19
20
|
if (namedBindings) {
|
|
20
21
|
if (ts.isNamespaceImport(namedBindings)) {
|
|
21
|
-
builtin.
|
|
22
|
+
builtin.namespace = namedBindings.name.text;
|
|
22
23
|
}
|
|
23
24
|
namedBindings.forEachChild((node) => {
|
|
24
25
|
var _a;
|
|
@@ -27,9 +28,6 @@ const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
if (builtin.name || builtin.members.length) {
|
|
31
|
-
builtins.push(builtin);
|
|
32
|
-
}
|
|
33
31
|
return false;
|
|
34
32
|
}
|
|
35
33
|
return true;
|
|
@@ -39,7 +37,12 @@ const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
39
37
|
return [
|
|
40
38
|
builtin.name
|
|
41
39
|
? factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
42
|
-
factory.createVariableDeclaration(factory.createIdentifier(builtin.name), undefined, undefined, mod),
|
|
40
|
+
factory.createVariableDeclaration(factory.createIdentifier(builtin.name), undefined, undefined, factory.createPropertyAccessExpression(mod, 'default')),
|
|
41
|
+
], ts.NodeFlags.Const))
|
|
42
|
+
: undefined,
|
|
43
|
+
builtin.namespace
|
|
44
|
+
? factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
45
|
+
factory.createVariableDeclaration(factory.createIdentifier(builtin.namespace), undefined, undefined, mod),
|
|
43
46
|
], ts.NodeFlags.Const))
|
|
44
47
|
: undefined,
|
|
45
48
|
...builtin.members.map((member) => {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createImportsRemovalTransformer = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const createImportsRemovalTransformer = (ts, removals) => (context) => (file) => {
|
|
6
|
+
const { factory } = context;
|
|
7
|
+
const names = [];
|
|
8
|
+
const statements = file.statements.filter((s) => {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
if (ts.isImportDeclaration(s) && ts.isStringLiteral(s.moduleSpecifier)) {
|
|
11
|
+
const moduleName = s.moduleSpecifier.text || undefined;
|
|
12
|
+
if (moduleName && removals.some((i) => moduleName.startsWith(i))) {
|
|
13
|
+
const n = (_b = (_a = s.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.text;
|
|
14
|
+
if (n) {
|
|
15
|
+
names.push(n);
|
|
16
|
+
}
|
|
17
|
+
const namedBindings = (_c = s.importClause) === null || _c === void 0 ? void 0 : _c.namedBindings;
|
|
18
|
+
if (namedBindings) {
|
|
19
|
+
if (ts.isNamespaceImport(namedBindings)) {
|
|
20
|
+
names.push(namedBindings.name.text);
|
|
21
|
+
}
|
|
22
|
+
namedBindings.forEachChild((node) => {
|
|
23
|
+
if (ts.isImportSpecifier(node)) {
|
|
24
|
+
names.push(node.name.text);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
const lastImportStatementIdx = (0, lodash_1.findLastIndex)(statements, (i) => ts.isImportDeclaration(i));
|
|
34
|
+
statements.splice(lastImportStatementIdx + 1, 0, ...names.map((name) => {
|
|
35
|
+
return factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
36
|
+
factory.createVariableDeclaration(factory.createIdentifier(name), undefined, undefined, factory.createVoidZero()),
|
|
37
|
+
], ts.NodeFlags.Const));
|
|
38
|
+
}));
|
|
39
|
+
return factory.updateSourceFile(file, statements);
|
|
40
|
+
};
|
|
41
|
+
exports.createImportsRemovalTransformer = createImportsRemovalTransformer;
|
package/lib/esm/builtin/react.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default React;
|
|
1
3
|
export { Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, } from 'react';
|
|
@@ -12,10 +12,11 @@ export const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
12
12
|
name: (_b = (_a = s.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.text,
|
|
13
13
|
members: [],
|
|
14
14
|
};
|
|
15
|
+
builtins.push(builtin);
|
|
15
16
|
const namedBindings = (_c = s.importClause) === null || _c === void 0 ? void 0 : _c.namedBindings;
|
|
16
17
|
if (namedBindings) {
|
|
17
18
|
if (ts.isNamespaceImport(namedBindings)) {
|
|
18
|
-
builtin.
|
|
19
|
+
builtin.namespace = namedBindings.name.text;
|
|
19
20
|
}
|
|
20
21
|
namedBindings.forEachChild((node) => {
|
|
21
22
|
var _a;
|
|
@@ -24,9 +25,6 @@ export const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
if (builtin.name || builtin.members.length) {
|
|
28
|
-
builtins.push(builtin);
|
|
29
|
-
}
|
|
30
28
|
return false;
|
|
31
29
|
}
|
|
32
30
|
return true;
|
|
@@ -36,7 +34,12 @@ export const createBuiltinModuleTransformer = (ts) => (context) => (file) => {
|
|
|
36
34
|
return [
|
|
37
35
|
builtin.name
|
|
38
36
|
? factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
39
|
-
factory.createVariableDeclaration(factory.createIdentifier(builtin.name), undefined, undefined, mod),
|
|
37
|
+
factory.createVariableDeclaration(factory.createIdentifier(builtin.name), undefined, undefined, factory.createPropertyAccessExpression(mod, 'default')),
|
|
38
|
+
], ts.NodeFlags.Const))
|
|
39
|
+
: undefined,
|
|
40
|
+
builtin.namespace
|
|
41
|
+
? factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
42
|
+
factory.createVariableDeclaration(factory.createIdentifier(builtin.namespace), undefined, undefined, mod),
|
|
40
43
|
], ts.NodeFlags.Const))
|
|
41
44
|
: undefined,
|
|
42
45
|
...builtin.members.map((member) => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { findLastIndex } from 'lodash';
|
|
2
|
+
export const createImportsRemovalTransformer = (ts, removals) => (context) => (file) => {
|
|
3
|
+
const { factory } = context;
|
|
4
|
+
const names = [];
|
|
5
|
+
const statements = file.statements.filter((s) => {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
if (ts.isImportDeclaration(s) && ts.isStringLiteral(s.moduleSpecifier)) {
|
|
8
|
+
const moduleName = s.moduleSpecifier.text || undefined;
|
|
9
|
+
if (moduleName && removals.some((i) => moduleName.startsWith(i))) {
|
|
10
|
+
const n = (_b = (_a = s.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.text;
|
|
11
|
+
if (n) {
|
|
12
|
+
names.push(n);
|
|
13
|
+
}
|
|
14
|
+
const namedBindings = (_c = s.importClause) === null || _c === void 0 ? void 0 : _c.namedBindings;
|
|
15
|
+
if (namedBindings) {
|
|
16
|
+
if (ts.isNamespaceImport(namedBindings)) {
|
|
17
|
+
names.push(namedBindings.name.text);
|
|
18
|
+
}
|
|
19
|
+
namedBindings.forEachChild((node) => {
|
|
20
|
+
if (ts.isImportSpecifier(node)) {
|
|
21
|
+
names.push(node.name.text);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
const lastImportStatementIdx = findLastIndex(statements, (i) => ts.isImportDeclaration(i));
|
|
31
|
+
statements.splice(lastImportStatementIdx + 1, 0, ...names.map((name) => {
|
|
32
|
+
return factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
33
|
+
factory.createVariableDeclaration(factory.createIdentifier(name), undefined, undefined, factory.createVoidZero()),
|
|
34
|
+
], ts.NodeFlags.Const));
|
|
35
|
+
}));
|
|
36
|
+
return factory.updateSourceFile(file, statements);
|
|
37
|
+
};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default React;
|
|
1
3
|
export { Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, } from 'react';
|