@blocklet/pages-kit 0.3.21 → 0.3.23
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/utils.js +16 -4
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +1 -2
- package/lib/cjs/utils/preload.js +2 -0
- package/lib/cjs/utils/property.js +15 -0
- package/lib/esm/builtin/utils.js +11 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +1 -2
- package/lib/esm/utils/preload.js +2 -0
- package/lib/esm/utils/property.js +12 -0
- package/lib/types/builtin/utils.d.ts +1 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/core.d.ts +1 -1
- package/lib/types/utils/preload.d.ts +1 -1
- package/package.json +3 -1
|
@@ -55,8 +55,7 @@ const CustomComponentRenderer_1 = __importDefault(require("../components/CustomC
|
|
|
55
55
|
const builtin_1 = require("../types/builtin");
|
|
56
56
|
function injectGlobalComponents() {
|
|
57
57
|
const win = window;
|
|
58
|
-
if (win[
|
|
59
|
-
return;
|
|
58
|
+
// if (win[BuiltinModulesGlobalVariableName]) return;
|
|
60
59
|
win[builtin_1.BuiltinModulesGlobalVariableName] = {
|
|
61
60
|
modules: {
|
|
62
61
|
'@blocklet/pages-kit/builtin/pages-kit': { CustomComponentRenderer: CustomComponentRenderer_1.default },
|
package/lib/cjs/utils/preload.js
CHANGED
|
@@ -14,6 +14,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.injectPreloadComponents = injectPreloadComponents;
|
|
15
15
|
const types_1 = require("../types");
|
|
16
16
|
function injectPreloadComponents(data) {
|
|
17
|
+
if (!data)
|
|
18
|
+
return null;
|
|
17
19
|
const injectState = {
|
|
18
20
|
config: data.config,
|
|
19
21
|
components: Object.fromEntries(Object.entries(data.components).map(([componentId, { script, component }]) => {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RenderNestedComponent = void 0;
|
|
4
7
|
exports.componentUMDName = componentUMDName;
|
|
5
8
|
exports.mergeComponent = mergeComponent;
|
|
6
9
|
exports.parsePropertyValue = parsePropertyValue;
|
|
7
10
|
exports.assignNullableFields = assignNullableFields;
|
|
11
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
8
12
|
function componentUMDName({ componentId }) {
|
|
9
13
|
return `PagesCustomComponent${componentId}`;
|
|
10
14
|
}
|
|
@@ -73,6 +77,17 @@ function parsePropertyValue(property, value, { locale, defaultLocale }) {
|
|
|
73
77
|
return undefined;
|
|
74
78
|
}
|
|
75
79
|
}
|
|
80
|
+
if (property.type === 'yaml') {
|
|
81
|
+
if (!value)
|
|
82
|
+
return undefined;
|
|
83
|
+
try {
|
|
84
|
+
return js_yaml_1.default.load(value);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('parse yaml value error', error);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
76
91
|
if (property.type === 'component') {
|
|
77
92
|
const componentId = value === null || value === void 0 ? void 0 : value.componentId;
|
|
78
93
|
if (typeof componentId !== 'string')
|
package/lib/esm/builtin/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { joinURL } from 'ufo';
|
|
1
2
|
export { joinURL, withQuery, getQuery } from 'ufo';
|
|
2
3
|
export function getComponentMountPoint(name) {
|
|
3
4
|
var _a, _b;
|
|
@@ -7,3 +8,13 @@ export function getComponentMountPoint(name) {
|
|
|
7
8
|
}
|
|
8
9
|
return (_b = (_a = globalThis.blocklet) === null || _a === void 0 ? void 0 : _a.componentMountPoints.find((i) => i.name === name || i.did === name)) === null || _b === void 0 ? void 0 : _b.mountPoint;
|
|
9
10
|
}
|
|
11
|
+
export function getMediaKitAbsoluteUrl(url) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const PREFIX = ((_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || '/';
|
|
14
|
+
const IMAGE_BIN_DID = 'z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9';
|
|
15
|
+
const IMAGE_BIN_PREFIX = ((_b = blocklet === null || blocklet === void 0 ? void 0 : blocklet.componentMountPoints.find((i) => i.did === IMAGE_BIN_DID)) === null || _b === void 0 ? void 0 : _b.mountPoint) || joinURL(PREFIX, '/image-bin');
|
|
16
|
+
if (url && url.startsWith('mediakit://')) {
|
|
17
|
+
return window.location.origin + joinURL(IMAGE_BIN_PREFIX, 'uploads', url.replace('mediakit://', ''));
|
|
18
|
+
}
|
|
19
|
+
return url;
|
|
20
|
+
}
|