@powerhousedao/builder-tools 4.1.0-dev.101 → 4.1.0-dev.103
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/dist/connect-utils/env-config.d.ts +96 -22
- package/dist/connect-utils/env-config.d.ts.map +1 -1
- package/dist/connect-utils/env-config.js +49 -11
- package/dist/connect-utils/env-config.js.map +1 -1
- package/dist/connect-utils/helpers.d.ts +1 -0
- package/dist/connect-utils/helpers.d.ts.map +1 -1
- package/dist/connect-utils/helpers.js +11 -0
- package/dist/connect-utils/helpers.js.map +1 -1
- package/dist/connect-utils/vite-config.d.ts.map +1 -1
- package/dist/connect-utils/vite-config.js +33 -13
- package/dist/connect-utils/vite-config.js.map +1 -1
- package/dist/connect-utils/vite-plugins/ph-external-packages.d.ts.map +1 -1
- package/dist/connect-utils/vite-plugins/ph-external-packages.js +86 -63
- package/dist/connect-utils/vite-plugins/ph-external-packages.js.map +1 -1
- package/dist/document-model-editor/index.d.ts +0 -1
- package/dist/document-model-editor/index.d.ts.map +1 -1
- package/dist/document-model-editor/index.js +0 -1
- package/dist/document-model-editor/index.js.map +1 -1
- package/dist/document-model-editor/module.d.ts.map +1 -1
- package/dist/document-model-editor/module.js +2 -2
- package/dist/document-model-editor/module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -3,93 +3,116 @@
|
|
|
3
3
|
* returns a js module that exports those packages for use in Connect.
|
|
4
4
|
*/
|
|
5
5
|
function makeImportScriptFromPackages(packages) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
return `
|
|
7
|
+
export async function loadExternalPackages() {
|
|
8
|
+
const modules = [];
|
|
9
|
+
${packages
|
|
10
|
+
.map((pkg, index) => `try {
|
|
11
|
+
const module = await import('${pkg}');
|
|
12
|
+
await import('${pkg}/style.css');
|
|
13
|
+
modules.push({
|
|
14
|
+
id: 'module${index}',
|
|
15
|
+
...module,
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error("Error loading package", pkg, error);
|
|
19
|
+
}`)
|
|
20
|
+
.join("\n")}
|
|
21
|
+
return modules;
|
|
15
22
|
}
|
|
16
|
-
|
|
17
|
-
id: "${packages[index]}",
|
|
18
|
-
...${name},
|
|
19
|
-
}`);
|
|
20
|
-
const exportsString = exports.length
|
|
21
|
-
? `
|
|
22
|
-
${exports.join(",\n")}
|
|
23
|
-
`
|
|
24
|
-
: "";
|
|
25
|
-
const exportStatement = `export default [${exportsString}];`;
|
|
26
|
-
// Add HMR boundary to prevent page reload
|
|
27
|
-
const hmrCode = `
|
|
28
|
-
// HMR boundary - accept updates to prevent full page reload
|
|
29
|
-
if (import.meta.hot) {
|
|
30
|
-
import.meta.hot.accept();
|
|
31
|
-
}`;
|
|
32
|
-
const fileContent = `${imports.join("\n")}\n\n${exportStatement}\n${hmrCode}`;
|
|
33
|
-
return fileContent;
|
|
23
|
+
`;
|
|
34
24
|
}
|
|
35
25
|
export function phExternalPackagesPlugin(phPackages) {
|
|
36
26
|
const virtualModuleId = "virtual:ph:external-packages";
|
|
37
|
-
const
|
|
27
|
+
const localPackageModules = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a module should be skipped based on the following conditions:
|
|
30
|
+
* - It is not a file
|
|
31
|
+
* - It is a node_modules file
|
|
32
|
+
* - It is already in the set of imported modules
|
|
33
|
+
* - It is not part of the local package
|
|
34
|
+
*/
|
|
35
|
+
function shouldSkipModule(module, rootPath, allModules) {
|
|
36
|
+
return (!module.file ||
|
|
37
|
+
module.file.includes("node_modules") ||
|
|
38
|
+
allModules.has(module.file) ||
|
|
39
|
+
(!module.file.startsWith(rootPath) && module.file !== virtualModuleId));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Recursively builds a set of imported modules for a given module.
|
|
43
|
+
* @param currentModule The module to build the set for.
|
|
44
|
+
* @param rootPath The root path of the local package.
|
|
45
|
+
* @param allModules The set of imported modules.
|
|
46
|
+
*/
|
|
47
|
+
function buildImportedModulesSet(currentModule, rootPath, allModules) {
|
|
48
|
+
const isVirtualModule = currentModule.file === virtualModuleId;
|
|
49
|
+
const skipModule = shouldSkipModule(currentModule, rootPath, allModules);
|
|
50
|
+
if (skipModule) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!isVirtualModule) {
|
|
54
|
+
allModules.add(currentModule.file);
|
|
55
|
+
}
|
|
56
|
+
for (const importer of currentModule.importedModules) {
|
|
57
|
+
if (!shouldSkipModule(importer, rootPath, allModules)) {
|
|
58
|
+
buildImportedModulesSet(importer, rootPath, allModules);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return allModules;
|
|
62
|
+
}
|
|
38
63
|
const plugin = {
|
|
39
64
|
name: "ph-external-packages",
|
|
40
65
|
enforce: "pre",
|
|
41
66
|
resolveId(id) {
|
|
42
67
|
if (id === virtualModuleId) {
|
|
43
|
-
return
|
|
68
|
+
return id;
|
|
44
69
|
}
|
|
45
70
|
},
|
|
46
71
|
load(id) {
|
|
47
|
-
if (id ===
|
|
72
|
+
if (id === virtualModuleId) {
|
|
48
73
|
return makeImportScriptFromPackages(phPackages);
|
|
49
74
|
}
|
|
50
75
|
},
|
|
51
76
|
handleHotUpdate({ file, server, modules }) {
|
|
52
77
|
// Check if the changed file is part of any local package
|
|
53
|
-
const
|
|
78
|
+
const localPackage = phPackages.find((pkg) => {
|
|
54
79
|
if (pkg.startsWith("/") || pkg.startsWith(".")) {
|
|
55
80
|
return file.startsWith(pkg);
|
|
56
81
|
}
|
|
57
82
|
return false;
|
|
58
83
|
});
|
|
59
|
-
if
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const isReactComponent = file.endsWith(".tsx") || file.endsWith(".jsx");
|
|
84
|
-
if (isReactComponent) {
|
|
85
|
-
return [...deduplicatedModules, virtualModule];
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return [virtualModule];
|
|
89
|
-
}
|
|
84
|
+
// if the changed file is not part of any local package, do not override HMR
|
|
85
|
+
if (!localPackage) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
// iterate through all local package imports to build set of imported modules, if not already built
|
|
89
|
+
const packageModules = localPackageModules.get(localPackage);
|
|
90
|
+
const importedModules = localPackageModules.get(localPackage) || new Set();
|
|
91
|
+
const virtualModule = server.moduleGraph.getModuleById(virtualModuleId);
|
|
92
|
+
if (virtualModule &&
|
|
93
|
+
!packageModules &&
|
|
94
|
+
virtualModule.importedModules.size > 0 // wait for virtual module to be built
|
|
95
|
+
) {
|
|
96
|
+
buildImportedModulesSet(virtualModule, localPackage, importedModules);
|
|
97
|
+
localPackageModules.set(localPackage, importedModules);
|
|
98
|
+
}
|
|
99
|
+
// checks if there are new modules being imported by a watched module and adds them to the set
|
|
100
|
+
for (const module of modules) {
|
|
101
|
+
if (module.file &&
|
|
102
|
+
!importedModules.has(module.file) &&
|
|
103
|
+
!shouldSkipModule(module, localPackage, importedModules) &&
|
|
104
|
+
module.importers
|
|
105
|
+
.values()
|
|
106
|
+
.some((m) => m.file && importedModules.has(m.file))) {
|
|
107
|
+
buildImportedModulesSet(module, localPackage, importedModules);
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
|
-
|
|
110
|
+
// returns only modules that are actually imported by Connect
|
|
111
|
+
const modulesToRefresh = modules.filter((m) => m.id &&
|
|
112
|
+
m.id !== virtualModuleId &&
|
|
113
|
+
m.file &&
|
|
114
|
+
importedModules.has(m.file));
|
|
115
|
+
return modulesToRefresh;
|
|
93
116
|
},
|
|
94
117
|
};
|
|
95
118
|
return plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ph-external-packages.js","sourceRoot":"","sources":["../../../connect-utils/vite-plugins/ph-external-packages.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,SAAS,4BAA4B,CAAC,QAAkB;IACtD,
|
|
1
|
+
{"version":3,"file":"ph-external-packages.js","sourceRoot":"","sources":["../../../connect-utils/vite-plugins/ph-external-packages.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,SAAS,4BAA4B,CAAC,QAAkB;IACtD,OAAO;;;QAGD,QAAQ;SACP,GAAG,CACF,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CACb;yCAC6B,GAAG;0BAClB,GAAG;;2BAEF,KAAK;;;;;QAKxB,CACC;SACA,IAAI,CAAC,IAAI,CAAC;;;GAGhB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,UAAoB;IAC3D,MAAM,eAAe,GAAG,8BAA8B,CAAC;IAEvD,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkC,CAAC;IAEtE;;;;;;OAMG;IACH,SAAS,gBAAgB,CACvB,MAAkB,EAClB,QAAgB,EAChB,UAAuB;QAEvB,OAAO,CACL,CAAC,MAAM,CAAC,IAAI;YACZ,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;YACpC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,eAAe,CAAC,CACvE,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,SAAS,uBAAuB,CAC9B,aAAyB,EACzB,QAAgB,EAChB,UAAuB;QAEvB,MAAM,eAAe,GAAG,aAAa,CAAC,IAA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,CAAC,IAAI;gBACN,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAC9B,CAAC;YAEF,OAAO,gBAAgB,CAAC;QAC1B,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-model-editor/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-model-editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../document-model-editor/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../document-model-editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../document-model-editor/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../document-model-editor/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,yBAAyB,EAAE,YASvC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lazy } from "react";
|
|
2
2
|
export const documentModelEditorModule = {
|
|
3
3
|
config: {
|
|
4
4
|
id: "document-model-editor-v2",
|
|
5
5
|
name: "Document Model Editor",
|
|
6
6
|
},
|
|
7
7
|
documentTypes: ["powerhouse/document-model"],
|
|
8
|
-
Component: DocumentModelEditor,
|
|
8
|
+
Component: lazy(() => import("./editor.js").then((m) => ({ default: m.DocumentModelEditor }))),
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../document-model-editor/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../document-model-editor/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,MAAM,CAAC,MAAM,yBAAyB,GAAiB;IACrD,MAAM,EAAE;QACN,EAAE,EAAE,0BAA0B;QAC9B,IAAI,EAAE,uBAAuB;KAC9B;IACD,aAAa,EAAE,CAAC,2BAA2B,CAAC;IAC5C,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CACnB,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,CACxE;CACF,CAAC"}
|