coralite 0.37.0 → 0.37.2
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/lib/coralite.d.ts.map +1 -1
- package/dist/lib/index.js +83 -29
- package/dist/lib/index.js.map +3 -3
- package/dist/lib/plugin.js +147 -0
- package/dist/lib/plugin.js.map +7 -0
- package/dist/lib/renderer.d.ts.map +1 -1
- package/dist/lib/utils/core.js +467 -0
- package/dist/lib/utils/core.js.map +7 -0
- package/dist/lib/utils/index.js +815 -0
- package/dist/lib/utils/index.js.map +7 -0
- package/dist/lib/utils/server/errors.d.ts.map +1 -1
- package/dist/lib/utils/server/parse.d.ts +0 -14
- package/dist/lib/utils/server/parse.d.ts.map +1 -1
- package/dist/plugins/static-assets.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAwBA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,2LAHW,cAAc,GACZ,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAwBA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,2LAHW,cAAc,GACZ,OAAO,CAAC,gBAAgB,CAAC,CAgXrC;;oCAvXS,mBAAmB;sCAAnB,mBAAmB"}
|
package/dist/lib/index.js
CHANGED
|
@@ -3193,7 +3193,7 @@ var metadataPlugin = definePlugin({
|
|
|
3193
3193
|
import { createRequire } from "node:module";
|
|
3194
3194
|
import { dirname as dirname4, join as join2, parse as parse2 } from "node:path";
|
|
3195
3195
|
import { existsSync as existsSync2 } from "node:fs";
|
|
3196
|
-
import { cp, mkdir } from "node:fs/promises";
|
|
3196
|
+
import { cp, mkdir, stat } from "node:fs/promises";
|
|
3197
3197
|
function findPackageRoot(startDir) {
|
|
3198
3198
|
let currentDir = startDir;
|
|
3199
3199
|
const rootDir = parse2(currentDir).root;
|
|
@@ -3206,40 +3206,76 @@ function findPackageRoot(startDir) {
|
|
|
3206
3206
|
throw new Error("package.json not found");
|
|
3207
3207
|
}
|
|
3208
3208
|
var staticAssetPlugin = (assets = []) => {
|
|
3209
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
3209
3210
|
return definePlugin({
|
|
3210
3211
|
name: "static-asset-plugin",
|
|
3211
3212
|
server: {
|
|
3212
3213
|
onBeforeBuild: async function(context) {
|
|
3213
3214
|
const outputDir = context.app.options.output || join2(process.cwd(), "dist");
|
|
3215
|
+
const copyTasks = [];
|
|
3214
3216
|
for (const asset of assets) {
|
|
3215
3217
|
if (!asset.dest) {
|
|
3216
3218
|
throw new Error("staticAssetPlugin requires assets to have a dest property.");
|
|
3217
3219
|
}
|
|
3218
3220
|
const dest = join2(outputDir, asset.dest);
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
}
|
|
3227
|
-
const require2 = createRequire(join2(process.cwd(), "package.json"));
|
|
3228
|
-
let pkgPath;
|
|
3229
|
-
try {
|
|
3230
|
-
pkgPath = dirname4(require2.resolve(`${asset.pkg}/package.json`));
|
|
3231
|
-
} catch {
|
|
3221
|
+
let src = asset.src;
|
|
3222
|
+
if (!src) {
|
|
3223
|
+
if (!asset.pkg || !asset.path) {
|
|
3224
|
+
throw new Error("staticAssetPlugin requires assets to have pkg and path state when src is not provided.");
|
|
3225
|
+
}
|
|
3226
|
+
const require2 = createRequire(join2(process.cwd(), "package.json"));
|
|
3227
|
+
let pkgPath;
|
|
3232
3228
|
try {
|
|
3233
|
-
|
|
3234
|
-
pkgPath = findPackageRoot(dirname4(resolvedPath));
|
|
3229
|
+
pkgPath = dirname4(require2.resolve(`${asset.pkg}/package.json`));
|
|
3235
3230
|
} catch {
|
|
3236
|
-
|
|
3231
|
+
try {
|
|
3232
|
+
const resolvedPath = require2.resolve(asset.pkg);
|
|
3233
|
+
pkgPath = findPackageRoot(dirname4(resolvedPath));
|
|
3234
|
+
} catch {
|
|
3235
|
+
throw new Error(`staticAssetPlugin could not resolve package.json for package: ${asset.pkg}`);
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
src = join2(pkgPath, asset.path);
|
|
3239
|
+
}
|
|
3240
|
+
if (inFlight.has(dest)) {
|
|
3241
|
+
const active = inFlight.get(dest);
|
|
3242
|
+
if (active.src !== src) {
|
|
3243
|
+
console.warn(`[staticAssetPlugin] Destination collision: Both "${src}" and "${active.src}" are targeting "${asset.dest}". Only the first one will be processed.`);
|
|
3237
3244
|
}
|
|
3245
|
+
copyTasks.push(active.promise);
|
|
3246
|
+
continue;
|
|
3238
3247
|
}
|
|
3239
|
-
const
|
|
3240
|
-
|
|
3241
|
-
|
|
3248
|
+
const performCopy = (async () => {
|
|
3249
|
+
try {
|
|
3250
|
+
const [srcStat, destStat] = await Promise.all([
|
|
3251
|
+
stat(src).catch(() => null),
|
|
3252
|
+
stat(dest).catch(() => null)
|
|
3253
|
+
]);
|
|
3254
|
+
if (!srcStat) {
|
|
3255
|
+
console.warn(`[staticAssetPlugin] Source file not found: ${src}`);
|
|
3256
|
+
return;
|
|
3257
|
+
}
|
|
3258
|
+
if (srcStat.isFile() && destStat) {
|
|
3259
|
+
if (Math.floor(srcStat.mtimeMs) === Math.floor(destStat.mtimeMs) && srcStat.size === destStat.size) {
|
|
3260
|
+
return;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
await mkdir(dirname4(dest), { recursive: true });
|
|
3264
|
+
await cp(src, dest, {
|
|
3265
|
+
recursive: true,
|
|
3266
|
+
preserveTimestamps: true
|
|
3267
|
+
});
|
|
3268
|
+
} finally {
|
|
3269
|
+
inFlight.delete(dest);
|
|
3270
|
+
}
|
|
3271
|
+
})();
|
|
3272
|
+
inFlight.set(dest, {
|
|
3273
|
+
promise: performCopy,
|
|
3274
|
+
src
|
|
3275
|
+
});
|
|
3276
|
+
copyTasks.push(performCopy);
|
|
3242
3277
|
}
|
|
3278
|
+
await Promise.all(copyTasks);
|
|
3243
3279
|
}
|
|
3244
3280
|
}
|
|
3245
3281
|
});
|
|
@@ -4703,7 +4739,7 @@ async function transformCss(css, rootClasses, descendantClasses, onError) {
|
|
|
4703
4739
|
}
|
|
4704
4740
|
|
|
4705
4741
|
// lib/utils/server/manifest.js
|
|
4706
|
-
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
4742
|
+
import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
4707
4743
|
import xxhash from "xxhash-wasm";
|
|
4708
4744
|
var hasher;
|
|
4709
4745
|
var initPromise = null;
|
|
@@ -4734,7 +4770,7 @@ async function hashFile(filepath) {
|
|
|
4734
4770
|
return hash(content);
|
|
4735
4771
|
}
|
|
4736
4772
|
async function checkFileChange(filepath, previousMetadata = {}) {
|
|
4737
|
-
const stats = await
|
|
4773
|
+
const stats = await stat2(filepath);
|
|
4738
4774
|
const mtime = stats.mtimeMs;
|
|
4739
4775
|
const size = stats.size;
|
|
4740
4776
|
if (previousMetadata.mtime === mtime && previousMetadata.size === size) {
|
|
@@ -5347,14 +5383,22 @@ function createRenderer({
|
|
|
5347
5383
|
if (parent && parent.children) {
|
|
5348
5384
|
const elementIndex = parent.children.indexOf(customElement);
|
|
5349
5385
|
if (elementIndex !== -1) {
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5386
|
+
let children = componentElement;
|
|
5387
|
+
if ("children" in componentElement && Array.isArray(componentElement.children)) {
|
|
5388
|
+
children = componentElement.children;
|
|
5389
|
+
}
|
|
5390
|
+
if (Array.isArray(children)) {
|
|
5391
|
+
parent.children.splice(elementIndex, 1, ...children);
|
|
5392
|
+
relinkChildren(parent);
|
|
5393
|
+
}
|
|
5353
5394
|
}
|
|
5354
5395
|
}
|
|
5355
5396
|
} else {
|
|
5356
|
-
|
|
5357
|
-
|
|
5397
|
+
if (Array.isArray(componentElement)) {
|
|
5398
|
+
customElement.children = componentElement;
|
|
5399
|
+
} else if ("children" in componentElement && Array.isArray(componentElement.children)) {
|
|
5400
|
+
customElement.children = componentElement.children;
|
|
5401
|
+
}
|
|
5358
5402
|
relinkChildren(customElement);
|
|
5359
5403
|
if (!customElement.attribs) {
|
|
5360
5404
|
customElement.attribs = {};
|
|
@@ -5660,7 +5704,7 @@ function createRenderer({
|
|
|
5660
5704
|
if (buildPath) {
|
|
5661
5705
|
const paths = Array.isArray(buildPath) ? buildPath : [buildPath];
|
|
5662
5706
|
for (const p of paths) {
|
|
5663
|
-
if (!app.pages.getItem(p)) {
|
|
5707
|
+
if (typeof p === "string" && !app.pages.getItem(p)) {
|
|
5664
5708
|
try {
|
|
5665
5709
|
await app.pages.setItem(p);
|
|
5666
5710
|
} catch (_err) {
|
|
@@ -5907,8 +5951,15 @@ function createRenderer({
|
|
|
5907
5951
|
skippedPages.length = 0;
|
|
5908
5952
|
}
|
|
5909
5953
|
};
|
|
5954
|
+
const clearCache = () => {
|
|
5955
|
+
scriptResultCache.clear();
|
|
5956
|
+
for (const key in outputFiles) {
|
|
5957
|
+
delete outputFiles[key];
|
|
5958
|
+
}
|
|
5959
|
+
};
|
|
5910
5960
|
return {
|
|
5911
5961
|
outputFiles,
|
|
5962
|
+
clearCache,
|
|
5912
5963
|
createSession: _createSession,
|
|
5913
5964
|
addRenderQueue,
|
|
5914
5965
|
createComponentElement,
|
|
@@ -6069,7 +6120,9 @@ async function createCoralite({
|
|
|
6069
6120
|
createExecutionError
|
|
6070
6121
|
});
|
|
6071
6122
|
Object.assign(app, {
|
|
6072
|
-
outputFiles
|
|
6123
|
+
get outputFiles() {
|
|
6124
|
+
return renderer.outputFiles;
|
|
6125
|
+
},
|
|
6073
6126
|
createComponentElement: renderer.createComponentElement,
|
|
6074
6127
|
build: renderer.build,
|
|
6075
6128
|
/**
|
|
@@ -6135,6 +6188,7 @@ async function createCoralite({
|
|
|
6135
6188
|
return results;
|
|
6136
6189
|
},
|
|
6137
6190
|
addRenderQueue: renderer.addRenderQueue,
|
|
6191
|
+
clearCache: renderer.clearCache,
|
|
6138
6192
|
_triggerPluginAggregateHook: _triggerPluginAggregateHookLocal,
|
|
6139
6193
|
_triggerPluginHook: _triggerPluginHookLocal,
|
|
6140
6194
|
/**
|