coralite 0.31.5 → 0.31.7
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/README.md +1 -1
- package/dist/lib/coralite.d.ts.map +1 -1
- package/dist/lib/html.d.ts.map +1 -1
- package/dist/lib/index.js +67 -53
- package/dist/lib/index.js.map +3 -3
- package/dist/lib/plugin.d.ts +4 -4
- package/dist/lib/script-manager.d.ts.map +1 -1
- package/dist/plugins/define-component.js +2 -2
- package/dist/plugins/metadata.js +2 -2
- package/dist/plugins/refs.d.ts +3 -0
- package/dist/plugins/refs.d.ts.map +1 -1
- package/dist/plugins/refs.js +6 -7
- package/dist/plugins/static-assets.js +2 -2
- package/dist/types/script.d.ts +11 -6
- package/dist/types/script.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ coralite is a static site generator library built around the emerging [HTML modu
|
|
|
17
17
|
- [Coralite](https://coralite.dev/docs/reference/coralite.html)
|
|
18
18
|
- [Plugin system](https://coralite.dev/docs/reference/plugins/index.html)
|
|
19
19
|
- [Create plugin](https://coralite.dev/docs/reference/plugins/create-plugin.html)
|
|
20
|
-
- The `
|
|
20
|
+
- The `definePlugin` function is the entry point for extending Coralite's functionality.
|
|
21
21
|
- [Define component](https://coralite.dev/docs/reference/plugins/define-component.html)
|
|
22
22
|
- The `defineComponent` plugin is Coralite's core built-in plugin that enables dynamic template functionality.
|
|
23
23
|
- [Ref](https://coralite.dev/docs/reference/plugins/refs-plugin.html)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,2IAXW,cAAc,QAmMxB;;IA3ND;;;;;;;;;;;;;;;;OAgBG;IAEH;;OAEG;IAEH;;;;;;;;;;;;OAYG;IACH,8HAXW,c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AAW,GAAC,cAAc,GAAC,cAAc,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,QAC1K,CAAC,GACA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAc5B;IAED;;;;;;;OAOG;IACH,qBAHW,WAAW,GAAC,cAAc,GAAC,cAAc,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,4BAapL;;;wCA1vCU,cAAc,KACZ,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;oCA9rCN,mBAAmB;4CAAnB,mBAAmB;8BA/Bd,qBAAqB;6BAHT,WAAW;4BAAX,WAAW;+BACiB,YAAY;2CAiCzD,mBAAmB;qCAAnB,mBAAmB;0CAIL,gBAAgB;+BAvBxB,iBAAiB;oCAmBvB,mBAAmB;uCAAnB,mBAAmB;0CAAnB,mBAAmB;qCAAnB,mBAAmB;oCAAnB,mBAAmB"}
|
package/dist/lib/html.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../lib/html.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,2HAnBG;IAAwB,IAAI,EAApB,MAAM;IACwB,IAAI,EAAlC,MAAM,GAAG,WAAW;IACF,SAAS,GAA3B,OAAO;IACY,OAAO,GAA1B,MAAM,EAAE;IAC6B,SAAS,GAA9C,0BAA0B;IACc,YAAY,GAApD,6BAA6B;IACW,YAAY,GAApD,6BAA6B;IACA,UAAU,GAAvC,kBAAkB;IACwB,KAAK,GAA/C,OAAO,SAAS,EAAE,aAAa;CACvC,GAAU,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../lib/html.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,2HAnBG;IAAwB,IAAI,EAApB,MAAM;IACwB,IAAI,EAAlC,MAAM,GAAG,WAAW;IACF,SAAS,GAA3B,OAAO;IACY,OAAO,GAA1B,MAAM,EAAE;IAC6B,SAAS,GAA9C,0BAA0B;IACc,YAAY,GAApD,6BAA6B;IACW,YAAY,GAApD,6BAA6B;IACA,UAAU,GAAvC,kBAAkB;IACwB,KAAK,GAA/C,OAAO,SAAS,EAAE,aAAa;CACvC,GAAU,OAAO,CAAC,kBAAkB,CAAC,CAoGvC;AAED;;;;GAIG;AACH,0CAHW,MAAM,UAehB;AAED;;;;GAIG;AACH,sCAHW,MAAM,mBAehB;gDAzJwC,mBAAmB;mDAAnB,mBAAmB;mDAAnB,mBAAmB;+BAN7B,iBAAiB"}
|
package/dist/lib/index.js
CHANGED
|
@@ -6840,7 +6840,7 @@ CoraliteCollection.prototype.setItem = async function(value) {
|
|
|
6840
6840
|
throw new Error("Valid HTMLData object must be provided");
|
|
6841
6841
|
}
|
|
6842
6842
|
const pathname = value.path.pathname;
|
|
6843
|
-
const
|
|
6843
|
+
const dirname6 = value.path.dirname;
|
|
6844
6844
|
const originalValue = this.collection[pathname];
|
|
6845
6845
|
if (value.content === void 0 && pathname) {
|
|
6846
6846
|
value.content = await getHtmlFile(pathname);
|
|
@@ -6861,11 +6861,11 @@ CoraliteCollection.prototype.setItem = async function(value) {
|
|
|
6861
6861
|
}
|
|
6862
6862
|
}
|
|
6863
6863
|
this.collection[pathname] = documentValue;
|
|
6864
|
-
if (!this.listByPath[
|
|
6865
|
-
this.listByPath[
|
|
6864
|
+
if (!this.listByPath[dirname6]) {
|
|
6865
|
+
this.listByPath[dirname6] = [];
|
|
6866
6866
|
}
|
|
6867
|
-
if (!this.listByPath[
|
|
6868
|
-
this.listByPath[
|
|
6867
|
+
if (!this.listByPath[dirname6].includes(documentValue)) {
|
|
6868
|
+
this.listByPath[dirname6].push(documentValue);
|
|
6869
6869
|
}
|
|
6870
6870
|
if (!this.list.includes(documentValue)) {
|
|
6871
6871
|
this.list.push(documentValue);
|
|
@@ -6880,18 +6880,18 @@ CoraliteCollection.prototype.deleteItem = async function(value) {
|
|
|
6880
6880
|
throw new Error("Valid pathname must be provided");
|
|
6881
6881
|
}
|
|
6882
6882
|
let pathname;
|
|
6883
|
-
let
|
|
6883
|
+
let dirname6;
|
|
6884
6884
|
let valuesByPath;
|
|
6885
6885
|
let originalValue;
|
|
6886
6886
|
if (typeof value !== "string" && value.path) {
|
|
6887
6887
|
pathname = value.path.pathname;
|
|
6888
|
-
|
|
6889
|
-
valuesByPath = this.listByPath[
|
|
6888
|
+
dirname6 = value.path.dirname;
|
|
6889
|
+
valuesByPath = this.listByPath[dirname6];
|
|
6890
6890
|
originalValue = value;
|
|
6891
6891
|
} else if (typeof value === "string") {
|
|
6892
6892
|
pathname = value;
|
|
6893
|
-
|
|
6894
|
-
valuesByPath = this.listByPath[
|
|
6893
|
+
dirname6 = path.dirname(pathname);
|
|
6894
|
+
valuesByPath = this.listByPath[dirname6];
|
|
6895
6895
|
originalValue = this.collection[pathname];
|
|
6896
6896
|
} else {
|
|
6897
6897
|
throw new Error("Valid pathname must be provided");
|
|
@@ -6924,7 +6924,7 @@ CoraliteCollection.prototype.deleteItem = async function(value) {
|
|
|
6924
6924
|
valuesByPath.splice(pathIndex, 1);
|
|
6925
6925
|
}
|
|
6926
6926
|
if (valuesByPath.length === 0) {
|
|
6927
|
-
delete this.listByPath[
|
|
6927
|
+
delete this.listByPath[dirname6];
|
|
6928
6928
|
}
|
|
6929
6929
|
};
|
|
6930
6930
|
CoraliteCollection.prototype.updateItem = async function(value) {
|
|
@@ -6977,8 +6977,8 @@ CoraliteCollection.prototype.getItem = function(id) {
|
|
|
6977
6977
|
}
|
|
6978
6978
|
return this.collection[id];
|
|
6979
6979
|
};
|
|
6980
|
-
CoraliteCollection.prototype.getListByPath = function(
|
|
6981
|
-
const list = this.listByPath[
|
|
6980
|
+
CoraliteCollection.prototype.getListByPath = function(dirname6) {
|
|
6981
|
+
const list = this.listByPath[dirname6];
|
|
6982
6982
|
if (list) {
|
|
6983
6983
|
return list.slice();
|
|
6984
6984
|
}
|
|
@@ -7048,18 +7048,16 @@ async function getHtmlFiles({
|
|
|
7048
7048
|
continue;
|
|
7049
7049
|
}
|
|
7050
7050
|
if (entry.isDirectory() && recursive) {
|
|
7051
|
-
tasks.push(
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
limit
|
|
7062
|
-
});
|
|
7051
|
+
tasks.push(getHtmlFiles({
|
|
7052
|
+
path: pathname,
|
|
7053
|
+
type,
|
|
7054
|
+
recursive,
|
|
7055
|
+
exclude,
|
|
7056
|
+
onFileSet,
|
|
7057
|
+
onFileUpdate,
|
|
7058
|
+
onFileDelete,
|
|
7059
|
+
collection,
|
|
7060
|
+
limit
|
|
7063
7061
|
}));
|
|
7064
7062
|
} else if (entry.isFile() && extname(entry.name).toLowerCase() === ".html") {
|
|
7065
7063
|
tasks.push(limit(async () => {
|
|
@@ -9467,7 +9465,7 @@ async function transformCss(css, rootClasses, descendantClasses, onError) {
|
|
|
9467
9465
|
import { build } from "esbuild";
|
|
9468
9466
|
import serialize from "serialize-javascript";
|
|
9469
9467
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
9470
|
-
import { resolve, parse as parse4 } from "node:path";
|
|
9468
|
+
import { resolve, parse as parse4, dirname as dirname2 } from "node:path";
|
|
9471
9469
|
import { createHash } from "node:crypto";
|
|
9472
9470
|
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill";
|
|
9473
9471
|
function ScriptManager(options = {}) {
|
|
@@ -9996,7 +9994,7 @@ export default {
|
|
|
9996
9994
|
return {
|
|
9997
9995
|
contents,
|
|
9998
9996
|
loader: "js",
|
|
9999
|
-
resolveDir: process.cwd()
|
|
9997
|
+
resolveDir: sharedFn && sharedFn.filePath ? dirname2(sharedFn.filePath) : process.cwd()
|
|
10000
9998
|
};
|
|
10001
9999
|
});
|
|
10002
10000
|
pluginBuild.onLoad({
|
|
@@ -10081,7 +10079,7 @@ export default {
|
|
|
10081
10079
|
return {
|
|
10082
10080
|
contents,
|
|
10083
10081
|
loader: "js",
|
|
10084
|
-
resolveDir: process.cwd()
|
|
10082
|
+
resolveDir: module.rootDir || (module.filePath ? dirname2(module.filePath) : process.cwd())
|
|
10085
10083
|
};
|
|
10086
10084
|
});
|
|
10087
10085
|
pluginBuild.onLoad({
|
|
@@ -10173,7 +10171,7 @@ async function processTokenValue(value, context) {
|
|
|
10173
10171
|
}
|
|
10174
10172
|
return result.root.children;
|
|
10175
10173
|
}
|
|
10176
|
-
var defineComponent =
|
|
10174
|
+
var defineComponent = definePlugin({
|
|
10177
10175
|
name: "defineComponent",
|
|
10178
10176
|
/**
|
|
10179
10177
|
* This function defines a component plugin for the Coralite framework.
|
|
@@ -10324,18 +10322,17 @@ var defineComponent = createPlugin({
|
|
|
10324
10322
|
});
|
|
10325
10323
|
|
|
10326
10324
|
// plugins/refs.js
|
|
10327
|
-
var refsPlugin =
|
|
10325
|
+
var refsPlugin = definePlugin({
|
|
10328
10326
|
name: "refs",
|
|
10329
10327
|
client: {
|
|
10330
10328
|
helpers: {
|
|
10331
10329
|
/**
|
|
10332
10330
|
* Creates a ref resolver function that maps IDs to DOM elements.
|
|
10333
10331
|
*
|
|
10334
|
-
* @
|
|
10335
|
-
* @returns {import('../types/index.js').ScriptPluginHelperLocalInstance}
|
|
10332
|
+
* @returns {ScriptPluginHelperLocalInstance}
|
|
10336
10333
|
*/
|
|
10337
|
-
refs(
|
|
10338
|
-
return ({ values
|
|
10334
|
+
refs() {
|
|
10335
|
+
return ({ values }) => {
|
|
10339
10336
|
const elements = {};
|
|
10340
10337
|
return function(id) {
|
|
10341
10338
|
if (elements[id]) {
|
|
@@ -10345,7 +10342,7 @@ var refsPlugin = createPlugin({
|
|
|
10345
10342
|
if (!refId && typeof refId !== "string") {
|
|
10346
10343
|
return null;
|
|
10347
10344
|
}
|
|
10348
|
-
const element =
|
|
10345
|
+
const element = document.querySelector(`[ref="${refId}"]`);
|
|
10349
10346
|
if (element) {
|
|
10350
10347
|
elements[id] = element;
|
|
10351
10348
|
}
|
|
@@ -10358,7 +10355,7 @@ var refsPlugin = createPlugin({
|
|
|
10358
10355
|
});
|
|
10359
10356
|
|
|
10360
10357
|
// plugins/metadata.js
|
|
10361
|
-
var metadataPlugin =
|
|
10358
|
+
var metadataPlugin = definePlugin({
|
|
10362
10359
|
name: "metadata",
|
|
10363
10360
|
async onPageSet({ elements, values, data: data2 }) {
|
|
10364
10361
|
values.$lang = "";
|
|
@@ -10413,7 +10410,7 @@ var metadataPlugin = createPlugin({
|
|
|
10413
10410
|
});
|
|
10414
10411
|
|
|
10415
10412
|
// lib/plugin.js
|
|
10416
|
-
import { basename, dirname as
|
|
10413
|
+
import { basename, dirname as dirname3 } from "path";
|
|
10417
10414
|
function validateNonEmptyString(value, paramName) {
|
|
10418
10415
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
10419
10416
|
throw new Error(
|
|
@@ -10487,7 +10484,7 @@ function processComponents(path2) {
|
|
|
10487
10484
|
const componentData = {
|
|
10488
10485
|
path: {
|
|
10489
10486
|
pathname: path2,
|
|
10490
|
-
dirname:
|
|
10487
|
+
dirname: dirname3(path2),
|
|
10491
10488
|
filename: basename(path2)
|
|
10492
10489
|
}
|
|
10493
10490
|
};
|
|
@@ -10498,7 +10495,7 @@ function processComponents(path2) {
|
|
|
10498
10495
|
);
|
|
10499
10496
|
}
|
|
10500
10497
|
}
|
|
10501
|
-
function
|
|
10498
|
+
function definePlugin({
|
|
10502
10499
|
name,
|
|
10503
10500
|
method,
|
|
10504
10501
|
components = [],
|
|
@@ -10587,11 +10584,11 @@ function createPlugin({
|
|
|
10587
10584
|
|
|
10588
10585
|
// plugins/static-assets.js
|
|
10589
10586
|
import { createRequire } from "node:module";
|
|
10590
|
-
import { dirname as
|
|
10587
|
+
import { dirname as dirname4, join as join2 } from "node:path";
|
|
10591
10588
|
import { existsSync as existsSync2 } from "node:fs";
|
|
10592
10589
|
import { cp, mkdir } from "node:fs/promises";
|
|
10593
10590
|
var staticAssetPlugin = (assets = []) => {
|
|
10594
|
-
return
|
|
10591
|
+
return definePlugin({
|
|
10595
10592
|
name: "static-asset-plugin",
|
|
10596
10593
|
onBeforeBuild: async function() {
|
|
10597
10594
|
const outputDir = this.options.output || join2(process.cwd(), "dist");
|
|
@@ -10601,7 +10598,7 @@ var staticAssetPlugin = (assets = []) => {
|
|
|
10601
10598
|
}
|
|
10602
10599
|
const dest = join2(outputDir, asset.dest);
|
|
10603
10600
|
if (asset.src) {
|
|
10604
|
-
await mkdir(
|
|
10601
|
+
await mkdir(dirname4(dest), { recursive: true });
|
|
10605
10602
|
await cp(asset.src, dest, { recursive: true });
|
|
10606
10603
|
continue;
|
|
10607
10604
|
}
|
|
@@ -10611,18 +10608,18 @@ var staticAssetPlugin = (assets = []) => {
|
|
|
10611
10608
|
const require2 = createRequire(join2(process.cwd(), "package.json"));
|
|
10612
10609
|
let pkgPath;
|
|
10613
10610
|
try {
|
|
10614
|
-
pkgPath =
|
|
10611
|
+
pkgPath = dirname4(require2.resolve(`${asset.pkg}/package.json`));
|
|
10615
10612
|
} catch (e) {
|
|
10616
|
-
pkgPath =
|
|
10613
|
+
pkgPath = dirname4(require2.resolve(asset.pkg));
|
|
10617
10614
|
while (pkgPath !== "/" && !existsSync2(join2(pkgPath, "package.json"))) {
|
|
10618
|
-
pkgPath =
|
|
10615
|
+
pkgPath = dirname4(pkgPath);
|
|
10619
10616
|
}
|
|
10620
10617
|
if (pkgPath === "/") {
|
|
10621
10618
|
throw new Error(`staticAssetPlugin could not resolve package.json for package: ${asset.pkg}`);
|
|
10622
10619
|
}
|
|
10623
10620
|
}
|
|
10624
10621
|
const src = join2(pkgPath, asset.path);
|
|
10625
|
-
await mkdir(
|
|
10622
|
+
await mkdir(dirname4(dest), { recursive: true });
|
|
10626
10623
|
await cp(src, dest, { recursive: true });
|
|
10627
10624
|
}
|
|
10628
10625
|
}
|
|
@@ -10631,7 +10628,7 @@ var staticAssetPlugin = (assets = []) => {
|
|
|
10631
10628
|
|
|
10632
10629
|
// lib/coralite.js
|
|
10633
10630
|
import { mkdir as mkdir2, writeFile } from "node:fs/promises";
|
|
10634
|
-
import { dirname as
|
|
10631
|
+
import { dirname as dirname5, join as join3, normalize, relative, resolve as resolve2 } from "node:path";
|
|
10635
10632
|
import { createRequire as createRequire2 } from "node:module";
|
|
10636
10633
|
import { transform } from "esbuild";
|
|
10637
10634
|
|
|
@@ -10917,7 +10914,7 @@ Coralite.prototype.initialise = async function() {
|
|
|
10917
10914
|
const urlPathname = pathToFileURL2(join3("/", relative(rootPath, data2.path.pathname))).pathname;
|
|
10918
10915
|
const values = {
|
|
10919
10916
|
$urlPathname: urlPathname,
|
|
10920
|
-
$urlDirname: pathToFileURL2(
|
|
10917
|
+
$urlDirname: pathToFileURL2(dirname5(urlPathname)).pathname,
|
|
10921
10918
|
$filePathname: data2.path.pathname,
|
|
10922
10919
|
$fileDirname: data2.path.dirname,
|
|
10923
10920
|
$filename: data2.path.filename,
|
|
@@ -11290,16 +11287,26 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11290
11287
|
|
|
11291
11288
|
// Capture light DOM children
|
|
11292
11289
|
const childNodes = Array.from(this.childNodes);
|
|
11290
|
+
|
|
11293
11291
|
for (let i = 0; i < childNodes.length; i++) {
|
|
11294
11292
|
const child = childNodes[i];
|
|
11295
11293
|
const slotName = (child.getAttribute && child.getAttribute('slot')) || 'default';
|
|
11294
|
+
|
|
11296
11295
|
if (!this._lightDomSlots[slotName]) {
|
|
11297
11296
|
this._lightDomSlots[slotName] = [];
|
|
11298
11297
|
}
|
|
11298
|
+
|
|
11299
11299
|
this._lightDomSlots[slotName].push(child);
|
|
11300
|
+
|
|
11301
|
+
// Hide the nodes so they don't cause FOUC
|
|
11302
|
+
if (child.nodeType === 1) {
|
|
11303
|
+
child.__coralite_orig_display = child.style.display;
|
|
11304
|
+
child.style.display = 'none';
|
|
11305
|
+
} else if (child.nodeType === 3) { // TEXT_NODE
|
|
11306
|
+
child.__coralite_orig_text = child.textContent;
|
|
11307
|
+
child.textContent = '';
|
|
11308
|
+
}
|
|
11300
11309
|
}
|
|
11301
|
-
// Clear the innerHTML to detach the captured nodes so they aren't destroyed
|
|
11302
|
-
this.innerHTML = '';
|
|
11303
11310
|
}
|
|
11304
11311
|
|
|
11305
11312
|
// Extract attributes to values
|
|
@@ -11488,9 +11495,17 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11488
11495
|
|
|
11489
11496
|
if (projectedNodes && projectedNodes.length > 0) {
|
|
11490
11497
|
// We have content to project, clear the fallback content
|
|
11491
|
-
slot.
|
|
11498
|
+
slot.replaceChildren();
|
|
11492
11499
|
// Append original nodes
|
|
11493
11500
|
for (let j = 0; j < projectedNodes.length; j++) {
|
|
11501
|
+
// Restore original visibility before re-inserting
|
|
11502
|
+
if (projectedNodes[j].nodeType === 1 && projectedNodes[j].hasOwnProperty('__coralite_orig_display')) {
|
|
11503
|
+
projectedNodes[j].style.display = projectedNodes[j].__coralite_orig_display;
|
|
11504
|
+
delete projectedNodes[j].__coralite_orig_display;
|
|
11505
|
+
} else if (projectedNodes[j].nodeType === 3 && projectedNodes[j].hasOwnProperty('__coralite_orig_text')) {
|
|
11506
|
+
projectedNodes[j].textContent = projectedNodes[j].__coralite_orig_text;
|
|
11507
|
+
delete projectedNodes[j].__coralite_orig_text;
|
|
11508
|
+
}
|
|
11494
11509
|
// Re-insert original nodes to preserve their state and event listeners across re-renders
|
|
11495
11510
|
slot.parentNode.insertBefore(projectedNodes[j], slot);
|
|
11496
11511
|
}
|
|
@@ -11573,7 +11588,6 @@ const globalSetupValuesPromise = getSetups(globalContext);
|
|
|
11573
11588
|
component: {},
|
|
11574
11589
|
signal: globalAbortController.signal
|
|
11575
11590
|
};
|
|
11576
|
-
context.root = window.document;
|
|
11577
11591
|
const setupValues = await globalSetupValuesPromise;
|
|
11578
11592
|
const helpers = await getHelpers(context);
|
|
11579
11593
|
context.helpers = helpers;
|
|
@@ -12497,11 +12511,11 @@ export {
|
|
|
12497
12511
|
cloneComponentInstance,
|
|
12498
12512
|
cloneModuleInstance,
|
|
12499
12513
|
createElement,
|
|
12500
|
-
createPlugin,
|
|
12501
12514
|
createTextNode,
|
|
12502
12515
|
index_default as default,
|
|
12503
12516
|
defineComponent,
|
|
12504
12517
|
defineConfig,
|
|
12518
|
+
definePlugin,
|
|
12505
12519
|
findAndExtractScript,
|
|
12506
12520
|
getHtmlFile,
|
|
12507
12521
|
getHtmlFileSync,
|