hadars 0.4.1 → 0.4.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/{chunk-TV37IMRB.js → chunk-2TMQUXFL.js} +10 -10
- package/dist/{chunk-2J2L2H3H.js → chunk-NYLXE7T7.js} +6 -6
- package/dist/{chunk-OS3V4CPN.js → chunk-OZUZS2PD.js} +4 -4
- package/dist/cli.js +462 -496
- package/dist/cloudflare.cjs +11 -11
- package/dist/cloudflare.js +3 -3
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/lambda.cjs +11 -11
- package/dist/lambda.js +7 -7
- package/dist/loader.cjs +90 -54
- package/dist/slim-react/index.cjs +13 -13
- package/dist/slim-react/index.js +2 -2
- package/dist/slim-react/jsx-runtime.cjs +2 -4
- package/dist/slim-react/jsx-runtime.js +1 -1
- package/dist/ssr-render-worker.js +174 -161
- package/dist/ssr-watch.js +40 -74
- package/package.json +8 -10
- package/cli-lib.ts +0 -676
- package/cli.ts +0 -36
- package/index.ts +0 -17
- package/src/build.ts +0 -805
- package/src/cloudflare.ts +0 -140
- package/src/index.tsx +0 -41
- package/src/lambda.ts +0 -287
- package/src/slim-react/context.ts +0 -55
- package/src/slim-react/dispatcher.ts +0 -87
- package/src/slim-react/hooks.ts +0 -137
- package/src/slim-react/index.ts +0 -232
- package/src/slim-react/jsx-runtime.ts +0 -7
- package/src/slim-react/jsx.ts +0 -53
- package/src/slim-react/render.ts +0 -1101
- package/src/slim-react/renderContext.ts +0 -294
- package/src/slim-react/types.ts +0 -33
- package/src/source/context.ts +0 -113
- package/src/source/graphiql.ts +0 -101
- package/src/source/inference.ts +0 -260
- package/src/source/runner.ts +0 -138
- package/src/source/store.ts +0 -50
- package/src/ssr-render-worker.ts +0 -116
- package/src/ssr-watch.ts +0 -62
- package/src/static.ts +0 -109
- package/src/types/global.d.ts +0 -5
- package/src/types/hadars.ts +0 -350
- package/src/utils/Head.tsx +0 -462
- package/src/utils/clientScript.tsx +0 -71
- package/src/utils/cookies.ts +0 -16
- package/src/utils/loader.ts +0 -335
- package/src/utils/proxyHandler.tsx +0 -104
- package/src/utils/request.tsx +0 -9
- package/src/utils/response.tsx +0 -141
- package/src/utils/rspack.ts +0 -467
- package/src/utils/runtime.ts +0 -19
- package/src/utils/serve.ts +0 -155
- package/src/utils/ssrHandler.ts +0 -239
- package/src/utils/staticFile.ts +0 -43
- package/src/utils/template.html +0 -11
- package/src/utils/upgradeRequest.tsx +0 -19
package/dist/cloudflare.cjs
CHANGED
|
@@ -152,10 +152,10 @@ var createProxyHandler = (options) => {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
// src/slim-react/types.ts
|
|
155
|
-
var SLIM_ELEMENT = Symbol.for("react.element");
|
|
156
|
-
var REACT19_ELEMENT = Symbol.for("react.transitional.element");
|
|
157
|
-
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
158
|
-
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
155
|
+
var SLIM_ELEMENT = /* @__PURE__ */ Symbol.for("react.element");
|
|
156
|
+
var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
157
|
+
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
158
|
+
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
159
159
|
|
|
160
160
|
// src/slim-react/jsx.ts
|
|
161
161
|
function createElement(type, props, ...children) {
|
|
@@ -826,13 +826,13 @@ function renderHostElement(tag, props, writer, isSvg) {
|
|
|
826
826
|
}
|
|
827
827
|
writer.write(`</${tag}>`);
|
|
828
828
|
}
|
|
829
|
-
var REACT_MEMO = Symbol.for("react.memo");
|
|
830
|
-
var REACT_FORWARD_REF = Symbol.for("react.forward_ref");
|
|
831
|
-
var REACT_PROVIDER = Symbol.for("react.provider");
|
|
832
|
-
var REACT_CONTEXT = Symbol.for("react.context");
|
|
833
|
-
var REACT_CONSUMER = Symbol.for("react.consumer");
|
|
834
|
-
var REACT_LAZY = Symbol.for("react.lazy");
|
|
835
|
-
var SUSPENSE_RETRY_LIMIT = Symbol("SuspenseRetryLimit");
|
|
829
|
+
var REACT_MEMO = /* @__PURE__ */ Symbol.for("react.memo");
|
|
830
|
+
var REACT_FORWARD_REF = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
831
|
+
var REACT_PROVIDER = /* @__PURE__ */ Symbol.for("react.provider");
|
|
832
|
+
var REACT_CONTEXT = /* @__PURE__ */ Symbol.for("react.context");
|
|
833
|
+
var REACT_CONSUMER = /* @__PURE__ */ Symbol.for("react.consumer");
|
|
834
|
+
var REACT_LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
835
|
+
var SUSPENSE_RETRY_LIMIT = /* @__PURE__ */ Symbol("SuspenseRetryLimit");
|
|
836
836
|
var MAX_COMPONENT_SUSPENSE_RETRIES = 25;
|
|
837
837
|
function patchPromiseStatus(p) {
|
|
838
838
|
const w = p;
|
package/dist/cloudflare.js
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-NYLXE7T7.js";
|
|
10
|
+
import "./chunk-2TMQUXFL.js";
|
|
11
|
+
import "./chunk-OZUZS2PD.js";
|
|
12
12
|
|
|
13
13
|
// src/cloudflare.ts
|
|
14
14
|
import "react";
|
package/dist/index.d.cts
CHANGED
|
@@ -77,14 +77,18 @@ declare const Head: React.FC<{
|
|
|
77
77
|
* `Promise.resolve(require('./path'))`, which rspack bundles statically.
|
|
78
78
|
*
|
|
79
79
|
* The hadars rspack loader must be active for the transform to apply.
|
|
80
|
-
*
|
|
80
|
+
* **The path argument must be a string literal** at the `loadModule()` call
|
|
81
|
+
* site — passing a variable prevents the loader from transforming the call,
|
|
82
|
+
* so the module is not bundled and build-time transforms (SWC plugins, etc.)
|
|
83
|
+
* are never applied.
|
|
81
84
|
*
|
|
82
85
|
* @example
|
|
83
|
-
* //
|
|
86
|
+
* // Correct — literal path at call site:
|
|
84
87
|
* const MyComp = React.lazy(() => loadModule('./MyComp'));
|
|
85
88
|
*
|
|
86
|
-
* //
|
|
87
|
-
* const { default:
|
|
89
|
+
* // Also correct — wrapper receives the factory, not the path string:
|
|
90
|
+
* const lazy = (fn: () => Promise<{ default: React.FC }>) => React.lazy(fn);
|
|
91
|
+
* const MyComp = lazy(() => loadModule('./MyComp'));
|
|
88
92
|
*/
|
|
89
93
|
declare function loadModule<T = any>(path: string): Promise<T>;
|
|
90
94
|
|
package/dist/index.d.ts
CHANGED
|
@@ -77,14 +77,18 @@ declare const Head: React.FC<{
|
|
|
77
77
|
* `Promise.resolve(require('./path'))`, which rspack bundles statically.
|
|
78
78
|
*
|
|
79
79
|
* The hadars rspack loader must be active for the transform to apply.
|
|
80
|
-
*
|
|
80
|
+
* **The path argument must be a string literal** at the `loadModule()` call
|
|
81
|
+
* site — passing a variable prevents the loader from transforming the call,
|
|
82
|
+
* so the module is not bundled and build-time transforms (SWC plugins, etc.)
|
|
83
|
+
* are never applied.
|
|
81
84
|
*
|
|
82
85
|
* @example
|
|
83
|
-
* //
|
|
86
|
+
* // Correct — literal path at call site:
|
|
84
87
|
* const MyComp = React.lazy(() => loadModule('./MyComp'));
|
|
85
88
|
*
|
|
86
|
-
* //
|
|
87
|
-
* const { default:
|
|
89
|
+
* // Also correct — wrapper receives the factory, not the path string:
|
|
90
|
+
* const lazy = (fn: () => Promise<{ default: React.FC }>) => React.lazy(fn);
|
|
91
|
+
* const MyComp = lazy(() => loadModule('./MyComp'));
|
|
88
92
|
*/
|
|
89
93
|
declare function loadModule<T = any>(path: string): Promise<T>;
|
|
90
94
|
|
package/dist/lambda.cjs
CHANGED
|
@@ -192,10 +192,10 @@ async function tryServeFile(filePath) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/slim-react/types.ts
|
|
195
|
-
var SLIM_ELEMENT = Symbol.for("react.element");
|
|
196
|
-
var REACT19_ELEMENT = Symbol.for("react.transitional.element");
|
|
197
|
-
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
198
|
-
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
195
|
+
var SLIM_ELEMENT = /* @__PURE__ */ Symbol.for("react.element");
|
|
196
|
+
var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
197
|
+
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
198
|
+
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
199
199
|
|
|
200
200
|
// src/slim-react/jsx.ts
|
|
201
201
|
function createElement(type, props, ...children) {
|
|
@@ -866,13 +866,13 @@ function renderHostElement(tag, props, writer, isSvg) {
|
|
|
866
866
|
}
|
|
867
867
|
writer.write(`</${tag}>`);
|
|
868
868
|
}
|
|
869
|
-
var REACT_MEMO = Symbol.for("react.memo");
|
|
870
|
-
var REACT_FORWARD_REF = Symbol.for("react.forward_ref");
|
|
871
|
-
var REACT_PROVIDER = Symbol.for("react.provider");
|
|
872
|
-
var REACT_CONTEXT = Symbol.for("react.context");
|
|
873
|
-
var REACT_CONSUMER = Symbol.for("react.consumer");
|
|
874
|
-
var REACT_LAZY = Symbol.for("react.lazy");
|
|
875
|
-
var SUSPENSE_RETRY_LIMIT = Symbol("SuspenseRetryLimit");
|
|
869
|
+
var REACT_MEMO = /* @__PURE__ */ Symbol.for("react.memo");
|
|
870
|
+
var REACT_FORWARD_REF = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
871
|
+
var REACT_PROVIDER = /* @__PURE__ */ Symbol.for("react.provider");
|
|
872
|
+
var REACT_CONTEXT = /* @__PURE__ */ Symbol.for("react.context");
|
|
873
|
+
var REACT_CONSUMER = /* @__PURE__ */ Symbol.for("react.consumer");
|
|
874
|
+
var REACT_LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
875
|
+
var SUSPENSE_RETRY_LIMIT = /* @__PURE__ */ Symbol("SuspenseRetryLimit");
|
|
876
876
|
var MAX_COMPONENT_SUSPENSE_RETRIES = 25;
|
|
877
877
|
function patchPromiseStatus(p) {
|
|
878
878
|
const w = p;
|
package/dist/lambda.js
CHANGED
|
@@ -6,18 +6,18 @@ import {
|
|
|
6
6
|
getReactResponse,
|
|
7
7
|
makePrecontentHtmlGetter,
|
|
8
8
|
parseRequest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-NYLXE7T7.js";
|
|
10
|
+
import "./chunk-2TMQUXFL.js";
|
|
11
|
+
import "./chunk-OZUZS2PD.js";
|
|
12
12
|
|
|
13
13
|
// src/lambda.ts
|
|
14
14
|
import "react";
|
|
15
|
-
import pathMod from "
|
|
16
|
-
import { pathToFileURL } from "
|
|
17
|
-
import fs from "
|
|
15
|
+
import pathMod from "path";
|
|
16
|
+
import { pathToFileURL } from "url";
|
|
17
|
+
import fs from "fs/promises";
|
|
18
18
|
|
|
19
19
|
// src/utils/staticFile.ts
|
|
20
|
-
import { readFile } from "
|
|
20
|
+
import { readFile } from "fs/promises";
|
|
21
21
|
var MIME = {
|
|
22
22
|
html: "text/html; charset=utf-8",
|
|
23
23
|
htm: "text/html; charset=utf-8",
|
package/dist/loader.cjs
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
11
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (
|
|
13
|
-
if (!__hasOwnProp.call(
|
|
14
|
-
__defProp(
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
15
20
|
}
|
|
16
|
-
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
17
23
|
};
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/utils/loader.ts
|
|
40
|
+
var exports_loader = {};
|
|
41
|
+
__export(exports_loader, {
|
|
21
42
|
default: () => loader
|
|
22
43
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
44
|
+
module.exports = __toCommonJS(exports_loader);
|
|
24
45
|
function loader(source) {
|
|
25
46
|
const opts = this.getOptions?.() ?? {};
|
|
26
47
|
const isServer = typeof opts.server === "boolean" ? opts.server : this.target === "node" || this.target === "async-node";
|
|
@@ -49,13 +70,16 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
49
70
|
const fileOffset = ast.span.start - countLeadingNonCodeBytes(source);
|
|
50
71
|
const replacements = [];
|
|
51
72
|
walkAst(ast, (node) => {
|
|
52
|
-
if (node.type !== "CallExpression")
|
|
73
|
+
if (node.type !== "CallExpression")
|
|
74
|
+
return;
|
|
53
75
|
const callee = node.callee;
|
|
54
|
-
if (!callee || callee.type !== "Identifier")
|
|
76
|
+
if (!callee || callee.type !== "Identifier")
|
|
77
|
+
return;
|
|
55
78
|
const name = callee.value;
|
|
56
79
|
if (!isServer && name === "useServerData") {
|
|
57
80
|
const args2 = node.arguments;
|
|
58
|
-
if (!args2 || args2.length < 1)
|
|
81
|
+
if (!args2 || args2.length < 1)
|
|
82
|
+
return;
|
|
59
83
|
const fnArg = args2[0].expression ?? args2[0];
|
|
60
84
|
replacements.push({
|
|
61
85
|
start: fnArg.span.start - fileOffset,
|
|
@@ -64,9 +88,11 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
64
88
|
});
|
|
65
89
|
return;
|
|
66
90
|
}
|
|
67
|
-
if (name !== "loadModule")
|
|
91
|
+
if (name !== "loadModule")
|
|
92
|
+
return;
|
|
68
93
|
const args = node.arguments;
|
|
69
|
-
if (!args || args.length === 0)
|
|
94
|
+
if (!args || args.length === 0)
|
|
95
|
+
return;
|
|
70
96
|
const firstArg = args[0].expression ?? args[0];
|
|
71
97
|
let modulePath;
|
|
72
98
|
let quoteChar;
|
|
@@ -80,18 +106,16 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
80
106
|
} else {
|
|
81
107
|
const start0 = node.span.start - fileOffset;
|
|
82
108
|
const bytesBefore = srcBytes.slice(0, start0);
|
|
83
|
-
const line = bytesBefore.toString("utf8").split(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`[hadars] loadModule() called with a dynamic (non-literal) path at ${resourcePath}:${line}. Only string-literal paths are transformed by the loader; dynamic calls fall back to runtime import().`
|
|
87
|
-
)
|
|
88
|
-
);
|
|
109
|
+
const line = bytesBefore.toString("utf8").split(`
|
|
110
|
+
`).length;
|
|
111
|
+
this.emitWarning(new Error(`[hadars] loadModule() called with a dynamic (non-literal) path at ${resourcePath}:${line}. ` + `The module will not be bundled. Use a string literal: loadModule('./myPage').`));
|
|
89
112
|
return;
|
|
90
113
|
}
|
|
91
114
|
const replacement = isServer ? `Promise.resolve(require(${quoteChar}${modulePath}${quoteChar}))` : `import(${quoteChar}${modulePath}${quoteChar})`;
|
|
92
115
|
replacements.push({ start: node.span.start - fileOffset, end: node.span.end - fileOffset, replacement });
|
|
93
116
|
});
|
|
94
|
-
if (replacements.length === 0)
|
|
117
|
+
if (replacements.length === 0)
|
|
118
|
+
return source;
|
|
95
119
|
replacements.sort((a, b) => b.start - a.start);
|
|
96
120
|
let result = srcBytes;
|
|
97
121
|
for (const { start, end, replacement } of replacements) {
|
|
@@ -100,13 +124,16 @@ function swcTransform(swc, source, isServer, resourcePath) {
|
|
|
100
124
|
return result.toString("utf8");
|
|
101
125
|
}
|
|
102
126
|
function walkAst(node, visit) {
|
|
103
|
-
if (!node || typeof node !== "object")
|
|
127
|
+
if (!node || typeof node !== "object")
|
|
128
|
+
return;
|
|
104
129
|
visit(node);
|
|
105
130
|
for (const key of Object.keys(node)) {
|
|
106
|
-
if (key === "span" || key === "type" || key === "ctxt")
|
|
131
|
+
if (key === "span" || key === "type" || key === "ctxt")
|
|
132
|
+
continue;
|
|
107
133
|
const val = node[key];
|
|
108
134
|
if (Array.isArray(val)) {
|
|
109
|
-
for (const child of val)
|
|
135
|
+
for (const child of val)
|
|
136
|
+
walkAst(child, visit);
|
|
110
137
|
} else if (val && typeof val === "object") {
|
|
111
138
|
walkAst(val, visit);
|
|
112
139
|
}
|
|
@@ -115,30 +142,37 @@ function walkAst(node, visit) {
|
|
|
115
142
|
function countLeadingNonCodeBytes(source) {
|
|
116
143
|
let i = 0;
|
|
117
144
|
while (i < source.length) {
|
|
118
|
-
if (source[i] === " " || source[i] === "
|
|
145
|
+
if (source[i] === " " || source[i] === "\t" || source[i] === "\r" || source[i] === `
|
|
146
|
+
`) {
|
|
119
147
|
i++;
|
|
120
148
|
continue;
|
|
121
149
|
}
|
|
122
150
|
if (source[i] === "/" && source[i + 1] === "/") {
|
|
123
|
-
while (i < source.length && source[i] !==
|
|
151
|
+
while (i < source.length && source[i] !== `
|
|
152
|
+
`)
|
|
153
|
+
i++;
|
|
124
154
|
continue;
|
|
125
155
|
}
|
|
126
156
|
if (source[i] === "/" && source[i + 1] === "*") {
|
|
127
157
|
i += 2;
|
|
128
|
-
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
129
|
-
|
|
158
|
+
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
159
|
+
i++;
|
|
160
|
+
if (i + 1 < source.length)
|
|
161
|
+
i += 2;
|
|
130
162
|
continue;
|
|
131
163
|
}
|
|
132
164
|
if (i === 0 && source[i] === "#" && source[i + 1] === "!") {
|
|
133
|
-
while (i < source.length && source[i] !==
|
|
165
|
+
while (i < source.length && source[i] !== `
|
|
166
|
+
`)
|
|
167
|
+
i++;
|
|
134
168
|
continue;
|
|
135
169
|
}
|
|
136
170
|
break;
|
|
137
171
|
}
|
|
138
172
|
return Buffer.byteLength(source.slice(0, i), "utf8");
|
|
139
173
|
}
|
|
140
|
-
|
|
141
|
-
|
|
174
|
+
var LOAD_MODULE_RE = /\bloadModule\s*(?:<(?:[^<>]|<[^<>]*>)*>\s*)?\(\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1\s*\)/gs;
|
|
175
|
+
var DYNAMIC_LOAD_MODULE_RE = /\bloadModule\s*(?:<(?:[^<>]|<[^<>]*>)*>\s*)?\(/g;
|
|
142
176
|
function scanExpressionEnd(source, pos) {
|
|
143
177
|
let depth = 0;
|
|
144
178
|
let i = pos;
|
|
@@ -150,29 +184,35 @@ function scanExpressionEnd(source, pos) {
|
|
|
150
184
|
continue;
|
|
151
185
|
}
|
|
152
186
|
if (ch === ")" || ch === "]" || ch === "}") {
|
|
153
|
-
if (depth === 0)
|
|
187
|
+
if (depth === 0)
|
|
188
|
+
break;
|
|
154
189
|
depth--;
|
|
155
190
|
i++;
|
|
156
191
|
continue;
|
|
157
192
|
}
|
|
158
|
-
if (ch === "," && depth === 0)
|
|
193
|
+
if (ch === "," && depth === 0)
|
|
194
|
+
break;
|
|
159
195
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
160
196
|
const q = ch;
|
|
161
197
|
i++;
|
|
162
198
|
while (i < source.length && source[i] !== q) {
|
|
163
|
-
if (source[i] === "\\")
|
|
199
|
+
if (source[i] === "\\")
|
|
200
|
+
i++;
|
|
164
201
|
i++;
|
|
165
202
|
}
|
|
166
203
|
i++;
|
|
167
204
|
continue;
|
|
168
205
|
}
|
|
169
206
|
if (ch === "/" && source[i + 1] === "/") {
|
|
170
|
-
while (i < source.length && source[i] !==
|
|
207
|
+
while (i < source.length && source[i] !== `
|
|
208
|
+
`)
|
|
209
|
+
i++;
|
|
171
210
|
continue;
|
|
172
211
|
}
|
|
173
212
|
if (ch === "/" && source[i + 1] === "*") {
|
|
174
213
|
i += 2;
|
|
175
|
-
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
214
|
+
while (i + 1 < source.length && !(source[i] === "*" && source[i + 1] === "/"))
|
|
215
|
+
i++;
|
|
176
216
|
i += 2;
|
|
177
217
|
continue;
|
|
178
218
|
}
|
|
@@ -188,10 +228,12 @@ function stripUseServerDataFns(source) {
|
|
|
188
228
|
CALL_RE.lastIndex = 0;
|
|
189
229
|
while ((match = CALL_RE.exec(source)) !== null) {
|
|
190
230
|
let i = match.index + match[0].length;
|
|
191
|
-
while (i < source.length && /\s/.test(source[i]))
|
|
231
|
+
while (i < source.length && /\s/.test(source[i]))
|
|
232
|
+
i++;
|
|
192
233
|
const fnStart = i;
|
|
193
234
|
const fnEnd = scanExpressionEnd(source, i);
|
|
194
|
-
if (fnEnd <= fnStart)
|
|
235
|
+
if (fnEnd <= fnStart)
|
|
236
|
+
continue;
|
|
195
237
|
result += source.slice(lastIndex, fnStart) + "()=>undefined";
|
|
196
238
|
lastIndex = fnEnd;
|
|
197
239
|
CALL_RE.lastIndex = fnEnd;
|
|
@@ -199,22 +241,16 @@ function stripUseServerDataFns(source) {
|
|
|
199
241
|
return lastIndex === 0 ? source : result + source.slice(lastIndex);
|
|
200
242
|
}
|
|
201
243
|
function regexTransform(source, isServer, resourcePath) {
|
|
202
|
-
let transformed = source.replace(
|
|
203
|
-
LOAD_MODULE_RE,
|
|
204
|
-
(_match, quote, modulePath) => isServer ? `Promise.resolve(require(${quote}${modulePath}${quote}))` : `import(${quote}${modulePath}${quote})`
|
|
205
|
-
);
|
|
244
|
+
let transformed = source.replace(LOAD_MODULE_RE, (_match, quote, modulePath) => isServer ? `Promise.resolve(require(${quote}${modulePath}${quote}))` : `import(${quote}${modulePath}${quote})`);
|
|
206
245
|
if (!isServer) {
|
|
207
246
|
transformed = stripUseServerDataFns(transformed);
|
|
208
247
|
}
|
|
209
248
|
let match;
|
|
210
249
|
DYNAMIC_LOAD_MODULE_RE.lastIndex = 0;
|
|
211
250
|
while ((match = DYNAMIC_LOAD_MODULE_RE.exec(transformed)) !== null) {
|
|
212
|
-
const line = transformed.slice(0, match.index).split(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
`[hadars] loadModule() called with a dynamic (non-literal) path at ${resourcePath}:${line}. Only string-literal paths are transformed by the loader; dynamic calls fall back to runtime import().`
|
|
216
|
-
)
|
|
217
|
-
);
|
|
251
|
+
const line = transformed.slice(0, match.index).split(`
|
|
252
|
+
`).length;
|
|
253
|
+
this.emitWarning(new Error(`[hadars] loadModule() called with a dynamic (non-literal) path at ${resourcePath}:${line}. ` + `The module will not be bundled. Use a string literal: loadModule('./myPage').`));
|
|
218
254
|
}
|
|
219
255
|
return transformed;
|
|
220
256
|
}
|
|
@@ -78,10 +78,10 @@ __export(slim_react_exports, {
|
|
|
78
78
|
module.exports = __toCommonJS(slim_react_exports);
|
|
79
79
|
|
|
80
80
|
// src/slim-react/types.ts
|
|
81
|
-
var SLIM_ELEMENT = Symbol.for("react.element");
|
|
82
|
-
var REACT19_ELEMENT = Symbol.for("react.transitional.element");
|
|
83
|
-
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
84
|
-
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
81
|
+
var SLIM_ELEMENT = /* @__PURE__ */ Symbol.for("react.element");
|
|
82
|
+
var REACT19_ELEMENT = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
83
|
+
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
84
|
+
var SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
85
85
|
|
|
86
86
|
// src/slim-react/jsx.ts
|
|
87
87
|
var Fragment = FRAGMENT_TYPE;
|
|
@@ -793,13 +793,13 @@ function renderHostElement(tag, props, writer, isSvg) {
|
|
|
793
793
|
}
|
|
794
794
|
writer.write(`</${tag}>`);
|
|
795
795
|
}
|
|
796
|
-
var REACT_MEMO = Symbol.for("react.memo");
|
|
797
|
-
var REACT_FORWARD_REF = Symbol.for("react.forward_ref");
|
|
798
|
-
var REACT_PROVIDER = Symbol.for("react.provider");
|
|
799
|
-
var REACT_CONTEXT = Symbol.for("react.context");
|
|
800
|
-
var REACT_CONSUMER = Symbol.for("react.consumer");
|
|
801
|
-
var REACT_LAZY = Symbol.for("react.lazy");
|
|
802
|
-
var SUSPENSE_RETRY_LIMIT = Symbol("SuspenseRetryLimit");
|
|
796
|
+
var REACT_MEMO = /* @__PURE__ */ Symbol.for("react.memo");
|
|
797
|
+
var REACT_FORWARD_REF = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
798
|
+
var REACT_PROVIDER = /* @__PURE__ */ Symbol.for("react.provider");
|
|
799
|
+
var REACT_CONTEXT = /* @__PURE__ */ Symbol.for("react.context");
|
|
800
|
+
var REACT_CONSUMER = /* @__PURE__ */ Symbol.for("react.consumer");
|
|
801
|
+
var REACT_LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
802
|
+
var SUSPENSE_RETRY_LIMIT = /* @__PURE__ */ Symbol("SuspenseRetryLimit");
|
|
803
803
|
var MAX_COMPONENT_SUSPENSE_RETRIES = 25;
|
|
804
804
|
function patchPromiseStatus(p) {
|
|
805
805
|
const w = p;
|
|
@@ -1168,14 +1168,14 @@ function cloneElement(element, overrideProps, ...children) {
|
|
|
1168
1168
|
}
|
|
1169
1169
|
function forwardRef(render) {
|
|
1170
1170
|
return {
|
|
1171
|
-
$$typeof: Symbol.for("react.forward_ref"),
|
|
1171
|
+
$$typeof: /* @__PURE__ */ Symbol.for("react.forward_ref"),
|
|
1172
1172
|
render,
|
|
1173
1173
|
displayName: render.displayName || render.name || "ForwardRef"
|
|
1174
1174
|
};
|
|
1175
1175
|
}
|
|
1176
1176
|
function memo(component, compare) {
|
|
1177
1177
|
return {
|
|
1178
|
-
$$typeof: Symbol.for("react.memo"),
|
|
1178
|
+
$$typeof: /* @__PURE__ */ Symbol.for("react.memo"),
|
|
1179
1179
|
type: component,
|
|
1180
1180
|
compare: compare ?? null
|
|
1181
1181
|
};
|
package/dist/slim-react/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
useSyncExternalStore,
|
|
35
35
|
useTransition,
|
|
36
36
|
version
|
|
37
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-2TMQUXFL.js";
|
|
38
38
|
import {
|
|
39
39
|
FRAGMENT_TYPE,
|
|
40
40
|
Fragment,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
SUSPENSE_TYPE,
|
|
43
43
|
createElement,
|
|
44
44
|
jsx
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-OZUZS2PD.js";
|
|
46
46
|
export {
|
|
47
47
|
Children,
|
|
48
48
|
Component,
|
|
@@ -28,10 +28,8 @@ __export(jsx_runtime_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(jsx_runtime_exports);
|
|
29
29
|
|
|
30
30
|
// src/slim-react/types.ts
|
|
31
|
-
var SLIM_ELEMENT = Symbol.for("react.element");
|
|
32
|
-
var
|
|
33
|
-
var FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
34
|
-
var SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
31
|
+
var SLIM_ELEMENT = /* @__PURE__ */ Symbol.for("react.element");
|
|
32
|
+
var FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
35
33
|
|
|
36
34
|
// src/slim-react/jsx.ts
|
|
37
35
|
var Fragment = FRAGMENT_TYPE;
|