@vrowzer/vite-plugin 0.1.2 → 0.1.3
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 +52 -5
- package/dist/ide/assets/{css.worker-CTXDGAqi.js → css.worker-B3bjHA4E.js} +12 -12
- package/dist/ide/assets/{html.worker-DoEWTywB.js → html.worker-CdKyo4PJ.js} +15 -15
- package/dist/ide/assets/json.worker-Dv30RK47.js +58 -0
- package/dist/ide/assets/{ts.worker-CEDDf2SQ.js → ts.worker-BMQFrgtp.js} +43 -43
- package/dist/ide/{cssMode-Bx4pwP7t.js → cssMode-BjT8Ilz9.js} +6 -6
- package/dist/ide/{handlebars-niagtI6v.js → handlebars-D8oWedcX.js} +1 -1
- package/dist/ide/{html-vu3rIOlL.js → html-BtI1mgAb.js} +1 -1
- package/dist/ide/{htmlMode-DJyFRqKm.js → htmlMode-nJv21bwP.js} +6 -6
- package/dist/ide/ide.js +1018 -1013
- package/dist/ide/{javascript-BaiNOEh_.js → javascript-CsLyoDyq.js} +1 -1
- package/dist/ide/{jsonMode-DLQ0j1a3.js → jsonMode-Gp85lTwz.js} +26 -25
- package/dist/ide/{lspLanguageFeatures-CY50NMcK.js → lspLanguageFeatures-Bh3u5Duz.js} +4 -4
- package/dist/ide/{mdx-DhZSVASO.js → mdx-BXUwpKml.js} +1 -1
- package/dist/ide/{monaco.contribution-4V6BrQ5P.js → monaco.contribution-Df9Y1epv.js} +2 -2
- package/dist/ide/{toggleHighContrast-DzGcs4Kw.js → toggleHighContrast-BAyJBPWB.js} +11852 -11696
- package/dist/ide/{tsMode-D6r_-_rM.js → tsMode-DW5hjWiU.js} +4 -4
- package/dist/ide/{typescript-DM2pFj0X.js → typescript-DdUYzFye.js} +1 -1
- package/dist/ide/{workers-DRkYqOHL.js → workers-_EnUbIXZ.js} +1 -1
- package/dist/ide/{xml-DrNRTdma.js → xml-YkclMbCx.js} +1 -1
- package/dist/ide/{yaml-ck2FlP6B.js → yaml-nzDq4-PC.js} +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +46 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/ide/assets/json.worker-C4xqSSAJ.js +0 -58
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, n as r, o as i, r as a } from "./toggleHighContrast-
|
|
2
|
-
import { t as o } from "./monaco.contribution-
|
|
3
|
-
import { t as s } from "./workers-
|
|
1
|
+
import { a as e, c as t, i as n, n as r, o as i, r as a } from "./toggleHighContrast-BAyJBPWB.js";
|
|
2
|
+
import { t as o } from "./monaco.contribution-Df9Y1epv.js";
|
|
3
|
+
import { t as s } from "./workers-_EnUbIXZ.js";
|
|
4
4
|
//#region ../../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor/esm/vs/language/typescript/workerManager.js
|
|
5
5
|
var c = class {
|
|
6
6
|
constructor(e, t) {
|
|
@@ -22,7 +22,7 @@ var c = class {
|
|
|
22
22
|
moduleId: "vs/language/typescript/tsWorker",
|
|
23
23
|
createWorker: () => new Worker(new URL(
|
|
24
24
|
/* @vite-ignore */
|
|
25
|
-
"/assets/ts.worker-
|
|
25
|
+
"/assets/ts.worker-BMQFrgtp.js",
|
|
26
26
|
"" + import.meta.url
|
|
27
27
|
), { type: "module" }),
|
|
28
28
|
label: this._modeId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e } from "./toggleHighContrast-
|
|
1
|
+
import { c as e } from "./toggleHighContrast-BAyJBPWB.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor/esm/vs/basic-languages/typescript/typescript.js
|
|
3
3
|
var t = {
|
|
4
4
|
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e } from "./toggleHighContrast-
|
|
1
|
+
import { o as e } from "./toggleHighContrast-BAyJBPWB.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor/esm/vs/common/workers.js
|
|
3
3
|
function t(e, t) {
|
|
4
4
|
let n = globalThis.MonacoEnvironment;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e } from "./toggleHighContrast-
|
|
1
|
+
import { c as e } from "./toggleHighContrast-BAyJBPWB.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor/esm/vs/basic-languages/xml/xml.js
|
|
3
3
|
var t = {
|
|
4
4
|
comments: { blockComment: ["<!--", "-->"] },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e } from "./toggleHighContrast-
|
|
1
|
+
import { c as e } from "./toggleHighContrast-BAyJBPWB.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor/esm/vs/basic-languages/yaml/yaml.js
|
|
3
3
|
var t = {
|
|
4
4
|
comments: { lineComment: "#" },
|
package/dist/index.d.mts
CHANGED
|
@@ -87,16 +87,19 @@ interface VrowzerOptions {
|
|
|
87
87
|
*/
|
|
88
88
|
basePath?: string;
|
|
89
89
|
/**
|
|
90
|
-
* The scope for the service worker of Vrowzer, which determines the range of URLs that
|
|
91
|
-
*
|
|
90
|
+
* The scope for the service worker of Vrowzer, which determines the range of URLs that
|
|
91
|
+
* the service worker will control and the `Service-Worker-Allowed` response header.
|
|
92
|
+
* The value is injected into the Vrowzer runtime, so its corresponding option can be
|
|
93
|
+
* omitted. This registration scope is independent of the preview `basePath`.
|
|
92
94
|
*
|
|
93
95
|
* @default '/' (the entire origin)
|
|
94
96
|
*/
|
|
95
97
|
serviceWorkerScope?: string;
|
|
96
98
|
/**
|
|
97
99
|
* The version of the service worker for Vrowzer, which can be used to manage updates and cache invalidation for the preview system.
|
|
100
|
+
* This is the source of truth for both the application and Service Worker bundles.
|
|
98
101
|
*
|
|
99
|
-
* @default '
|
|
102
|
+
* @default 'vrowzer-v1'
|
|
100
103
|
*/
|
|
101
104
|
serviceWorkerVersion?: string;
|
|
102
105
|
/**
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/options.ts","../src/manifest.ts","../src/index.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/options.ts","../src/manifest.ts","../src/index.ts"],"mappings":";;;;;;;;UAgBiB;EACf,eAAe;EACf;;UAGe;;;;;;;;;;EAUf;;;;;EAKA;;;;;;EAMA;;UAGe;;;;;EAKf;;UAGe;;;;;;;;;EASf,gBAAgB;;;;;;;;;EAShB;;UAGe;;;;;;;;;;;;;;EAcf;;;;EAIA,WAAW;;;;;;;EAOX;;;;;;;;;EASA;;;;;;;EAOA;;;;;;;;;;;;EAYA;;;;;;;;;EASA;IAAY,QAAQ;;;;;EAIpB,eAAe;;;;iBCpGD,mBAAmB;;;iBCJnB,QAAQ,UAAS,iBAAsB"}
|
package/dist/index.mjs
CHANGED
|
@@ -30,7 +30,7 @@ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
|
30
30
|
*/
|
|
31
31
|
const debug$8 = createDebug("vite-plugin-vrowzer:auto-manifest");
|
|
32
32
|
const VIRTUAL_MODULE_ID = "virtual:vrowzer-manifest";
|
|
33
|
-
const RESOLVED_VIRTUAL_MODULE_ID = "\
|
|
33
|
+
const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
|
|
34
34
|
const CACHE_DIR_NAME = ".vrowzer-manifest";
|
|
35
35
|
const MANIFEST_FILENAME = "manifest.json";
|
|
36
36
|
const HASH_FILENAME = "_hash";
|
|
@@ -252,9 +252,13 @@ function resolveAliases(extra) {
|
|
|
252
252
|
*/
|
|
253
253
|
const debug$7 = createDebug("vite-plugin-vrowzer:env");
|
|
254
254
|
const VROWZER_PREVIEW_BASE_PATH_DEFINE = "__VROWZER_INTERNAL_PREVIEW_BASE_PATH__";
|
|
255
|
+
const VROWZER_SERVICE_WORKER_SCOPE_DEFINE = "__VROWZER_INTERNAL_SERVICE_WORKER_SCOPE__";
|
|
256
|
+
const VROWZER_SERVICE_WORKER_VERSION_DEFINE = "__VROWZER_INTERNAL_SERVICE_WORKER_VERSION__";
|
|
255
257
|
const picocolorsBrowser = resolve(dirname(fileURLToPath(import.meta.resolve("picocolors"))), "picocolors.browser.js");
|
|
256
258
|
function envPlugin(options) {
|
|
257
259
|
const serializedBasePath = JSON.stringify(options.basePath);
|
|
260
|
+
const serializedServiceWorkerScope = JSON.stringify(options.serviceWorkerScope);
|
|
261
|
+
const serializedServiceWorkerVersion = JSON.stringify(options.serviceWorkerVersion);
|
|
258
262
|
return {
|
|
259
263
|
name: "vrowzer:env",
|
|
260
264
|
options(inputOptions) {
|
|
@@ -269,7 +273,9 @@ function envPlugin(options) {
|
|
|
269
273
|
return {
|
|
270
274
|
define: {
|
|
271
275
|
"import.meta.env.DEBUG": JSON.stringify(process.env.DEBUG || ""),
|
|
272
|
-
[VROWZER_PREVIEW_BASE_PATH_DEFINE]: serializedBasePath
|
|
276
|
+
[VROWZER_PREVIEW_BASE_PATH_DEFINE]: serializedBasePath,
|
|
277
|
+
[VROWZER_SERVICE_WORKER_SCOPE_DEFINE]: serializedServiceWorkerScope,
|
|
278
|
+
[VROWZER_SERVICE_WORKER_VERSION_DEFINE]: serializedServiceWorkerVersion
|
|
273
279
|
},
|
|
274
280
|
resolve: { alias: resolveAliases({
|
|
275
281
|
"node:process": "@vrowzer/node-polyfill/process",
|
|
@@ -279,12 +285,12 @@ function envPlugin(options) {
|
|
|
279
285
|
}) },
|
|
280
286
|
worker: { format: "es" },
|
|
281
287
|
server: { headers: {
|
|
282
|
-
"Service-Worker-Allowed":
|
|
288
|
+
"Service-Worker-Allowed": options.serviceWorkerScope,
|
|
283
289
|
"Cross-Origin-Opener-Policy": "same-origin",
|
|
284
290
|
"Cross-Origin-Embedder-Policy": "credentialless"
|
|
285
291
|
} },
|
|
286
292
|
preview: { headers: {
|
|
287
|
-
"Service-Worker-Allowed":
|
|
293
|
+
"Service-Worker-Allowed": options.serviceWorkerScope,
|
|
288
294
|
"Cross-Origin-Opener-Policy": "same-origin",
|
|
289
295
|
"Cross-Origin-Embedder-Policy": "credentialless"
|
|
290
296
|
} }
|
|
@@ -293,6 +299,10 @@ function envPlugin(options) {
|
|
|
293
299
|
configResolved(config) {
|
|
294
300
|
const resolvedBasePath = config.define?.[VROWZER_PREVIEW_BASE_PATH_DEFINE];
|
|
295
301
|
if (resolvedBasePath !== serializedBasePath) throw new Error(`Vrowzer reserved define ${VROWZER_PREVIEW_BASE_PATH_DEFINE} must be ${serializedBasePath}, received ${JSON.stringify(resolvedBasePath)}`);
|
|
302
|
+
const resolvedServiceWorkerScope = config.define?.[VROWZER_SERVICE_WORKER_SCOPE_DEFINE];
|
|
303
|
+
if (resolvedServiceWorkerScope !== serializedServiceWorkerScope) throw new Error(`Vrowzer reserved define ${VROWZER_SERVICE_WORKER_SCOPE_DEFINE} must be ${serializedServiceWorkerScope}, received ${JSON.stringify(resolvedServiceWorkerScope)}`);
|
|
304
|
+
const resolvedServiceWorkerVersion = config.define?.[VROWZER_SERVICE_WORKER_VERSION_DEFINE];
|
|
305
|
+
if (resolvedServiceWorkerVersion !== serializedServiceWorkerVersion) throw new Error(`Vrowzer reserved define ${VROWZER_SERVICE_WORKER_VERSION_DEFINE} must be ${serializedServiceWorkerVersion}, received ${JSON.stringify(resolvedServiceWorkerVersion)}`);
|
|
296
306
|
}
|
|
297
307
|
};
|
|
298
308
|
}
|
|
@@ -692,8 +702,10 @@ function extractInputProperties(source, configObj, forwardedProps, unsupported)
|
|
|
692
702
|
}
|
|
693
703
|
if (hasUnknownTopLevelInput) return;
|
|
694
704
|
const inputProp = findObjectProperty(configObj, "input");
|
|
695
|
-
if (inputProp)
|
|
696
|
-
|
|
705
|
+
if (inputProp) {
|
|
706
|
+
if (isStaticInputOption(inputProp.value)) forwardedProps.set("input", source.slice(inputProp.value.start, inputProp.value.end));
|
|
707
|
+
else unsupported.push(`input is not an inline string, array, or record: ${source.slice(inputProp.value.start, inputProp.value.end)}`);
|
|
708
|
+
}
|
|
697
709
|
const environmentsProp = findObjectProperty(configObj, "environments");
|
|
698
710
|
if (!environmentsProp) return;
|
|
699
711
|
const environmentsValue = unwrapStaticExpression(environmentsProp.value);
|
|
@@ -920,6 +932,7 @@ function generateFallbackCode() {
|
|
|
920
932
|
* @license MIT
|
|
921
933
|
*/
|
|
922
934
|
const DEFAULT_BASE_PATH = "/__preview__/";
|
|
935
|
+
const DEFAULT_SERVICE_WORKER_VERSION = "vrowzer-v1";
|
|
923
936
|
function resolveDefaultServiceWorkerEntry() {
|
|
924
937
|
try {
|
|
925
938
|
return fileURLToPath(import.meta.resolve("vrowzer/service-worker"));
|
|
@@ -945,7 +958,7 @@ function resolveOptions(options) {
|
|
|
945
958
|
},
|
|
946
959
|
basePath: normalizeBasePath(options.basePath ?? DEFAULT_BASE_PATH),
|
|
947
960
|
serviceWorkerScope: options.serviceWorkerScope ?? "/",
|
|
948
|
-
serviceWorkerVersion: options.serviceWorkerVersion ??
|
|
961
|
+
serviceWorkerVersion: options.serviceWorkerVersion ?? DEFAULT_SERVICE_WORKER_VERSION,
|
|
949
962
|
serviceWorkerEntry: options.serviceWorkerEntry ?? resolveDefaultServiceWorkerEntry(),
|
|
950
963
|
resolve: options.resolve
|
|
951
964
|
};
|
|
@@ -1133,7 +1146,8 @@ function inlineCreateRequirePlugin() {
|
|
|
1133
1146
|
const result = code.replace(RE, (match, specifier) => {
|
|
1134
1147
|
if (!specifier.endsWith(".json")) return match;
|
|
1135
1148
|
try {
|
|
1136
|
-
const
|
|
1149
|
+
const resolvedPath = createRequire(id).resolve(specifier);
|
|
1150
|
+
const content = readFileSync(resolvedPath, "utf-8");
|
|
1137
1151
|
modified = true;
|
|
1138
1152
|
debug$4("inlineCreateRequire: inlined", specifier, "from", id);
|
|
1139
1153
|
return JSON.stringify(JSON.parse(content));
|
|
@@ -1161,28 +1175,41 @@ function inlineCreateRequirePlugin() {
|
|
|
1161
1175
|
* @license MIT
|
|
1162
1176
|
*/
|
|
1163
1177
|
const debug$3 = createDebug("vite-plugin-vrowzer:rolldown");
|
|
1178
|
+
function rewriteRolldownAssetUrls(code) {
|
|
1179
|
+
return code.replace(/(["'])\.\.\/(rolldown-(?:binding\.wasm32-wasi\.wasm|worker\.js)\?__vrowzer_internal_asset=rolldown)\1/g, "$1./$2$1");
|
|
1180
|
+
}
|
|
1181
|
+
function renderRolldownAssetChunk(code) {
|
|
1182
|
+
const rewritten = rewriteRolldownAssetUrls(code);
|
|
1183
|
+
return rewritten === code ? null : rewritten;
|
|
1184
|
+
}
|
|
1185
|
+
function rolldownWorkerAssetPlugin() {
|
|
1186
|
+
return {
|
|
1187
|
+
name: "vrowzer:worker-rolldown-assets",
|
|
1188
|
+
renderChunk: renderRolldownAssetChunk
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1164
1191
|
const rolldownDistDir = path.resolve(path.dirname(fileURLToPath(import.meta.resolve("@vrowzer/rolldown/package.json"))), "dist");
|
|
1165
1192
|
debug$3("rolldownDistDir ", rolldownDistDir);
|
|
1166
1193
|
function rolldownPlugin(_options) {
|
|
1167
|
-
let
|
|
1194
|
+
let resolvedAssetsDir = "";
|
|
1168
1195
|
return {
|
|
1169
1196
|
name: "vrowzer:rolldown",
|
|
1170
1197
|
configResolved(config) {
|
|
1171
|
-
|
|
1198
|
+
resolvedAssetsDir = path.resolve(config.root, config.build.outDir, config.build.assetsDir);
|
|
1172
1199
|
},
|
|
1200
|
+
renderChunk: renderRolldownAssetChunk,
|
|
1173
1201
|
/**
|
|
1174
1202
|
* Copy rolldown WASM binary and sub-worker for production builds.
|
|
1175
|
-
*
|
|
1203
|
+
* The worker chunks and these files share the configured assets directory.
|
|
1176
1204
|
*/
|
|
1177
1205
|
writeBundle() {
|
|
1178
|
-
|
|
1179
|
-
debug$3("copy-rolldown-wasm: assetsDir ", assetsDir);
|
|
1206
|
+
debug$3("copy-rolldown-wasm: assetsDir ", resolvedAssetsDir);
|
|
1180
1207
|
const wasmSrc = path.resolve(rolldownDistDir, "rolldown-binding.wasm32-wasi.wasm");
|
|
1181
1208
|
debug$3("copy-rolldown-wasm: wasmSrc ", wasmSrc);
|
|
1182
1209
|
const workerSrc = path.resolve(rolldownDistDir, "worker.js");
|
|
1183
1210
|
debug$3("copy-rolldown-wasm: workerSrc ", workerSrc);
|
|
1184
|
-
if (existsSync(wasmSrc)) copyFileSync(wasmSrc, path.resolve(
|
|
1185
|
-
if (existsSync(workerSrc)) copyFileSync(workerSrc, path.resolve(
|
|
1211
|
+
if (existsSync(wasmSrc)) copyFileSync(wasmSrc, path.resolve(resolvedAssetsDir, "rolldown-binding.wasm32-wasi.wasm"));
|
|
1212
|
+
if (existsSync(workerSrc)) copyFileSync(workerSrc, path.resolve(resolvedAssetsDir, "rolldown-worker.js"));
|
|
1186
1213
|
}
|
|
1187
1214
|
};
|
|
1188
1215
|
}
|
|
@@ -1390,9 +1417,11 @@ function Vrowzer(options = {}) {
|
|
|
1390
1417
|
{
|
|
1391
1418
|
name: "vrowzer:web-worker-config-inject",
|
|
1392
1419
|
transform: workerEntryTransform
|
|
1393
|
-
}
|
|
1420
|
+
},
|
|
1421
|
+
rolldownWorkerAssetPlugin()
|
|
1394
1422
|
];
|
|
1395
1423
|
return {
|
|
1424
|
+
optimizeDeps: { exclude: ["@vrowzer/vite-dev-server"] },
|
|
1396
1425
|
resolve: { alias: [{
|
|
1397
1426
|
find: /^vite$/,
|
|
1398
1427
|
replacement: "@vrowzer/vite-dev-server/vite"
|
|
@@ -1441,7 +1470,7 @@ function Vrowzer(options = {}) {
|
|
|
1441
1470
|
apply: "serve"
|
|
1442
1471
|
};
|
|
1443
1472
|
const serviceWorkerPlugin = ServiceWorker({
|
|
1444
|
-
serviceWorkerAllowed:
|
|
1473
|
+
serviceWorkerAllowed: resolvedOptions.serviceWorkerScope,
|
|
1445
1474
|
format: "esm",
|
|
1446
1475
|
...resolvedOptions.serviceWorkerEntry ? { entry: resolvedOptions.serviceWorkerEntry } : {}
|
|
1447
1476
|
});
|