Skip to content

Commit

Permalink
feat(platform): implement "support import multiple element contributes"
Browse files Browse the repository at this point in the history
add ShowPublishedElements;
support import multiple element contributes;
app binary file add store allElements;
remove element contribute protocol;
  • Loading branch information
yyc-git committed Nov 18, 2023
1 parent 3757c77 commit 54200cc
Show file tree
Hide file tree
Showing 80 changed files with 1,768 additions and 1,165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function isNullable(prim) {
return prim == null;
}

function getEmpty(param) {

}

var map = Js_null_undefined.bind;

export {
Expand All @@ -35,5 +39,6 @@ export {
map ,
bind ,
isNullable ,
getEmpty ,
}
/* No side effect */
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function isNullable(prim) {
return prim == null;
}

function getEmpty(param) {

}

var map = Js_null_undefined.bind;

exports.getExn = getExn;
Expand All @@ -34,4 +38,5 @@ exports.getWithDefault = getWithDefault;
exports.map = map;
exports.bind = bind;
exports.isNullable = isNullable;
exports.getEmpty = getEmpty;
/* No side effect */
2 changes: 2 additions & 0 deletions defaults/meta3d-commonlib/src/structure/NullableSt.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ let bind = (nullableData, func) => {
}

let isNullable = Js.Nullable.isNullable

let getEmpty = () => Js.Nullable.undefined
48 changes: 25 additions & 23 deletions defaults/meta3d/lib/es6_global/src/app_and_package/AppManager.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ function _flatten(arr) {
return ArraySt$Meta3dCommonlib.reduceOneParam(arr, Js_array.concat, []);
}

function generate(allContributeFileData, allPackageBinaryFiles, allPackageBinaryFileDataStoredInApp, configData, startPackageProtocolName) {
function generate(allContributeFileData, allPackageBinaryFiles, allPackageBinaryFileDataStoredInApp, selectedElements, configData, startPackageProtocolName) {
var encoder = new TextEncoder();
return BinaryFileOperator$Meta3d.generate(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ManagerUtils$Meta3d.mergeAllPackageBinaryFiles(ManagerUtils$Meta3d.generate([
[],
allContributeFileData
]))(allPackageBinaryFiles), new Uint8Array(BinaryFileOperator$Meta3d.generate(_flatten(ArraySt$Meta3dCommonlib.map(allPackageBinaryFileDataStoredInApp, (function (param) {
return [
TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(param[0]), encoder),
new Uint8Array(param[1])
];
})))))), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(NullableSt$Meta3dCommonlib.getWithDefault(configData, [])), encoder)), TextEncoder$Meta3d.encodeUint8Array(startPackageProtocolName, encoder)));
return BinaryFileOperator$Meta3d.generate(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ManagerUtils$Meta3d.mergeAllPackageBinaryFiles(ManagerUtils$Meta3d.generate([
[],
allContributeFileData
]))(allPackageBinaryFiles), new Uint8Array(BinaryFileOperator$Meta3d.generate(_flatten(ArraySt$Meta3dCommonlib.map(allPackageBinaryFileDataStoredInApp, (function (param) {
return [
TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(param[0]), encoder),
new Uint8Array(param[1])
];
})))))), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(selectedElements), encoder)), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(NullableSt$Meta3dCommonlib.getWithDefault(configData, [])), encoder)), TextEncoder$Meta3d.encodeUint8Array(startPackageProtocolName, encoder)));
}

function getExtensionFuncDataStr(extensionFuncData) {
Expand Down Expand Up @@ -77,7 +77,7 @@ function _parseAllPackageUint8StoredInApp(allPackageUint8StoredInApp) {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
174,
178,
32
],
Error: new Error()
Expand Down Expand Up @@ -111,19 +111,19 @@ function _decodeConfigData(configData) {
return JSON.parse(FileUtils$Meta3d.removeAlignedEmptyChars(TextDecoder$Meta3d.decodeUint8Array(configData, decoder)));
}

function _decodeStartPackageProtocolName(startPackageProtocolName) {
function _decode(data) {
var decoder = new TextDecoder("utf-8");
return TextDecoder$Meta3d.decodeUint8Array(startPackageProtocolName, decoder);
return TextDecoder$Meta3d.decodeUint8Array(data, decoder);
}

function load(appBinaryFile) {
var match = BinaryFileOperator$Meta3d.load(appBinaryFile);
if (match.length !== 6) {
if (match.length !== 7) {
throw {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
225,
227,
6
],
Error: new Error()
Expand All @@ -133,8 +133,8 @@ function load(appBinaryFile) {
var allContributeUint8 = match[1];
var allPackageUint8NotStoredInApp = match[2];
var allPackageUint8StoredInApp = match[3];
var configData = match[4];
var startPackageProtocolName = match[5];
var configData = match[5];
var startPackageProtocolName = match[6];
var match$1 = ManagerUtils$Meta3d.load([
allExtensionUint8,
allContributeUint8,
Expand All @@ -144,7 +144,7 @@ function load(appBinaryFile) {
var state = _loadAllPackageUint8StoredInApp(match$1[0], allPackageUint8StoredInApp);
return [
state,
_decodeStartPackageProtocolName(startPackageProtocolName),
_decode(startPackageProtocolName),
_decodeConfigData(configData)
];
}
Expand All @@ -155,12 +155,12 @@ function start(param) {

function getAllDataOfApp(appBinaryFile) {
var match = BinaryFileOperator$Meta3d.load(appBinaryFile);
if (match.length !== 6) {
if (match.length !== 7) {
throw {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
287,
296,
6
],
Error: new Error()
Expand All @@ -170,15 +170,17 @@ function getAllDataOfApp(appBinaryFile) {
var allContributeUint8 = match[1];
var allPackageUint8NotStoredInApp = match[2];
var allPackageUint8StoredInApp = match[3];
var configData = match[4];
var selectedElementsUint8 = match[4];
var configData = match[5];
return [
_parseAllPackageUint8StoredInApp(allPackageUint8StoredInApp),
ManagerUtils$Meta3d.parse3([
allExtensionUint8,
allContributeUint8,
allPackageUint8NotStoredInApp
]),
_decodeConfigData(configData)
_decodeConfigData(configData),
JSON.parse(_decode(selectedElementsUint8))
];
}

Expand All @@ -194,7 +196,7 @@ export {
_parseAllPackageUint8StoredInApp ,
_loadAllPackageUint8StoredInApp ,
_decodeConfigData ,
_decodeStartPackageProtocolName ,
_decode ,
load ,
start ,
getAllDataOfApp ,
Expand Down
48 changes: 25 additions & 23 deletions defaults/meta3d/lib/js/src/app_and_package/AppManager.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ function _flatten(arr) {
return ArraySt$Meta3dCommonlib.reduceOneParam(arr, Js_array.concat, []);
}

function generate(allContributeFileData, allPackageBinaryFiles, allPackageBinaryFileDataStoredInApp, configData, startPackageProtocolName) {
function generate(allContributeFileData, allPackageBinaryFiles, allPackageBinaryFileDataStoredInApp, selectedElements, configData, startPackageProtocolName) {
var encoder = new TextEncoder();
return BinaryFileOperator$Meta3d.generate(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ManagerUtils$Meta3d.mergeAllPackageBinaryFiles(ManagerUtils$Meta3d.generate([
[],
allContributeFileData
]))(allPackageBinaryFiles), new Uint8Array(BinaryFileOperator$Meta3d.generate(_flatten(ArraySt$Meta3dCommonlib.map(allPackageBinaryFileDataStoredInApp, (function (param) {
return [
TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(param[0]), encoder),
new Uint8Array(param[1])
];
})))))), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(NullableSt$Meta3dCommonlib.getWithDefault(configData, [])), encoder)), TextEncoder$Meta3d.encodeUint8Array(startPackageProtocolName, encoder)));
return BinaryFileOperator$Meta3d.generate(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ArraySt$Meta3dCommonlib.push(ManagerUtils$Meta3d.mergeAllPackageBinaryFiles(ManagerUtils$Meta3d.generate([
[],
allContributeFileData
]))(allPackageBinaryFiles), new Uint8Array(BinaryFileOperator$Meta3d.generate(_flatten(ArraySt$Meta3dCommonlib.map(allPackageBinaryFileDataStoredInApp, (function (param) {
return [
TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(param[0]), encoder),
new Uint8Array(param[1])
];
})))))), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(selectedElements), encoder)), TextEncoder$Meta3d.encodeUint8Array(JSON.stringify(NullableSt$Meta3dCommonlib.getWithDefault(configData, [])), encoder)), TextEncoder$Meta3d.encodeUint8Array(startPackageProtocolName, encoder)));
}

function getExtensionFuncDataStr(extensionFuncData) {
Expand Down Expand Up @@ -77,7 +77,7 @@ function _parseAllPackageUint8StoredInApp(allPackageUint8StoredInApp) {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
174,
178,
32
],
Error: new Error()
Expand Down Expand Up @@ -111,19 +111,19 @@ function _decodeConfigData(configData) {
return JSON.parse(FileUtils$Meta3d.removeAlignedEmptyChars(TextDecoder$Meta3d.decodeUint8Array(configData, decoder)));
}

function _decodeStartPackageProtocolName(startPackageProtocolName) {
function _decode(data) {
var decoder = new TextDecoder("utf-8");
return TextDecoder$Meta3d.decodeUint8Array(startPackageProtocolName, decoder);
return TextDecoder$Meta3d.decodeUint8Array(data, decoder);
}

function load(appBinaryFile) {
var match = BinaryFileOperator$Meta3d.load(appBinaryFile);
if (match.length !== 6) {
if (match.length !== 7) {
throw {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
225,
227,
6
],
Error: new Error()
Expand All @@ -133,8 +133,8 @@ function load(appBinaryFile) {
var allContributeUint8 = match[1];
var allPackageUint8NotStoredInApp = match[2];
var allPackageUint8StoredInApp = match[3];
var configData = match[4];
var startPackageProtocolName = match[5];
var configData = match[5];
var startPackageProtocolName = match[6];
var match$1 = ManagerUtils$Meta3d.load([
allExtensionUint8,
allContributeUint8,
Expand All @@ -144,7 +144,7 @@ function load(appBinaryFile) {
var state = _loadAllPackageUint8StoredInApp(match$1[0], allPackageUint8StoredInApp);
return [
state,
_decodeStartPackageProtocolName(startPackageProtocolName),
_decode(startPackageProtocolName),
_decodeConfigData(configData)
];
}
Expand All @@ -155,12 +155,12 @@ function start(param) {

function getAllDataOfApp(appBinaryFile) {
var match = BinaryFileOperator$Meta3d.load(appBinaryFile);
if (match.length !== 6) {
if (match.length !== 7) {
throw {
RE_EXN_ID: "Match_failure",
_1: [
"AppManager.res",
287,
296,
6
],
Error: new Error()
Expand All @@ -170,15 +170,17 @@ function getAllDataOfApp(appBinaryFile) {
var allContributeUint8 = match[1];
var allPackageUint8NotStoredInApp = match[2];
var allPackageUint8StoredInApp = match[3];
var configData = match[4];
var selectedElementsUint8 = match[4];
var configData = match[5];
return [
_parseAllPackageUint8StoredInApp(allPackageUint8StoredInApp),
ManagerUtils$Meta3d.parse3([
allExtensionUint8,
allContributeUint8,
allPackageUint8NotStoredInApp
]),
_decodeConfigData(configData)
_decodeConfigData(configData),
JSON.parse(_decode(selectedElementsUint8))
];
}

Expand All @@ -193,7 +195,7 @@ exports.execGetContributeFunc = execGetContributeFunc;
exports._parseAllPackageUint8StoredInApp = _parseAllPackageUint8StoredInApp;
exports._loadAllPackageUint8StoredInApp = _loadAllPackageUint8StoredInApp;
exports._decodeConfigData = _decodeConfigData;
exports._decodeStartPackageProtocolName = _decodeStartPackageProtocolName;
exports._decode = _decode;
exports.load = load;
exports.start = start;
exports.getAllDataOfApp = getAllDataOfApp;
Expand Down
9 changes: 6 additions & 3 deletions defaults/meta3d/src/Main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { extensionProtocolName, getExtensionService, getExtensionLife, state, ap
import { actionName, supportedEventName, } from "meta3d-type/src/contribute/UIControlProtocolConfigType"
import { needConfigData } from "meta3d-type/src/package/StartPackageProtocolConfigType"
import { extensionFileData, contributeFileData, extensionPackageData, contributePackageData, extensionFuncData, contributeFuncData } from "./file/ExtensionFileType"
import { extensionPackageData as extensionPackageDataApp, contributePackageData as contributePackageDataApp, packageData } from "./app_and_package/AppAndPackageFileType"
import { extensionPackageData as extensionPackageDataApp, contributePackageData as contributePackageDataApp, packageData, selectedElements } from "./app_and_package/AppAndPackageFileType"
import { nullable } from "meta3d-commonlib-ts/src/nullable"

export function prepare(): state
Expand Down Expand Up @@ -90,6 +90,7 @@ export function generateApp(
allContributeFileData: Array<[contributePackageDataApp, contributeFuncData]>,
allPackageBinaryFiles: allPackageBinaryFiles,
allPackageBinaryFileDataStoredInApp: Array<[packageProtocolName, ArrayBuffer]>,
selectedElements: selectedElements,
configData: nullable<startConfigData>,
startPackageProtocolName: string
): ArrayBuffer
Expand Down Expand Up @@ -125,11 +126,13 @@ export function getAllDataOfPackage(
]
]

export function getAllExtensionAndContributeFileDataOfApp(
export function getAllDataOfApp(
appBinaryFile: ArrayBuffer
): [
Array<[extensionPackageDataApp, extensionFuncData]>,
Array<[contributePackageDataApp, contributeFuncData]>
Array<[contributePackageDataApp, contributeFuncData]>,
Array<ArrayBuffer>,
selectedElements
]

export function startApp(
Expand Down
2 changes: 2 additions & 0 deletions defaults/meta3d/src/app_and_package/AppAndPackageFileType.res
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ type packageData = (
packageName,
entryExtensionProtocolConfigStr,
)

type selectedElements
4 changes: 3 additions & 1 deletion defaults/meta3d/src/app_and_package/AppAndPackageFileType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ type packageName = string

type packageVersion = version

export type packageData = [packageProtocol, entryExtensionName, packageVersion, packageName, entryExtensionProtocolConfigStr]
export type packageData = [packageProtocol, entryExtensionName, packageVersion, packageName, entryExtensionProtocolConfigStr]

export type selectedElements = any
Loading

0 comments on commit 54200cc

Please sign in to comment.