@cedarjs/vite 5.0.0-canary.2597 → 5.0.0-canary.2599
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/cjs/devFeServer.js +4 -16
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/plugins/vite-plugin-cedar-data-uri-shim.js +67 -0
- package/dist/devFeServer.js +4 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +43 -0
- package/package.json +13 -15
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +0 -43
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +0 -19
package/dist/cjs/devFeServer.js
CHANGED
|
@@ -248,22 +248,10 @@ async function createServer() {
|
|
|
248
248
|
"busboy",
|
|
249
249
|
"cookie"
|
|
250
250
|
],
|
|
251
|
-
//
|
|
252
|
-
//
|
|
253
|
-
//
|
|
254
|
-
//
|
|
255
|
-
// the Browserify polyfill is because we have
|
|
256
|
-
// `vite-plugin-node-polyfills` as a dependency, and that'll add
|
|
257
|
-
// Browserify's `node-util` to `node_modules`, so when Vite goes to
|
|
258
|
-
// resolve `import { TextEncoder } from 'util` it'll find the one in
|
|
259
|
-
// `node_modules` instead of Node's internal version.
|
|
260
|
-
// We only see this in dev, and not in prod. I'm not entirely sure why
|
|
261
|
-
// but I have two guesses: 1. When RSC is enabled we don't actually use
|
|
262
|
-
// `vite-plugin-node-polyfill`, so some kind of tree shaking is
|
|
263
|
-
// happening, which prevents the issue from occurring. 2. In prod we
|
|
264
|
-
// only use Node's dependency resolution. Vite is not involved. And
|
|
265
|
-
// that difference in resolution is what prevents the issue from
|
|
266
|
-
// occurring.
|
|
251
|
+
// Ensure `util` resolves to Node's built-in module and not to
|
|
252
|
+
// Browserify's `node-util` polyfill (which lacks TextEncoder).
|
|
253
|
+
// The polyfill may be hoisted into node_modules by optional
|
|
254
|
+
// dependencies like `@cedarjs/storybook`.
|
|
267
255
|
exclude: ["util"]
|
|
268
256
|
}
|
|
269
257
|
},
|
package/dist/cjs/index.js
CHANGED
|
@@ -32,11 +32,11 @@ __export(index_exports, {
|
|
|
32
32
|
cedarAutoImportsPlugin: () => import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin,
|
|
33
33
|
cedarCellTransform: () => import_vite_plugin_cedar_cell2.cedarCellTransform,
|
|
34
34
|
cedarCjsCompatPlugin: () => import_vite_plugin_cedar_cjs_compat.cedarCjsCompatPlugin,
|
|
35
|
+
cedarDataUriShim: () => import_vite_plugin_cedar_data_uri_shim2.cedarDataUriShim,
|
|
35
36
|
cedarEntryInjectionPlugin: () => import_vite_plugin_cedar_entry_injection2.cedarEntryInjectionPlugin,
|
|
36
37
|
cedarHtmlEnvPlugin: () => import_vite_plugin_cedar_html_env2.cedarHtmlEnvPlugin,
|
|
37
38
|
cedarImportDirPlugin: () => import_vite_plugin_cedar_import_dir.cedarImportDirPlugin,
|
|
38
39
|
cedarMergedConfig: () => import_vite_plugin_merged_config2.cedarMergedConfig,
|
|
39
|
-
cedarNodePolyfills: () => import_vite_plugin_cedar_node_polyfills2.cedarNodePolyfills,
|
|
40
40
|
cedarRemoveDevFatalErrorPage: () => import_vite_plugin_cedar_remove_dev_fatal_error_page2.cedarRemoveDevFatalErrorPage,
|
|
41
41
|
cedarRemoveFromBundle: () => import_vite_plugin_cedar_remove_from_bundle2.cedarRemoveFromBundle,
|
|
42
42
|
cedarRoutesAutoLoaderPlugin: () => import_vite_plugin_cedar_routes_auto_loader2.cedarRoutesAutoLoaderPlugin,
|
|
@@ -54,9 +54,9 @@ var import_babel_config = require("@cedarjs/babel-config");
|
|
|
54
54
|
var import_project_config = require("@cedarjs/project-config");
|
|
55
55
|
var import_vitest = require("@cedarjs/testing/web/vitest");
|
|
56
56
|
var import_vite_plugin_cedar_cell = require("./plugins/vite-plugin-cedar-cell.js");
|
|
57
|
+
var import_vite_plugin_cedar_data_uri_shim = require("./plugins/vite-plugin-cedar-data-uri-shim.js");
|
|
57
58
|
var import_vite_plugin_cedar_entry_injection = require("./plugins/vite-plugin-cedar-entry-injection.js");
|
|
58
59
|
var import_vite_plugin_cedar_html_env = require("./plugins/vite-plugin-cedar-html-env.js");
|
|
59
|
-
var import_vite_plugin_cedar_node_polyfills = require("./plugins/vite-plugin-cedar-node-polyfills.js");
|
|
60
60
|
var import_vite_plugin_cedar_remove_dev_fatal_error_page = require("./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js");
|
|
61
61
|
var import_vite_plugin_cedar_remove_from_bundle = require("./plugins/vite-plugin-cedar-remove-from-bundle.js");
|
|
62
62
|
var import_vite_plugin_cedar_routes_auto_loader = require("./plugins/vite-plugin-cedar-routes-auto-loader.js");
|
|
@@ -71,7 +71,7 @@ var import_vite_plugin_cedar_cell2 = require("./plugins/vite-plugin-cedar-cell.j
|
|
|
71
71
|
var import_vite_plugin_cedar_entry_injection2 = require("./plugins/vite-plugin-cedar-entry-injection.js");
|
|
72
72
|
var import_vite_plugin_cedar_html_env2 = require("./plugins/vite-plugin-cedar-html-env.js");
|
|
73
73
|
var import_vite_plugin_cedar_import_dir = require("./plugins/vite-plugin-cedar-import-dir.js");
|
|
74
|
-
var
|
|
74
|
+
var import_vite_plugin_cedar_data_uri_shim2 = require("./plugins/vite-plugin-cedar-data-uri-shim.js");
|
|
75
75
|
var import_vite_plugin_cedar_remove_dev_fatal_error_page2 = require("./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js");
|
|
76
76
|
var import_vite_plugin_cedar_routes_auto_loader2 = require("./plugins/vite-plugin-cedar-routes-auto-loader.js");
|
|
77
77
|
var import_vite_plugin_cedar_remove_from_bundle2 = require("./plugins/vite-plugin-cedar-remove-from-bundle.js");
|
|
@@ -96,7 +96,7 @@ function cedar({ mode } = {}) {
|
|
|
96
96
|
mode === "test" && (0, import_vitest.createAuthImportTransformPlugin)(),
|
|
97
97
|
mode === "test" && (0, import_vitest.autoImportsPlugin)(),
|
|
98
98
|
(0, import_vite_plugin_cedar_wait_for_api_server.cedarWaitForApiServer)(),
|
|
99
|
-
(0,
|
|
99
|
+
(0, import_vite_plugin_cedar_data_uri_shim.cedarDataUriShim)(),
|
|
100
100
|
(0, import_vite_plugin_cedar_html_env.cedarHtmlEnvPlugin)(),
|
|
101
101
|
(0, import_vite_plugin_cedar_entry_injection.cedarEntryInjectionPlugin)(),
|
|
102
102
|
(0, import_vite_plugin_merged_config.cedarMergedConfig)(),
|
|
@@ -118,11 +118,11 @@ var index_default = cedar;
|
|
|
118
118
|
cedarAutoImportsPlugin,
|
|
119
119
|
cedarCellTransform,
|
|
120
120
|
cedarCjsCompatPlugin,
|
|
121
|
+
cedarDataUriShim,
|
|
121
122
|
cedarEntryInjectionPlugin,
|
|
122
123
|
cedarHtmlEnvPlugin,
|
|
123
124
|
cedarImportDirPlugin,
|
|
124
125
|
cedarMergedConfig,
|
|
125
|
-
cedarNodePolyfills,
|
|
126
126
|
cedarRemoveDevFatalErrorPage,
|
|
127
127
|
cedarRemoveFromBundle,
|
|
128
128
|
cedarRoutesAutoLoaderPlugin,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var vite_plugin_cedar_data_uri_shim_exports = {};
|
|
20
|
+
__export(vite_plugin_cedar_data_uri_shim_exports, {
|
|
21
|
+
cedarDataUriShim: () => cedarDataUriShim
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_cedar_data_uri_shim_exports);
|
|
24
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
25
|
+
function dataUriToBuffer(uri) {
|
|
26
|
+
const match = uri.match(/^data:(.*?)(;(.*?))?(,(.*))$/);
|
|
27
|
+
if (!match) {
|
|
28
|
+
throw new Error("Invalid data URI");
|
|
29
|
+
}
|
|
30
|
+
const mediaType = match[1] || "text/plain";
|
|
31
|
+
const params = match[3] || "";
|
|
32
|
+
const data = match[5];
|
|
33
|
+
const [type] = mediaType.split(";");
|
|
34
|
+
const typeFull = params ? mediaType + ";" + params : mediaType;
|
|
35
|
+
const lowerParams = params.toLowerCase();
|
|
36
|
+
const isBase64 = lowerParams.includes("base64");
|
|
37
|
+
const charset = lowerParams.startsWith("charset=") ? lowerParams.slice(8) : "";
|
|
38
|
+
const bytes = isBase64 ? Uint8Array.from(atob(data), (c) => c.charCodeAt(0)) : new TextEncoder().encode(decodeURIComponent(data));
|
|
39
|
+
const decoder = new TextDecoder();
|
|
40
|
+
bytes.toString = () => decoder.decode(bytes);
|
|
41
|
+
return Object.assign(bytes, { type, typeFull, charset });
|
|
42
|
+
}
|
|
43
|
+
function cedarDataUriShim() {
|
|
44
|
+
if ((0, import_project_config.getConfig)().experimental?.rsc?.enabled) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
name: "cedar-data-uri-shim",
|
|
49
|
+
apply: "serve",
|
|
50
|
+
resolveId(id) {
|
|
51
|
+
if (id === "data-uri-to-buffer") {
|
|
52
|
+
return "\0cedar-data-uri-to-buffer";
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
},
|
|
56
|
+
load(id) {
|
|
57
|
+
if (id === "\0cedar-data-uri-to-buffer") {
|
|
58
|
+
return "export default " + dataUriToBuffer.toString();
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
cedarDataUriShim
|
|
67
|
+
});
|
package/dist/devFeServer.js
CHANGED
|
@@ -232,22 +232,10 @@ async function createServer() {
|
|
|
232
232
|
"busboy",
|
|
233
233
|
"cookie"
|
|
234
234
|
],
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
// the Browserify polyfill is because we have
|
|
240
|
-
// `vite-plugin-node-polyfills` as a dependency, and that'll add
|
|
241
|
-
// Browserify's `node-util` to `node_modules`, so when Vite goes to
|
|
242
|
-
// resolve `import { TextEncoder } from 'util` it'll find the one in
|
|
243
|
-
// `node_modules` instead of Node's internal version.
|
|
244
|
-
// We only see this in dev, and not in prod. I'm not entirely sure why
|
|
245
|
-
// but I have two guesses: 1. When RSC is enabled we don't actually use
|
|
246
|
-
// `vite-plugin-node-polyfill`, so some kind of tree shaking is
|
|
247
|
-
// happening, which prevents the issue from occurring. 2. In prod we
|
|
248
|
-
// only use Node's dependency resolution. Vite is not involved. And
|
|
249
|
-
// that difference in resolution is what prevents the issue from
|
|
250
|
-
// occurring.
|
|
235
|
+
// Ensure `util` resolves to Node's built-in module and not to
|
|
236
|
+
// Browserify's `node-util` polyfill (which lacks TextEncoder).
|
|
237
|
+
// The polyfill may be hoisted into node_modules by optional
|
|
238
|
+
// dependencies like `@cedarjs/storybook`.
|
|
251
239
|
exclude: ["util"]
|
|
252
240
|
}
|
|
253
241
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { cedarCellTransform } from './plugins/vite-plugin-cedar-cell.js';
|
|
|
5
5
|
export { cedarEntryInjectionPlugin } from './plugins/vite-plugin-cedar-entry-injection.js';
|
|
6
6
|
export { cedarHtmlEnvPlugin } from './plugins/vite-plugin-cedar-html-env.js';
|
|
7
7
|
export { cedarImportDirPlugin } from './plugins/vite-plugin-cedar-import-dir.js';
|
|
8
|
-
export {
|
|
8
|
+
export { cedarDataUriShim } from './plugins/vite-plugin-cedar-data-uri-shim.js';
|
|
9
9
|
export { cedarRemoveDevFatalErrorPage } from './plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js';
|
|
10
10
|
export { cedarRoutesAutoLoaderPlugin } from './plugins/vite-plugin-cedar-routes-auto-loader.js';
|
|
11
11
|
export { cedarRemoveFromBundle } from './plugins/vite-plugin-cedar-remove-from-bundle.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAuBxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAuBxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAE1F,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAgClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
createAuthImportTransformPlugin
|
|
8
8
|
} from "@cedarjs/testing/web/vitest";
|
|
9
9
|
import { cedarCellTransform } from "./plugins/vite-plugin-cedar-cell.js";
|
|
10
|
+
import { cedarDataUriShim } from "./plugins/vite-plugin-cedar-data-uri-shim.js";
|
|
10
11
|
import { cedarEntryInjectionPlugin } from "./plugins/vite-plugin-cedar-entry-injection.js";
|
|
11
12
|
import { cedarHtmlEnvPlugin } from "./plugins/vite-plugin-cedar-html-env.js";
|
|
12
|
-
import { cedarNodePolyfills } from "./plugins/vite-plugin-cedar-node-polyfills.js";
|
|
13
13
|
import { cedarRemoveDevFatalErrorPage } from "./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js";
|
|
14
14
|
import { cedarRemoveFromBundle } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
|
|
15
15
|
import { cedarRoutesAutoLoaderPlugin } from "./plugins/vite-plugin-cedar-routes-auto-loader.js";
|
|
@@ -24,7 +24,7 @@ import { cedarCellTransform as cedarCellTransform2 } from "./plugins/vite-plugin
|
|
|
24
24
|
import { cedarEntryInjectionPlugin as cedarEntryInjectionPlugin2 } from "./plugins/vite-plugin-cedar-entry-injection.js";
|
|
25
25
|
import { cedarHtmlEnvPlugin as cedarHtmlEnvPlugin2 } from "./plugins/vite-plugin-cedar-html-env.js";
|
|
26
26
|
import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
|
|
27
|
-
import {
|
|
27
|
+
import { cedarDataUriShim as cedarDataUriShim2 } from "./plugins/vite-plugin-cedar-data-uri-shim.js";
|
|
28
28
|
import { cedarRemoveDevFatalErrorPage as cedarRemoveDevFatalErrorPage2 } from "./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js";
|
|
29
29
|
import { cedarRoutesAutoLoaderPlugin as cedarRoutesAutoLoaderPlugin2 } from "./plugins/vite-plugin-cedar-routes-auto-loader.js";
|
|
30
30
|
import { cedarRemoveFromBundle as cedarRemoveFromBundle2 } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
|
|
@@ -49,7 +49,7 @@ function cedar({ mode } = {}) {
|
|
|
49
49
|
mode === "test" && createAuthImportTransformPlugin(),
|
|
50
50
|
mode === "test" && autoImportsPlugin(),
|
|
51
51
|
cedarWaitForApiServer(),
|
|
52
|
-
|
|
52
|
+
cedarDataUriShim(),
|
|
53
53
|
cedarHtmlEnvPlugin(),
|
|
54
54
|
cedarEntryInjectionPlugin(),
|
|
55
55
|
cedarMergedConfig(),
|
|
@@ -70,11 +70,11 @@ export {
|
|
|
70
70
|
cedarAutoImportsPlugin,
|
|
71
71
|
cedarCellTransform2 as cedarCellTransform,
|
|
72
72
|
cedarCjsCompatPlugin,
|
|
73
|
+
cedarDataUriShim2 as cedarDataUriShim,
|
|
73
74
|
cedarEntryInjectionPlugin2 as cedarEntryInjectionPlugin,
|
|
74
75
|
cedarHtmlEnvPlugin2 as cedarHtmlEnvPlugin,
|
|
75
76
|
cedarImportDirPlugin,
|
|
76
77
|
cedarMergedConfig2 as cedarMergedConfig,
|
|
77
|
-
cedarNodePolyfills2 as cedarNodePolyfills,
|
|
78
78
|
cedarRemoveDevFatalErrorPage2 as cedarRemoveDevFatalErrorPage,
|
|
79
79
|
cedarRemoveFromBundle2 as cedarRemoveFromBundle,
|
|
80
80
|
cedarRoutesAutoLoaderPlugin2 as cedarRoutesAutoLoaderPlugin,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-data-uri-shim.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-data-uri-shim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAgClC,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CA4BrD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
2
|
+
function dataUriToBuffer(uri) {
|
|
3
|
+
const match = uri.match(/^data:(.*?)(;(.*?))?(,(.*))$/);
|
|
4
|
+
if (!match) {
|
|
5
|
+
throw new Error("Invalid data URI");
|
|
6
|
+
}
|
|
7
|
+
const mediaType = match[1] || "text/plain";
|
|
8
|
+
const params = match[3] || "";
|
|
9
|
+
const data = match[5];
|
|
10
|
+
const [type] = mediaType.split(";");
|
|
11
|
+
const typeFull = params ? mediaType + ";" + params : mediaType;
|
|
12
|
+
const lowerParams = params.toLowerCase();
|
|
13
|
+
const isBase64 = lowerParams.includes("base64");
|
|
14
|
+
const charset = lowerParams.startsWith("charset=") ? lowerParams.slice(8) : "";
|
|
15
|
+
const bytes = isBase64 ? Uint8Array.from(atob(data), (c) => c.charCodeAt(0)) : new TextEncoder().encode(decodeURIComponent(data));
|
|
16
|
+
const decoder = new TextDecoder();
|
|
17
|
+
bytes.toString = () => decoder.decode(bytes);
|
|
18
|
+
return Object.assign(bytes, { type, typeFull, charset });
|
|
19
|
+
}
|
|
20
|
+
function cedarDataUriShim() {
|
|
21
|
+
if (getConfig().experimental?.rsc?.enabled) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
name: "cedar-data-uri-shim",
|
|
26
|
+
apply: "serve",
|
|
27
|
+
resolveId(id) {
|
|
28
|
+
if (id === "data-uri-to-buffer") {
|
|
29
|
+
return "\0cedar-data-uri-to-buffer";
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
},
|
|
33
|
+
load(id) {
|
|
34
|
+
if (id === "\0cedar-data-uri-to-buffer") {
|
|
35
|
+
return "export default " + dataUriToBuffer.toString();
|
|
36
|
+
}
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
cedarDataUriShim
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2599",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"@babel/parser": "7.29.7",
|
|
64
64
|
"@babel/traverse": "7.29.7",
|
|
65
65
|
"@babel/types": "7.29.7",
|
|
66
|
-
"@cedarjs/api": "5.0.0-canary.
|
|
67
|
-
"@cedarjs/babel-config": "5.0.0-canary.
|
|
68
|
-
"@cedarjs/context": "5.0.0-canary.
|
|
69
|
-
"@cedarjs/cookie-jar": "5.0.0-canary.
|
|
70
|
-
"@cedarjs/graphql-server": "5.0.0-canary.
|
|
71
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
72
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
73
|
-
"@cedarjs/server-store": "5.0.0-canary.
|
|
74
|
-
"@cedarjs/testing": "5.0.0-canary.
|
|
66
|
+
"@cedarjs/api": "5.0.0-canary.2599",
|
|
67
|
+
"@cedarjs/babel-config": "5.0.0-canary.2599",
|
|
68
|
+
"@cedarjs/context": "5.0.0-canary.2599",
|
|
69
|
+
"@cedarjs/cookie-jar": "5.0.0-canary.2599",
|
|
70
|
+
"@cedarjs/graphql-server": "5.0.0-canary.2599",
|
|
71
|
+
"@cedarjs/internal": "5.0.0-canary.2599",
|
|
72
|
+
"@cedarjs/project-config": "5.0.0-canary.2599",
|
|
73
|
+
"@cedarjs/server-store": "5.0.0-canary.2599",
|
|
74
|
+
"@cedarjs/testing": "5.0.0-canary.2599",
|
|
75
75
|
"@fastify/url-data": "6.0.3",
|
|
76
76
|
"@swc/core": "1.15.41",
|
|
77
77
|
"@universal-deploy/store": "^0.2.1",
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"acorn": "8.16.0",
|
|
83
83
|
"acorn-loose": "8.5.2",
|
|
84
84
|
"ansis": "4.2.0",
|
|
85
|
-
"buffer": "6.0.3",
|
|
86
85
|
"busboy": "^1.6.0",
|
|
87
86
|
"cookie": "1.1.1",
|
|
88
87
|
"dotenv-defaults": "5.0.2",
|
|
@@ -99,15 +98,14 @@
|
|
|
99
98
|
"rou3": "^0.8.1",
|
|
100
99
|
"vite": "7.3.5",
|
|
101
100
|
"vite-plugin-cjs-interop": "2.4.4",
|
|
102
|
-
"vite-plugin-node-polyfills": "0.26.0",
|
|
103
101
|
"ws": "8.20.0",
|
|
104
102
|
"yargs-parser": "21.1.1"
|
|
105
103
|
},
|
|
106
104
|
"devDependencies": {
|
|
107
105
|
"@arethetypeswrong/cli": "0.18.4",
|
|
108
|
-
"@cedarjs/auth": "5.0.0-canary.
|
|
109
|
-
"@cedarjs/router": "5.0.0-canary.
|
|
110
|
-
"@cedarjs/web": "5.0.0-canary.
|
|
106
|
+
"@cedarjs/auth": "5.0.0-canary.2599",
|
|
107
|
+
"@cedarjs/router": "5.0.0-canary.2599",
|
|
108
|
+
"@cedarjs/web": "5.0.0-canary.2599",
|
|
111
109
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
112
110
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
113
111
|
"@types/aws-lambda": "8.10.162",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var vite_plugin_cedar_node_polyfills_exports = {};
|
|
20
|
-
__export(vite_plugin_cedar_node_polyfills_exports, {
|
|
21
|
-
cedarNodePolyfills: () => cedarNodePolyfills
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(vite_plugin_cedar_node_polyfills_exports);
|
|
24
|
-
var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
|
|
25
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
-
function cedarNodePolyfills() {
|
|
27
|
-
if ((0, import_project_config.getConfig)().experimental?.rsc?.enabled) {
|
|
28
|
-
return void 0;
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
...(0, import_vite_plugin_node_polyfills.nodePolyfills)({
|
|
32
|
-
include: ["buffer"],
|
|
33
|
-
globals: {
|
|
34
|
-
Buffer: true
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
apply: "serve"
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
cedarNodePolyfills
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-node-polyfills.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-node-polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAiBvD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
2
|
-
import { getConfig } from "@cedarjs/project-config";
|
|
3
|
-
function cedarNodePolyfills() {
|
|
4
|
-
if (getConfig().experimental?.rsc?.enabled) {
|
|
5
|
-
return void 0;
|
|
6
|
-
}
|
|
7
|
-
return {
|
|
8
|
-
...nodePolyfills({
|
|
9
|
-
include: ["buffer"],
|
|
10
|
-
globals: {
|
|
11
|
-
Buffer: true
|
|
12
|
-
}
|
|
13
|
-
}),
|
|
14
|
-
apply: "serve"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
cedarNodePolyfills
|
|
19
|
-
};
|