@blocklet/pages-kit-block-studio 0.0.10 → 0.0.11
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/{block-studio → middlewares}/init-resource-router.js +3 -3
- package/lib/cjs/{block-studio/plugins → plugins}/vite-plugin-block-studio.js +22 -22
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/{block-studio → utils}/build-lib.js +2 -3
- package/lib/cjs/{block-studio → utils}/generate-wrapper-code.js +21 -5
- package/lib/cjs/{block-studio/utils.js → utils/helper.js} +2 -0
- package/lib/esm/{block-studio → middlewares}/init-resource-router.js +2 -2
- package/lib/esm/{block-studio/plugins → plugins}/vite-plugin-block-studio.js +16 -16
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/{block-studio → utils}/build-lib.js +1 -2
- package/lib/esm/{block-studio → utils}/generate-wrapper-code.js +21 -5
- package/lib/esm/{block-studio/utils.js → utils/helper.js} +1 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/generate-wrapper-code.d.ts +5 -0
- package/lib/types/{block-studio/utils.d.ts → utils/helper.d.ts} +1 -0
- package/package.json +28 -25
- package/lib/cjs/utils/index.js +0 -1
- package/lib/esm/utils/index.js +0 -1
- package/lib/types/block-studio/generate-wrapper-code.d.ts +0 -5
- package/lib/types/utils/index.d.ts +0 -0
- /package/lib/cjs/{block-studio/plugins → plugins}/_theme.js +0 -0
- /package/lib/cjs/{block-studio/plugins → plugins}/index.js +0 -0
- /package/lib/cjs/{block-studio/plugins → plugins}/vite-plugin-html-transform.js +0 -0
- /package/lib/cjs/{block-studio/plugins → plugins}/vite-plugin-remote-script-localizer.js +0 -0
- /package/lib/esm/{block-studio/plugins → plugins}/_theme.js +0 -0
- /package/lib/esm/{block-studio/plugins → plugins}/index.js +0 -0
- /package/lib/esm/{block-studio/plugins → plugins}/vite-plugin-html-transform.js +0 -0
- /package/lib/esm/{block-studio/plugins → plugins}/vite-plugin-remote-script-localizer.js +0 -0
- /package/lib/types/{block-studio → middlewares}/init-resource-router.d.ts +0 -0
- /package/lib/types/{block-studio/plugins → plugins}/_theme.d.ts +0 -0
- /package/lib/types/{block-studio/plugins → plugins}/index.d.ts +0 -0
- /package/lib/types/{block-studio/plugins → plugins}/vite-plugin-block-studio.d.ts +0 -0
- /package/lib/types/{block-studio/plugins → plugins}/vite-plugin-html-transform.d.ts +0 -0
- /package/lib/types/{block-studio/plugins → plugins}/vite-plugin-remote-script-localizer.d.ts +0 -0
- /package/lib/types/{block-studio → utils}/build-lib.d.ts +0 -0
|
@@ -54,9 +54,9 @@ const child_process_1 = require("child_process");
|
|
|
54
54
|
const express_1 = require("express");
|
|
55
55
|
const fs_1 = __importDefault(require("fs"));
|
|
56
56
|
const path_1 = __importStar(require("path"));
|
|
57
|
-
const
|
|
57
|
+
const helper_1 = require("../utils/helper");
|
|
58
58
|
const DID = 'z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV';
|
|
59
|
-
const RESOURCE_TYPE = '
|
|
59
|
+
const RESOURCE_TYPE = 'page';
|
|
60
60
|
const allTag = '@ALL_COMPONENTS';
|
|
61
61
|
function copyFile(src, dest) {
|
|
62
62
|
return new Promise((resolve, reject) => {
|
|
@@ -104,7 +104,7 @@ exports.initResourceRouter = (0, express_1.Router)();
|
|
|
104
104
|
exports.initResourceRouter.get('/', (_req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
105
|
const resources = [];
|
|
106
106
|
const rootDir = process.cwd();
|
|
107
|
-
const files = (0,
|
|
107
|
+
const files = (0, helper_1.findComponentFiles)({ cwd: rootDir });
|
|
108
108
|
for (const file of files) {
|
|
109
109
|
// const filePath = path.join(rootDir, file);
|
|
110
110
|
// const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
@@ -48,18 +48,18 @@ exports.initBlockStudioPlugins = initBlockStudioPlugins;
|
|
|
48
48
|
const fs_1 = require("fs");
|
|
49
49
|
const path = __importStar(require("path"));
|
|
50
50
|
const vite_plugin_react_pages_1 = __importStar(require("vite-plugin-react-pages"));
|
|
51
|
-
const
|
|
51
|
+
const helper_1 = require("../utils/helper");
|
|
52
52
|
const vite_plugin_html_transform_1 = require("./vite-plugin-html-transform");
|
|
53
53
|
// import initRemoteScriptLocalizerPlugin from './vite-plugin-remote-script-localizer';
|
|
54
54
|
function initBlockStudioPlugins(options) {
|
|
55
55
|
const workingDir = (options === null || options === void 0 ? void 0 : options.cwd) || process.cwd();
|
|
56
|
-
const entryFilesPattern = (options === null || options === void 0 ? void 0 : options.entryFilesPattern) || (0,
|
|
57
|
-
(0,
|
|
56
|
+
const entryFilesPattern = (options === null || options === void 0 ? void 0 : options.entryFilesPattern) || (0, helper_1.getBlockEntryFilesPattern)();
|
|
57
|
+
(0, helper_1.setBlockEntryFilesPattern)(entryFilesPattern);
|
|
58
58
|
// fallback to __dirname if _theme.tsx not exists
|
|
59
59
|
const pagesDir = (0, fs_1.existsSync)(path.join(workingDir, '_theme.tsx')) ? workingDir : __dirname.replace('cjs', 'esm');
|
|
60
|
-
|
|
60
|
+
helper_1.logger.log('initBlockStudioPlugins options: ', {
|
|
61
61
|
cwd: workingDir,
|
|
62
|
-
entryFilesPattern: (0,
|
|
62
|
+
entryFilesPattern: (0, helper_1.getBlockEntryFilesPattern)(),
|
|
63
63
|
pagesDir,
|
|
64
64
|
});
|
|
65
65
|
return [
|
|
@@ -87,25 +87,25 @@ function initBlockStudioPlugins(options) {
|
|
|
87
87
|
const filterModules = process.argv.includes('--filter')
|
|
88
88
|
? (_a = process.argv[process.argv.indexOf('--filter') + 1]) === null || _a === void 0 ? void 0 : _a.split(',')
|
|
89
89
|
: null;
|
|
90
|
-
const multiMode = !!process.argv.includes('--multi');
|
|
91
90
|
const name = yield Promise.resolve(`${`${workingDir}/package.json`}`).then(s => __importStar(require(s))).then((res) => res.name).catch(() => 'MyLib');
|
|
91
|
+
const entryList = (0, helper_1.findComponentFiles)({ cwd: workingDir })
|
|
92
|
+
.map((entry) => {
|
|
93
|
+
const { blockName } = entry;
|
|
94
|
+
const { isHtml } = entry;
|
|
95
|
+
const { file } = entry;
|
|
96
|
+
if (isHtml) {
|
|
97
|
+
return [blockName, `${vite_plugin_html_transform_1.VIRTUAL_MODULE_ID}?dir=${path.dirname(file)}`];
|
|
98
|
+
}
|
|
99
|
+
return [blockName, path.resolve(workingDir, file)];
|
|
100
|
+
})
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.filter(([blockName]) => !filterModules || filterModules.includes(blockName || ''));
|
|
103
|
+
const multiMode = entryList.length > 1;
|
|
92
104
|
return {
|
|
93
105
|
build: Object.assign({ cssCodeSplit: false, lib: {
|
|
94
106
|
name,
|
|
95
|
-
entry: Object.assign({}, Object.fromEntries(
|
|
96
|
-
|
|
97
|
-
const { blockName } = entry;
|
|
98
|
-
const { isHtml } = entry;
|
|
99
|
-
const { file } = entry;
|
|
100
|
-
if (isHtml) {
|
|
101
|
-
return [blockName, `${vite_plugin_html_transform_1.VIRTUAL_MODULE_ID}?dir=${path.dirname(file)}`];
|
|
102
|
-
}
|
|
103
|
-
return [blockName, path.resolve(workingDir, file)];
|
|
104
|
-
})
|
|
105
|
-
.filter(Boolean)
|
|
106
|
-
.filter(([blockName]) => !filterModules || filterModules.includes(blockName || '')))),
|
|
107
|
-
// multiMode not support umd
|
|
108
|
-
formats: ['es', multiMode ? 'umd' : 'cjs'],
|
|
107
|
+
entry: Object.assign({}, Object.fromEntries(entryList)),
|
|
108
|
+
formats: ['es', !multiMode ? 'umd' : 'cjs'],
|
|
109
109
|
fileName: (format, entryName) => `${format}/${entryName}.js`,
|
|
110
110
|
}, rollupOptions: {
|
|
111
111
|
external: [
|
|
@@ -151,11 +151,11 @@ function initBlockStudioPlugins(options) {
|
|
|
151
151
|
pagesDir,
|
|
152
152
|
pageStrategy: new vite_plugin_react_pages_1.DefaultPageStrategy({
|
|
153
153
|
extraFindPages: (_pagesDir, helpers) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
helpers.watchFiles(workingDir, (0,
|
|
154
|
+
helpers.watchFiles(workingDir, (0, helper_1.getBlockEntryFilesPattern)(), function fileHandler(file, api) {
|
|
155
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
156
|
const { relative, path: filePath } = file;
|
|
157
157
|
const isHtml = relative.endsWith('.html');
|
|
158
|
-
const blockName = (0,
|
|
158
|
+
const blockName = (0, helper_1.getBlockName)(relative);
|
|
159
159
|
const pageId = `/${blockName}`;
|
|
160
160
|
api.addPageData({
|
|
161
161
|
pageId,
|