@atom.io/spa 0.0.0 → 0.0.1
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/astro-client.js +3 -3
- package/dist/astro-server.js +2 -2
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/development/astro-client.js +3 -3
- package/dist/development/astro-server.js +2 -2
- package/dist/development/astro.js +1 -1
- package/dist/development/index.js +1 -1
- package/dist/development/server.js +14 -5
- package/dist/development/server.js.map +1 -1
- package/dist/development/{vite-BadrFSIM.js → vite-CQchIQ_-.js} +3 -3
- package/dist/development/vite-CQchIQ_-.js.map +1 -0
- package/dist/development/vite.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +14 -5
- package/dist/server.js.map +1 -1
- package/dist/size.json +2 -2
- package/dist/{vite-BadrFSIM.js → vite-CQchIQ_-.js} +3 -3
- package/dist/vite-CQchIQ_-.js.map +1 -0
- package/dist/vite.js +1 -1
- package/package.json +131 -131
- package/src/compiler.ts +5 -4
- package/src/server.ts +18 -13
- package/dist/development/vite-BadrFSIM.js.map +0 -1
- package/dist/vite-BadrFSIM.js.map +0 -1
package/dist/astro-client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as onCleanup, y as useValue } from "./core-Dvqm7w2y.js";
|
|
2
|
-
import { n as render, t as hydrate } from "./dom-BR9o9wZW.js";
|
|
3
|
-
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
4
1
|
import { browserApplication } from "./astro-application.js";
|
|
2
|
+
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
5
3
|
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { s as onCleanup, y as useValue } from "./core-Dvqm7w2y.js";
|
|
5
|
+
import { n as render, t as hydrate } from "./dom-BR9o9wZW.js";
|
|
6
6
|
import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, setIntoStore } from "atom.io/internal";
|
|
7
7
|
// src/astro-client.ts
|
|
8
8
|
const roots = /* @__PURE__ */ new WeakMap();
|
package/dist/astro-server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { renderToString } from "./server.js";
|
|
2
1
|
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
3
|
-
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
2
|
import { t as requestApplication } from "./astro-request-DRKvDjsO.js";
|
|
3
|
+
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { renderToString } from "./server.js";
|
|
5
5
|
// src/astro-server.ts
|
|
6
6
|
const renderer = {
|
|
7
7
|
name: `spa`,
|
package/dist/astro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-DkZaqX7L.js";
|
|
2
1
|
import { SpaPluginOptions } from "./vite.js";
|
|
2
|
+
import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-DkZaqX7L.js";
|
|
3
3
|
import { AstroIntegration } from "astro";
|
|
4
4
|
export default function integration(options?: SpaPluginOptions): AstroIntegration;
|
|
5
5
|
export type { AstroApplicationContext, AstroStoreContext, AstroStoreFactory, AstroStorePreparation, Island };
|
package/dist/astro.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as onCleanup, y as useValue } from "./core-DB3sQz4h.js";
|
|
2
|
-
import { n as render, t as hydrate } from "./dom-D9cY6l1R.js";
|
|
3
|
-
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
4
1
|
import { browserApplication } from "./astro-application.js";
|
|
2
|
+
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
5
3
|
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { s as onCleanup, y as useValue } from "./core-DB3sQz4h.js";
|
|
5
|
+
import { n as render, t as hydrate } from "./dom-D9cY6l1R.js";
|
|
6
6
|
import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, setIntoStore } from "atom.io/internal";
|
|
7
7
|
// src/astro-client.ts
|
|
8
8
|
const roots = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { renderToString } from "./server.js";
|
|
2
1
|
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
3
|
-
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
2
|
import { t as requestApplication } from "./astro-request-DRKvDjsO.js";
|
|
3
|
+
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { renderToString } from "./server.js";
|
|
5
5
|
// src/astro-server.ts
|
|
6
6
|
const renderer = {
|
|
7
7
|
name: `spa`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as useTimeline, c as onMount, d as resolveStateToken, g as useStore, h as useSetter, l as owner, m as useRef, p as useId, s as onCleanup, v as useTransaction, y as useValue } from "./core-DB3sQz4h.js";
|
|
2
|
-
import { Fragment } from "./jsx-runtime.js";
|
|
3
2
|
import { n as render, t as hydrate } from "./dom-D9cY6l1R.js";
|
|
3
|
+
import { Fragment } from "./jsx-runtime.js";
|
|
4
4
|
import { withdraw } from "atom.io/internal";
|
|
5
5
|
// src/use-loadable.ts
|
|
6
6
|
function useLoadable(...params) {
|
|
@@ -9,7 +9,7 @@ const escape = (value) => String(value).replace(/[&<>"']/g, (char) => ({
|
|
|
9
9
|
"'": `'`
|
|
10
10
|
})[char]);
|
|
11
11
|
const voidTags = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
|
|
12
|
-
const booleans = new Set(`allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate
|
|
12
|
+
const booleans = new Set(`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(` `));
|
|
13
13
|
function stringify(value, owner, namespace = `html`, selectValue) {
|
|
14
14
|
if (typeof value === `function`) {
|
|
15
15
|
const values = [untrack(value)].flat(Infinity);
|
|
@@ -41,17 +41,26 @@ function stringify(value, owner, namespace = `html`, selectValue) {
|
|
|
41
41
|
if (key === `children` || key === `ref` || key === `key` || key.startsWith(`on`)) continue;
|
|
42
42
|
if (/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(key)) throw new Error(`spa: owned content`);
|
|
43
43
|
let attribute = props[key];
|
|
44
|
+
if (ns === `html`) {
|
|
45
|
+
if (key === `defaultValue` && (type === `input` || type === `textarea`)) {
|
|
46
|
+
if (props[`value`] != null) continue;
|
|
47
|
+
key = `value`;
|
|
48
|
+
} else if (key === `defaultChecked` && type === `input`) {
|
|
49
|
+
if (props[`checked`] != null) continue;
|
|
50
|
+
key = `checked`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
if (key === `className`) key = `class`;
|
|
45
54
|
if (key === `htmlFor`) key = `for`;
|
|
46
55
|
if (!/^[^\s"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`);
|
|
47
56
|
if (key === `value` && (type === `select` || type === `textarea`)) {
|
|
48
|
-
textValue = attribute;
|
|
57
|
+
textValue = attribute ?? textValue;
|
|
49
58
|
continue;
|
|
50
59
|
}
|
|
51
60
|
if (key === `style` && attribute != null && typeof attribute !== `string`) throw new TypeError(`spa: CSS string required`);
|
|
52
|
-
const boolean = ns === `html` && booleans.has(key.toLowerCase());
|
|
53
|
-
if (attribute == null || boolean && !attribute
|
|
54
|
-
attrs += boolean
|
|
61
|
+
const boolean = ns === `html` && (booleans.has(key.toLowerCase()) || /^(capture|download|hidden)$/.test(key) && typeof attribute === `boolean`);
|
|
62
|
+
if (attribute == null || boolean && !attribute) continue;
|
|
63
|
+
attrs += boolean ? ` ${key}=""` : ` ${key}="${escape(attribute)}"`;
|
|
55
64
|
}
|
|
56
65
|
if (type === `option` && selectValue !== void 0 && String(props[`value`]) === String(selectValue)) attrs += ` selected=""`;
|
|
57
66
|
if (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../../src/server.ts"],"sourcesContent":["import type { Child, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&`, \"<\": `<`, \">\": `>`, '\"': `"`, \"'\": `'` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../src/server.ts"],"sourcesContent":["import type { Child, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&`, \"<\": `<`, \">\": `>`, '\"': `"`, \"'\": `'` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(\n\t\t` `,\n\t),\n)\nfunction stringify(\n\tvalue: Child,\n\towner: Scope,\n\tnamespace = `html`,\n\tselectValue?: string | number,\n): string {\n\tif (typeof value === `function`) {\n\t\tconst values = ([untrack(value)] as unknown[]).flat(Infinity) as Child[]\n\t\tconst keys = new Set<unknown>()\n\t\treturn (\n\t\t\t`<!--{-->` +\n\t\t\tvalues\n\t\t\t\t.map((child, index) => {\n\t\t\t\t\tconst explicit = (child as VNode | null)?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (keys.has(key)) throw new Error(`spa: duplicate key`)\n\t\t\t\t\tkeys.add(key)\n\t\t\t\t\treturn `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`\n\t\t\t\t})\n\t\t\t\t.join(``) +\n\t\t\t`<!--}-->`\n\t\t)\n\t}\n\tif (Array.isArray(value))\n\t\treturn value\n\t\t\t.map((child) => stringify(child, owner, namespace, selectValue))\n\t\t\t.join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (typeof value !== `object`) return `<!--t-->${escape(value)}`\n\tif (!(`type` in value) || !(`props` in value))\n\t\tthrow new TypeError(`spa: invalid child`)\n\tconst { type, props } = value\n\tif (!type || type === Fragment)\n\t\treturn stringify(() => props[`children`], owner, namespace, selectValue)\n\tif (typeof type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\treturn within(childOwner, () =>\n\t\t\tstringify(\n\t\t\t\tuntrack(() => type(props)),\n\t\t\t\tchildOwner,\n\t\t\t\tnamespace,\n\t\t\t\tselectValue,\n\t\t\t),\n\t\t)\n\t}\n\tif (!/^[A-Za-z][\\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`)\n\tif (type === `astro-slot`)\n\t\treturn `<astro-slot${props[`name`] ? ` name=\"${escape(props[`name`])}\"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`\n\tconst ns = type === `svg` ? `svg` : namespace\n\tlet attrs = ``\n\tlet textValue: string | number | undefined\n\tfor (let key of Object.keys(props)) {\n\t\tif (\n\t\t\tkey === `children` ||\n\t\t\tkey === `ref` ||\n\t\t\tkey === `key` ||\n\t\t\tkey.startsWith(`on`)\n\t\t)\n\t\t\tcontinue\n\t\tif (\n\t\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`spa: owned content`)\n\t\tlet attribute = props[key]\n\t\tif (ns === `html`) {\n\t\t\tif (key === `defaultValue` && (type === `input` || type === `textarea`)) {\n\t\t\t\tif (props[`value`] != null) continue\n\t\t\t\tkey = `value`\n\t\t\t} else if (key === `defaultChecked` && type === `input`) {\n\t\t\t\tif (props[`checked`] != null) continue\n\t\t\t\tkey = `checked`\n\t\t\t}\n\t\t}\n\t\tif (key === `className`) key = `class`\n\t\tif (key === `htmlFor`) key = `for`\n\t\tif (!/^[^\\s\"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)\n\t\tif (key === `value` && (type === `select` || type === `textarea`)) {\n\t\t\ttextValue = attribute ?? textValue\n\t\t\tcontinue\n\t\t}\n\t\tif (key === `style` && attribute != null && typeof attribute !== `string`)\n\t\t\tthrow new TypeError(`spa: CSS string required`)\n\t\tconst boolean =\n\t\t\tns === `html` &&\n\t\t\t(booleans.has(key.toLowerCase()) ||\n\t\t\t\t(/^(capture|download|hidden)$/.test(key) &&\n\t\t\t\t\ttypeof attribute === `boolean`))\n\t\tif (attribute == null || (boolean && !attribute)) continue\n\t\tattrs += boolean ? ` ${key}=\"\"` : ` ${key}=\"${escape(attribute)}\"`\n\t}\n\tif (\n\t\ttype === `option` &&\n\t\tselectValue !== undefined &&\n\t\tString(props[`value`]) === String(selectValue)\n\t)\n\t\tattrs += ` selected=\"\"`\n\tif (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`\n\tif (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {\n\t\tlet text = plain(\n\t\t\ttype === `textarea` ? (textValue ?? props[`children`]) : props[`children`],\n\t\t)\n\t\tif (type === `textarea` && text.startsWith(`\\n`)) text = `\\n${text}`\n\t\tif (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text))\n\t\t\tthrow new Error(`spa: unsafe raw text`)\n\t\treturn `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`\n\t}\n\tconst children = stringify(\n\t\t() => props[`children`],\n\t\towner,\n\t\ttype === `foreignObject` ? `html` : ns,\n\t\ttype === `select` ? textValue : selectValue,\n\t)\n\treturn `<${type}${attrs}>${children}</${type}>`\n}\n\nexport function renderToString(\n\tsetup: () => Child,\n\toptions: RootOptions = {},\n): string {\n\tconst root = createRoot(options, true)\n\tif (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`)\n\ttry {\n\t\treturn `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`\n\t} finally {\n\t\tdispose(root)\n\t}\n}\n"],"mappings":";;;AAWA,MAAM,UAAU,UACf,OAAO,KAAK,CAAC,CAAC,QACb,aACC,UACC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,EAAA,CACtE,KAEH;AACD,MAAM,WACL;AACD,MAAM,WAAW,IAAI,IACpB,qVAAqV,MACpV,GACD,CACD;AACA,SAAS,UACR,OACA,OACA,YAAY,QACZ,aACS;CACT,IAAI,OAAO,UAAU,YAAY;EAChC,MAAM,SAAU,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAe,KAAK,QAAQ;EAC5D,MAAM,uBAAO,IAAI,IAAa;EAC9B,OACC,aACA,OACE,KAAK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AAQ,GAAG,CAAC,CAAC,KAAK,IAAI,GAC1E,MAAM,IAAI,MAAM,sBAAsB;EACvC,OAAO,IAAI,OAAO,MAAM,GAAG,mBAAmB,KAAK,IAAI,IAAI,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK;CACzF;CACA,MAAM,WAAW,gBACV,MAAM,aACZ,OACA,SAAS,kBAAkB,SAAS,IACpC,SAAS,WAAW,YAAY,WACjC;CACA,OAAO,IAAI,OAAO,MAAM,GAAG,SAAS,IAAI,KAAK;AAC9C;AAEA,SAAgB,eACf,OACA,UAAuB,CAAC,GACf;CACT,MAAM,OAAO,WAAW,SAAS,IAAI;CACrC,IAAI,UAAU,KAAK,KAAK,OAAO,GAAG,MAAM,IAAI,MAAM,uBAAuB;CACzE,IAAI;EACH,OAAO,SAAS,KAAK,QAAQ,KAAK,OAAO,YAAY,UAAU,QAAQ,KAAK,GAAG,IAAI,CAAC,EAAE;CACvF,UAAU;EACT,QAAQ,IAAI;CACb;AACD"}
|
|
@@ -57,13 +57,13 @@ function compile(code, filename) {
|
|
|
57
57
|
const children = types.react.buildChildren(node).map((value) => child(value));
|
|
58
58
|
if (children.length) properties.push(types.objectProperty(types.identifier(`children`), children.length === 1 ? children[0] : types.arrayExpression(children)));
|
|
59
59
|
flush();
|
|
60
|
-
const props = chunks.length > 1 ? types.callExpression(merge, chunks) : chunks[0] ?? types.objectExpression([]);
|
|
60
|
+
const props = chunks.length > 1 || types.isArrowFunctionExpression(chunks[0]) ? types.callExpression(merge, chunks) : chunks[0] ?? types.objectExpression([]);
|
|
61
61
|
const result = types.callExpression(create, [types.isJSXElement(node) ? name(node.openingElement.name) : types.nullLiteral(), props]);
|
|
62
62
|
generated.add(result);
|
|
63
63
|
let fn = path.findParent((parent) => parent.isFunction());
|
|
64
64
|
while (fn?.findParent((parent) => parent.isFunction())) fn = fn.findParent((parent) => parent.isFunction());
|
|
65
65
|
if (fn) {
|
|
66
|
-
if (fn.node.id) components.add(fn.node.id.name);
|
|
66
|
+
if (fn.isFunctionDeclaration() && fn.node.id) components.add(fn.node.id.name);
|
|
67
67
|
else if (fn.parentPath.isVariableDeclarator() && types.isIdentifier(fn.parentPath.node.id)) components.add(fn.parentPath.node.id.name);
|
|
68
68
|
else if (fn.parentPath.isExportDefaultDeclaration() && types.isFunctionDeclaration(fn.node)) {
|
|
69
69
|
fn.node.id = path.scope.generateUidIdentifier(`Component`);
|
|
@@ -123,4 +123,4 @@ function spa(options = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
export { spa as t };
|
|
125
125
|
|
|
126
|
-
//# sourceMappingURL=vite-
|
|
126
|
+
//# sourceMappingURL=vite-CQchIQ_-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-CQchIQ_-.js","names":["t"],"sources":["../../src/compiler.ts","../../src/vite.ts"],"sourcesContent":["import type { PluginObject } from \"@babel/core\"\nimport { transformSync, types as t } from \"@babel/core\"\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: any } {\n\tconst plugin = (): PluginObject => {\n\t\tlet create: t.Identifier\n\t\tlet merge: t.Identifier\n\t\tconst generated = new WeakSet<object>()\n\t\tconst components = new Set<string>()\n\t\tfunction name(\n\t\t\tnode: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n\t\t): t.Expression {\n\t\t\tif (t.isJSXMemberExpression(node))\n\t\t\t\treturn t.memberExpression(\n\t\t\t\t\tt.isJSXIdentifier(node.object)\n\t\t\t\t\t\t? node.object.name === `this`\n\t\t\t\t\t\t\t? t.thisExpression()\n\t\t\t\t\t\t\t: t.identifier(node.object.name)\n\t\t\t\t\t\t: name(node.object),\n\t\t\t\t\tt.identifier(node.property.name),\n\t\t\t\t)\n\t\t\tif (t.isJSXNamespacedName(node))\n\t\t\t\treturn t.stringLiteral(`${node.namespace.name}:${node.name.name}`)\n\t\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t\t? t.stringLiteral(node.name)\n\t\t\t\t: t.identifier(node.name)\n\t\t}\n\t\tfunction literal(node: t.Node): boolean {\n\t\t\treturn (\n\t\t\t\tt.isLiteral(node) &&\n\t\t\t\t(!t.isTemplateLiteral(node) || node.expressions.length === 0)\n\t\t\t)\n\t\t}\n\t\tfunction child(node: t.Expression): t.Expression {\n\t\t\treturn generated.has(node) || literal(node) || t.isFunction(node)\n\t\t\t\t? node\n\t\t\t\t: t.arrowFunctionExpression([], node)\n\t\t}\n\t\treturn {\n\t\t\tvisitor: {\n\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isArrowFunctionExpression(path.node.declaration) ||\n\t\t\t\t\t\tt.isFunctionExpression(path.node.declaration)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\tpath.replaceWithMultiple([\n\t\t\t\t\t\t\tt.variableDeclaration(`const`, [\n\t\t\t\t\t\t\t\tt.variableDeclarator(id, path.node.declaration),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tt.exportDefaultDeclaration(id),\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tProgram: {\n\t\t\t\t\tenter(path) {\n\t\t\t\t\t\tcreate = path.scope.generateUidIdentifier(`spa`)\n\t\t\t\t\t\tmerge = path.scope.generateUidIdentifier(`props`)\n\t\t\t\t\t},\n\t\t\t\t\texit(path) {\n\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\tt.importDeclaration(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tt.importSpecifier(create, t.identifier(`jsx`)),\n\t\t\t\t\t\t\t\t\tt.importSpecifier(merge, t.identifier(`merge`)),\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tt.stringLiteral(`@atom.io/spa/jsx-runtime`),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tfor (const component of components)\n\t\t\t\t\t\t\tpath.pushContainer(\n\t\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\t\tt.expressionStatement(\n\t\t\t\t\t\t\t\t\tt.assignmentExpression(\n\t\t\t\t\t\t\t\t\t\t`=`,\n\t\t\t\t\t\t\t\t\t\tt.memberExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(component),\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(`spa`),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tt.booleanLiteral(true),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"JSXElement|JSXFragment\": {\n\t\t\t\t\texit(path: any) {\n\t\t\t\t\t\tconst node = path.node as t.JSXElement | t.JSXFragment\n\t\t\t\t\t\tconst chunks: t.Expression[] = []\n\t\t\t\t\t\tlet properties: (t.ObjectProperty | t.ObjectMethod)[] = []\n\t\t\t\t\t\tconst flush = () => {\n\t\t\t\t\t\t\tif (properties.length) {\n\t\t\t\t\t\t\t\tchunks.push(t.objectExpression(properties))\n\t\t\t\t\t\t\t\tproperties = []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (t.isJSXElement(node))\n\t\t\t\t\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\t\t\t\t\tif (t.isJSXSpreadAttribute(attribute)) {\n\t\t\t\t\t\t\t\t\tflush()\n\t\t\t\t\t\t\t\t\tchunks.push(t.arrowFunctionExpression([], attribute.argument))\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst key = t.isJSXNamespacedName(attribute.name)\n\t\t\t\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t\t\t\t: attribute.name.name\n\t\t\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\t\t\tattribute.value == null\n\t\t\t\t\t\t\t\t\t\t? t.booleanLiteral(true)\n\t\t\t\t\t\t\t\t\t\t: t.isJSXExpressionContainer(attribute.value)\n\t\t\t\t\t\t\t\t\t\t\t? attribute.value.expression\n\t\t\t\t\t\t\t\t\t\t\t: attribute.value\n\t\t\t\t\t\t\t\t// The parser rejects empty attribute expressions.\n\t\t\t\t\t\t\t\tconst expression = value as t.Expression\n\t\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\t\tkey === `key` ||\n\t\t\t\t\t\t\t\t\t\tliteral(expression) ||\n\t\t\t\t\t\t\t\t\t\tt.isFunction(expression)\n\t\t\t\t\t\t\t\t\t\t? t.objectProperty(t.stringLiteral(key), expression)\n\t\t\t\t\t\t\t\t\t\t: t.objectMethod(\n\t\t\t\t\t\t\t\t\t\t\t\t`get`,\n\t\t\t\t\t\t\t\t\t\t\t\tt.stringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t\t\tt.blockStatement([t.returnStatement(expression)]),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tconst children = t.react\n\t\t\t\t\t\t\t.buildChildren(node)\n\t\t\t\t\t\t\t.map((value) => child(value as t.Expression))\n\t\t\t\t\t\tif (children.length)\n\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\tt.objectProperty(\n\t\t\t\t\t\t\t\t\tt.identifier(`children`),\n\t\t\t\t\t\t\t\t\tchildren.length === 1\n\t\t\t\t\t\t\t\t\t\t? children[0]\n\t\t\t\t\t\t\t\t\t\t: t.arrayExpression(children),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\tflush()\n\t\t\t\t\t\tconst props =\n\t\t\t\t\t\t\tchunks.length > 1 || t.isArrowFunctionExpression(chunks[0])\n\t\t\t\t\t\t\t\t? t.callExpression(merge, chunks)\n\t\t\t\t\t\t\t\t: (chunks[0] ?? t.objectExpression([]))\n\t\t\t\t\t\tconst result = t.callExpression(create, [\n\t\t\t\t\t\t\tt.isJSXElement(node)\n\t\t\t\t\t\t\t\t? name(node.openingElement.name)\n\t\t\t\t\t\t\t\t: t.nullLiteral(),\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tgenerated.add(result)\n\t\t\t\t\t\tlet fn = path.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\twhile (fn?.findParent((parent: any) => parent.isFunction()))\n\t\t\t\t\t\t\tfn = fn.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\tif (fn) {\n\t\t\t\t\t\t\tif (fn.isFunctionDeclaration() && fn.node.id)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isVariableDeclarator() &&\n\t\t\t\t\t\t\t\tt.isIdentifier(fn.parentPath.node.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcomponents.add(fn.parentPath.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isExportDefaultDeclaration() &&\n\t\t\t\t\t\t\t\tt.isFunctionDeclaration(fn.node)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfn.node.id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpath.replaceWith(result)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\tconst result = transformSync(code, {\n\t\tfilename,\n\t\tbabelrc: false,\n\t\tconfigFile: false,\n\t\tsourceMaps: true,\n\t\tparserOpts: { plugins: [`jsx`, `typescript`] },\n\t\tplugins: [plugin],\n\t})!\n\treturn { code: result.code!, map: result.map }\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;AAGA,SAAgB,QACf,MACA,UAC6B;CAC7B,MAAM,eAA6B;EAClC,IAAI;EACJ,IAAI;EACJ,MAAM,4BAAY,IAAI,QAAgB;EACtC,MAAM,6BAAa,IAAI,IAAY;EACnC,SAAS,KACR,MACe;GAC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AAY;EACZ,YAAY,EAAE,SAAS,CAAC,OAAO,YAAY,EAAE;EAC7C,SAAS,CAAC,MAAM;CACjB,CAAC;CACD,OAAO;EAAE,MAAM,OAAO;EAAO,KAAK,OAAO;CAAI;AAC9C;;ACtLA,SAAwB,IAAI,UAA4B,CAAC,GAAW;CACnE,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,WAAW,OAAwB;EACxC,QAAQ,YAAY;EACpB,OAAO,CAAC,GAAG,SAAS,gBAAgB,KAAK,QAAQ,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE;CACvE;CACA,OAAO;EACN,MAAM;EACN,SAAS;EACT,SAAS;GACR,OAAO;IACN,SAAS,EAAE,QAAQ,CAAC,gBAAgB,SAAS,EAAE;IAC/C,cAAc,EAAE,SAAS,CAAC,gBAAgB,SAAS,EAAE;GACtD;EACD;EACA,mBAAmB;GAClB,OAAO;GACP,QAAQ,OAAO,QAAQ;IAItB,IAAI,OAAO,cAAc,SACxB,OAAO,aAAa,UAAU,OAAO,aAAa,QAAQ,QACxD,OAAO,CAAC,mCAAmC,KAAK,EAAE,CACpD;GAEF;EACD;EACA,UAAU,MAAM,IAAI;GACnB,IAAI,CAAC,QAAQ,EAAE,GAAG;GAClB,OAAO,QAAQ,MAAM,EAAE;EACxB;EAEA,gBAAgB,EAAE,QAAQ,QAAQ;GACjC,IAAI,QAAQ,IAAI,GAAG;IAClB,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IACtC,OAAO,CAAC;GACT;EACD;CACD;AACD"}
|
package/dist/development/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./vite-
|
|
1
|
+
export { t as default } from "./vite-CQchIQ_-.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as useTimeline, c as onMount, d as resolveStateToken, g as useStore, h as useSetter, l as owner, m as useRef, p as useId, s as onCleanup, v as useTransaction, y as useValue } from "./core-Dvqm7w2y.js";
|
|
2
|
-
import { Fragment } from "./jsx-runtime.js";
|
|
3
2
|
import { n as render, t as hydrate } from "./dom-BR9o9wZW.js";
|
|
3
|
+
import { Fragment } from "./jsx-runtime.js";
|
|
4
4
|
import { withdraw } from "atom.io/internal";
|
|
5
5
|
// src/use-loadable.ts
|
|
6
6
|
function useLoadable(...params) {
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":";wBA+IgB,eACf,aAAa,OACb,UAAS"}
|
package/dist/server.js
CHANGED
|
@@ -9,7 +9,7 @@ const escape = (value) => String(value).replace(/[&<>"']/g, (char) => ({
|
|
|
9
9
|
"'": `'`
|
|
10
10
|
})[char]);
|
|
11
11
|
const voidTags = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
|
|
12
|
-
const booleans = new Set(`allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate
|
|
12
|
+
const booleans = new Set(`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(` `));
|
|
13
13
|
function stringify(value, owner, namespace = `html`, selectValue) {
|
|
14
14
|
if (typeof value === `function`) {
|
|
15
15
|
const values = [untrack(value)].flat(Infinity);
|
|
@@ -41,17 +41,26 @@ function stringify(value, owner, namespace = `html`, selectValue) {
|
|
|
41
41
|
if (key === `children` || key === `ref` || key === `key` || key.startsWith(`on`)) continue;
|
|
42
42
|
if (/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(key)) throw new Error(`spa: owned content`);
|
|
43
43
|
let attribute = props[key];
|
|
44
|
+
if (ns === `html`) {
|
|
45
|
+
if (key === `defaultValue` && (type === `input` || type === `textarea`)) {
|
|
46
|
+
if (props[`value`] != null) continue;
|
|
47
|
+
key = `value`;
|
|
48
|
+
} else if (key === `defaultChecked` && type === `input`) {
|
|
49
|
+
if (props[`checked`] != null) continue;
|
|
50
|
+
key = `checked`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
if (key === `className`) key = `class`;
|
|
45
54
|
if (key === `htmlFor`) key = `for`;
|
|
46
55
|
if (!/^[^\s"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`);
|
|
47
56
|
if (key === `value` && (type === `select` || type === `textarea`)) {
|
|
48
|
-
textValue = attribute;
|
|
57
|
+
textValue = attribute ?? textValue;
|
|
49
58
|
continue;
|
|
50
59
|
}
|
|
51
60
|
if (key === `style` && attribute != null && typeof attribute !== `string`) throw new TypeError(`spa: CSS string required`);
|
|
52
|
-
const boolean = ns === `html` && booleans.has(key.toLowerCase());
|
|
53
|
-
if (attribute == null || boolean && !attribute
|
|
54
|
-
attrs += boolean
|
|
61
|
+
const boolean = ns === `html` && (booleans.has(key.toLowerCase()) || /^(capture|download|hidden)$/.test(key) && typeof attribute === `boolean`);
|
|
62
|
+
if (attribute == null || boolean && !attribute) continue;
|
|
63
|
+
attrs += boolean ? ` ${key}=""` : ` ${key}="${escape(attribute)}"`;
|
|
55
64
|
}
|
|
56
65
|
if (type === `option` && selectValue !== void 0 && String(props[`value`]) === String(selectValue)) attrs += ` selected=""`;
|
|
57
66
|
if (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`;
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import type { Child, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&`, \"<\": `<`, \">\": `>`, '\"': `"`, \"'\": `'` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import type { Child, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&`, \"<\": `<`, \">\": `>`, '\"': `"`, \"'\": `'` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(\n\t\t` `,\n\t),\n)\nfunction stringify(\n\tvalue: Child,\n\towner: Scope,\n\tnamespace = `html`,\n\tselectValue?: string | number,\n): string {\n\tif (typeof value === `function`) {\n\t\tconst values = ([untrack(value)] as unknown[]).flat(Infinity) as Child[]\n\t\tconst keys = new Set<unknown>()\n\t\treturn (\n\t\t\t`<!--{-->` +\n\t\t\tvalues\n\t\t\t\t.map((child, index) => {\n\t\t\t\t\tconst explicit = (child as VNode | null)?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (keys.has(key)) throw new Error(`spa: duplicate key`)\n\t\t\t\t\tkeys.add(key)\n\t\t\t\t\treturn `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`\n\t\t\t\t})\n\t\t\t\t.join(``) +\n\t\t\t`<!--}-->`\n\t\t)\n\t}\n\tif (Array.isArray(value))\n\t\treturn value\n\t\t\t.map((child) => stringify(child, owner, namespace, selectValue))\n\t\t\t.join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (typeof value !== `object`) return `<!--t-->${escape(value)}`\n\tif (!(`type` in value) || !(`props` in value))\n\t\tthrow new TypeError(`spa: invalid child`)\n\tconst { type, props } = value\n\tif (!type || type === Fragment)\n\t\treturn stringify(() => props[`children`], owner, namespace, selectValue)\n\tif (typeof type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\treturn within(childOwner, () =>\n\t\t\tstringify(\n\t\t\t\tuntrack(() => type(props)),\n\t\t\t\tchildOwner,\n\t\t\t\tnamespace,\n\t\t\t\tselectValue,\n\t\t\t),\n\t\t)\n\t}\n\tif (!/^[A-Za-z][\\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`)\n\tif (type === `astro-slot`)\n\t\treturn `<astro-slot${props[`name`] ? ` name=\"${escape(props[`name`])}\"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`\n\tconst ns = type === `svg` ? `svg` : namespace\n\tlet attrs = ``\n\tlet textValue: string | number | undefined\n\tfor (let key of Object.keys(props)) {\n\t\tif (\n\t\t\tkey === `children` ||\n\t\t\tkey === `ref` ||\n\t\t\tkey === `key` ||\n\t\t\tkey.startsWith(`on`)\n\t\t)\n\t\t\tcontinue\n\t\tif (\n\t\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`spa: owned content`)\n\t\tlet attribute = props[key]\n\t\tif (ns === `html`) {\n\t\t\tif (key === `defaultValue` && (type === `input` || type === `textarea`)) {\n\t\t\t\tif (props[`value`] != null) continue\n\t\t\t\tkey = `value`\n\t\t\t} else if (key === `defaultChecked` && type === `input`) {\n\t\t\t\tif (props[`checked`] != null) continue\n\t\t\t\tkey = `checked`\n\t\t\t}\n\t\t}\n\t\tif (key === `className`) key = `class`\n\t\tif (key === `htmlFor`) key = `for`\n\t\tif (!/^[^\\s\"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)\n\t\tif (key === `value` && (type === `select` || type === `textarea`)) {\n\t\t\ttextValue = attribute ?? textValue\n\t\t\tcontinue\n\t\t}\n\t\tif (key === `style` && attribute != null && typeof attribute !== `string`)\n\t\t\tthrow new TypeError(`spa: CSS string required`)\n\t\tconst boolean =\n\t\t\tns === `html` &&\n\t\t\t(booleans.has(key.toLowerCase()) ||\n\t\t\t\t(/^(capture|download|hidden)$/.test(key) &&\n\t\t\t\t\ttypeof attribute === `boolean`))\n\t\tif (attribute == null || (boolean && !attribute)) continue\n\t\tattrs += boolean ? ` ${key}=\"\"` : ` ${key}=\"${escape(attribute)}\"`\n\t}\n\tif (\n\t\ttype === `option` &&\n\t\tselectValue !== undefined &&\n\t\tString(props[`value`]) === String(selectValue)\n\t)\n\t\tattrs += ` selected=\"\"`\n\tif (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`\n\tif (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {\n\t\tlet text = plain(\n\t\t\ttype === `textarea` ? (textValue ?? props[`children`]) : props[`children`],\n\t\t)\n\t\tif (type === `textarea` && text.startsWith(`\\n`)) text = `\\n${text}`\n\t\tif (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text))\n\t\t\tthrow new Error(`spa: unsafe raw text`)\n\t\treturn `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`\n\t}\n\tconst children = stringify(\n\t\t() => props[`children`],\n\t\towner,\n\t\ttype === `foreignObject` ? `html` : ns,\n\t\ttype === `select` ? textValue : selectValue,\n\t)\n\treturn `<${type}${attrs}>${children}</${type}>`\n}\n\nexport function renderToString(\n\tsetup: () => Child,\n\toptions: RootOptions = {},\n): string {\n\tconst root = createRoot(options, true)\n\tif (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`)\n\ttry {\n\t\treturn `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`\n\t} finally {\n\t\tdispose(root)\n\t}\n}\n"],"mappings":";;;AAWA,MAAM,UAAU,UACf,OAAO,KAAK,CAAC,CAAC,QACb,aACC,UACC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,EAAA,CACtE,KAEH;AACD,MAAM,WACL;AACD,MAAM,WAAW,IAAI,IACpB,qVAAqV,MACpV,GACD,CACD;AACA,SAAS,UACR,OACA,OACA,YAAY,QACZ,aACS;CACT,IAAI,OAAO,UAAU,YAAY;EAChC,MAAM,SAAU,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAe,KAAK,QAAQ;EAC5D,MAAM,uBAAO,IAAI,IAAa;EAC9B,OACC,aACA,OACE,KAAK,OAAO,UAAU;GACtB,MAAM,WAAY,OAAwB,QAAQ;GAClD,MAAM,MAAM,YAAY,OAAO,QAAQ,OAAO,QAAQ;GACtD,IAAI,KAAK,IAAI,GAAG,GAAG,MAAM,IAAI,MAAM,oBAAoB;GACvD,KAAK,IAAI,GAAG;GACZ,OAAO,WAAW,OAAO,aAAa,UAAU,OAAO,YAAY,KAAK,GAAG,WAAW,WAAW,CAAC,EAAE;EACrG,CAAC,CAAC,CACD,KAAK,EAAE,IACT;CAEF;CACA,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MACL,KAAK,UAAU,UAAU,OAAO,OAAO,WAAW,WAAW,CAAC,CAAC,CAC/D,KAAK,EAAE;CACV,IAAI,SAAS,QAAQ,OAAO,UAAU,WAAW,OAAO;CACxD,IAAI,OAAO,UAAU,UAAU,OAAO,WAAW,OAAO,KAAK;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QAAQ,KAAK,GAAG,IAAI,CAAC,EAAE;CACvF,UAAU;EACT,QAAQ,IAAI;CACb;AACD"}
|
package/dist/size.json
CHANGED
|
@@ -57,13 +57,13 @@ function compile(code, filename) {
|
|
|
57
57
|
const children = types.react.buildChildren(node).map((value) => child(value));
|
|
58
58
|
if (children.length) properties.push(types.objectProperty(types.identifier(`children`), children.length === 1 ? children[0] : types.arrayExpression(children)));
|
|
59
59
|
flush();
|
|
60
|
-
const props = chunks.length > 1 ? types.callExpression(merge, chunks) : chunks[0] ?? types.objectExpression([]);
|
|
60
|
+
const props = chunks.length > 1 || types.isArrowFunctionExpression(chunks[0]) ? types.callExpression(merge, chunks) : chunks[0] ?? types.objectExpression([]);
|
|
61
61
|
const result = types.callExpression(create, [types.isJSXElement(node) ? name(node.openingElement.name) : types.nullLiteral(), props]);
|
|
62
62
|
generated.add(result);
|
|
63
63
|
let fn = path.findParent((parent) => parent.isFunction());
|
|
64
64
|
while (fn?.findParent((parent) => parent.isFunction())) fn = fn.findParent((parent) => parent.isFunction());
|
|
65
65
|
if (fn) {
|
|
66
|
-
if (fn.node.id) components.add(fn.node.id.name);
|
|
66
|
+
if (fn.isFunctionDeclaration() && fn.node.id) components.add(fn.node.id.name);
|
|
67
67
|
else if (fn.parentPath.isVariableDeclarator() && types.isIdentifier(fn.parentPath.node.id)) components.add(fn.parentPath.node.id.name);
|
|
68
68
|
else if (fn.parentPath.isExportDefaultDeclaration() && types.isFunctionDeclaration(fn.node)) {
|
|
69
69
|
fn.node.id = path.scope.generateUidIdentifier(`Component`);
|
|
@@ -123,4 +123,4 @@ function spa(options = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
export { spa as t };
|
|
125
125
|
|
|
126
|
-
//# sourceMappingURL=vite-
|
|
126
|
+
//# sourceMappingURL=vite-CQchIQ_-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-CQchIQ_-.js","names":["t"],"sources":["../src/compiler.ts","../src/vite.ts"],"sourcesContent":["import type { PluginObject } from \"@babel/core\"\nimport { transformSync, types as t } from \"@babel/core\"\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: any } {\n\tconst plugin = (): PluginObject => {\n\t\tlet create: t.Identifier\n\t\tlet merge: t.Identifier\n\t\tconst generated = new WeakSet<object>()\n\t\tconst components = new Set<string>()\n\t\tfunction name(\n\t\t\tnode: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n\t\t): t.Expression {\n\t\t\tif (t.isJSXMemberExpression(node))\n\t\t\t\treturn t.memberExpression(\n\t\t\t\t\tt.isJSXIdentifier(node.object)\n\t\t\t\t\t\t? node.object.name === `this`\n\t\t\t\t\t\t\t? t.thisExpression()\n\t\t\t\t\t\t\t: t.identifier(node.object.name)\n\t\t\t\t\t\t: name(node.object),\n\t\t\t\t\tt.identifier(node.property.name),\n\t\t\t\t)\n\t\t\tif (t.isJSXNamespacedName(node))\n\t\t\t\treturn t.stringLiteral(`${node.namespace.name}:${node.name.name}`)\n\t\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t\t? t.stringLiteral(node.name)\n\t\t\t\t: t.identifier(node.name)\n\t\t}\n\t\tfunction literal(node: t.Node): boolean {\n\t\t\treturn (\n\t\t\t\tt.isLiteral(node) &&\n\t\t\t\t(!t.isTemplateLiteral(node) || node.expressions.length === 0)\n\t\t\t)\n\t\t}\n\t\tfunction child(node: t.Expression): t.Expression {\n\t\t\treturn generated.has(node) || literal(node) || t.isFunction(node)\n\t\t\t\t? node\n\t\t\t\t: t.arrowFunctionExpression([], node)\n\t\t}\n\t\treturn {\n\t\t\tvisitor: {\n\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isArrowFunctionExpression(path.node.declaration) ||\n\t\t\t\t\t\tt.isFunctionExpression(path.node.declaration)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\tpath.replaceWithMultiple([\n\t\t\t\t\t\t\tt.variableDeclaration(`const`, [\n\t\t\t\t\t\t\t\tt.variableDeclarator(id, path.node.declaration),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tt.exportDefaultDeclaration(id),\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tProgram: {\n\t\t\t\t\tenter(path) {\n\t\t\t\t\t\tcreate = path.scope.generateUidIdentifier(`spa`)\n\t\t\t\t\t\tmerge = path.scope.generateUidIdentifier(`props`)\n\t\t\t\t\t},\n\t\t\t\t\texit(path) {\n\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\tt.importDeclaration(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tt.importSpecifier(create, t.identifier(`jsx`)),\n\t\t\t\t\t\t\t\t\tt.importSpecifier(merge, t.identifier(`merge`)),\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tt.stringLiteral(`@atom.io/spa/jsx-runtime`),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tfor (const component of components)\n\t\t\t\t\t\t\tpath.pushContainer(\n\t\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\t\tt.expressionStatement(\n\t\t\t\t\t\t\t\t\tt.assignmentExpression(\n\t\t\t\t\t\t\t\t\t\t`=`,\n\t\t\t\t\t\t\t\t\t\tt.memberExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(component),\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(`spa`),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tt.booleanLiteral(true),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"JSXElement|JSXFragment\": {\n\t\t\t\t\texit(path: any) {\n\t\t\t\t\t\tconst node = path.node as t.JSXElement | t.JSXFragment\n\t\t\t\t\t\tconst chunks: t.Expression[] = []\n\t\t\t\t\t\tlet properties: (t.ObjectProperty | t.ObjectMethod)[] = []\n\t\t\t\t\t\tconst flush = () => {\n\t\t\t\t\t\t\tif (properties.length) {\n\t\t\t\t\t\t\t\tchunks.push(t.objectExpression(properties))\n\t\t\t\t\t\t\t\tproperties = []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (t.isJSXElement(node))\n\t\t\t\t\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\t\t\t\t\tif (t.isJSXSpreadAttribute(attribute)) {\n\t\t\t\t\t\t\t\t\tflush()\n\t\t\t\t\t\t\t\t\tchunks.push(t.arrowFunctionExpression([], attribute.argument))\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst key = t.isJSXNamespacedName(attribute.name)\n\t\t\t\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t\t\t\t: attribute.name.name\n\t\t\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\t\t\tattribute.value == null\n\t\t\t\t\t\t\t\t\t\t? t.booleanLiteral(true)\n\t\t\t\t\t\t\t\t\t\t: t.isJSXExpressionContainer(attribute.value)\n\t\t\t\t\t\t\t\t\t\t\t? attribute.value.expression\n\t\t\t\t\t\t\t\t\t\t\t: attribute.value\n\t\t\t\t\t\t\t\t// The parser rejects empty attribute expressions.\n\t\t\t\t\t\t\t\tconst expression = value as t.Expression\n\t\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\t\tkey === `key` ||\n\t\t\t\t\t\t\t\t\t\tliteral(expression) ||\n\t\t\t\t\t\t\t\t\t\tt.isFunction(expression)\n\t\t\t\t\t\t\t\t\t\t? t.objectProperty(t.stringLiteral(key), expression)\n\t\t\t\t\t\t\t\t\t\t: t.objectMethod(\n\t\t\t\t\t\t\t\t\t\t\t\t`get`,\n\t\t\t\t\t\t\t\t\t\t\t\tt.stringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t\t\tt.blockStatement([t.returnStatement(expression)]),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tconst children = t.react\n\t\t\t\t\t\t\t.buildChildren(node)\n\t\t\t\t\t\t\t.map((value) => child(value as t.Expression))\n\t\t\t\t\t\tif (children.length)\n\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\tt.objectProperty(\n\t\t\t\t\t\t\t\t\tt.identifier(`children`),\n\t\t\t\t\t\t\t\t\tchildren.length === 1\n\t\t\t\t\t\t\t\t\t\t? children[0]\n\t\t\t\t\t\t\t\t\t\t: t.arrayExpression(children),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\tflush()\n\t\t\t\t\t\tconst props =\n\t\t\t\t\t\t\tchunks.length > 1 || t.isArrowFunctionExpression(chunks[0])\n\t\t\t\t\t\t\t\t? t.callExpression(merge, chunks)\n\t\t\t\t\t\t\t\t: (chunks[0] ?? t.objectExpression([]))\n\t\t\t\t\t\tconst result = t.callExpression(create, [\n\t\t\t\t\t\t\tt.isJSXElement(node)\n\t\t\t\t\t\t\t\t? name(node.openingElement.name)\n\t\t\t\t\t\t\t\t: t.nullLiteral(),\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tgenerated.add(result)\n\t\t\t\t\t\tlet fn = path.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\twhile (fn?.findParent((parent: any) => parent.isFunction()))\n\t\t\t\t\t\t\tfn = fn.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\tif (fn) {\n\t\t\t\t\t\t\tif (fn.isFunctionDeclaration() && fn.node.id)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isVariableDeclarator() &&\n\t\t\t\t\t\t\t\tt.isIdentifier(fn.parentPath.node.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcomponents.add(fn.parentPath.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isExportDefaultDeclaration() &&\n\t\t\t\t\t\t\t\tt.isFunctionDeclaration(fn.node)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfn.node.id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpath.replaceWith(result)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\tconst result = transformSync(code, {\n\t\tfilename,\n\t\tbabelrc: false,\n\t\tconfigFile: false,\n\t\tsourceMaps: true,\n\t\tparserOpts: { plugins: [`jsx`, `typescript`] },\n\t\tplugins: [plugin],\n\t})!\n\treturn { code: result.code!, map: result.map }\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;AAGA,SAAgB,QACf,MACA,UAC6B;CAC7B,MAAM,eAA6B;EAClC,IAAI;EACJ,IAAI;EACJ,MAAM,4BAAY,IAAI,QAAgB;EACtC,MAAM,6BAAa,IAAI,IAAY;EACnC,SAAS,KACR,MACe;GACf,IAAIA,MAAE,sBAAsB,IAAI,GAC/B,OAAOA,MAAE,iBACRA,MAAE,gBAAgB,KAAK,MAAM,IAC1B,KAAK,OAAO,SAAS,SACpBA,MAAE,eAAe,IACjBA,MAAE,WAAW,KAAK,OAAO,IAAI,IAC9B,KAAK,KAAK,MAAM,GACnBA,MAAE,WAAW,KAAK,SAAS,IAAI,CAChC;GACD,IAAIA,MAAE,oBAAoB,IAAI,GAC7B,OAAOA,MAAE,cAAc,GAAG,KAAK,UAAU,KAAK,GAAG,KAAK,KAAK,MAAM;GAClE,OAAO,SAAS,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,GAAG,IACtDA,MAAE,cAAc,KAAK,IAAI,IACzBA,MAAE,WAAW,KAAK,IAAI;EAC1B;EACA,SAAS,QAAQ,MAAuB;GACvC,OACCA,MAAE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AE;GACtD;EACD;EACA,mBAAmB;GAClB,OAAO;GACP,QAAQ,OAAO,QAAQ;IAItB,IAAI,OAAO,cAAc,SACxB,OAAO,aAAa,UAAU,OAAO,aAAa,QAAQ,QACxD,OAAO,CAAC,mCAAmC,KAAK,EAAE,CACpD;GAEF;EACD;EACA,UAAU,MAAM,IAAI;GACnB,IAAI,CAAC,QAAQ,EAAE,GAAG;GAClB,OAAO,QAAQ,MAAM,EAAE;EACxB;EAEA,gBAAgB,EAAE,QAAQ,QAAQ;GACjC,IAAI,QAAQ,IAAI,GAAG;IAClB,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IACtC,OAAO,CAAC;GACT;EACD;CACD;AACD"}
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./vite-
|
|
1
|
+
export { t as default } from "./vite-CQchIQ_-.js";
|
package/package.json
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
2
|
+
"name": "@atom.io/spa",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An atom.io-driven JSX renderer.",
|
|
5
|
+
"homepage": "https://atom.io.fyi/docs/spa",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/jeremybanka/atom.io.git",
|
|
9
|
+
"directory": "packages/spa"
|
|
10
|
+
},
|
|
11
|
+
"license": "MPL-2.0",
|
|
12
|
+
"author": "Jeremy Banka",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"development": "./dist/development/index.js",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./jsx-runtime": {
|
|
22
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
23
|
+
"development": "./dist/development/jsx-runtime.js",
|
|
24
|
+
"import": "./dist/jsx-runtime.js"
|
|
25
|
+
},
|
|
26
|
+
"./jsx-dev-runtime": {
|
|
27
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
28
|
+
"development": "./dist/development/jsx-runtime.js",
|
|
29
|
+
"import": "./dist/jsx-runtime.js"
|
|
30
|
+
},
|
|
31
|
+
"./server": {
|
|
32
|
+
"types": "./dist/server.d.ts",
|
|
33
|
+
"development": "./dist/development/server.js",
|
|
34
|
+
"import": "./dist/server.js"
|
|
35
|
+
},
|
|
36
|
+
"./vite": {
|
|
37
|
+
"types": "./dist/vite.d.ts",
|
|
38
|
+
"development": "./dist/development/vite.js",
|
|
39
|
+
"import": "./dist/vite.js"
|
|
40
|
+
},
|
|
41
|
+
"./astro": {
|
|
42
|
+
"types": "./dist/astro.d.ts",
|
|
43
|
+
"development": "./dist/development/astro.js",
|
|
44
|
+
"import": "./dist/astro.js"
|
|
45
|
+
},
|
|
46
|
+
"./astro-client": {
|
|
47
|
+
"types": "./dist/astro-client.d.ts",
|
|
48
|
+
"development": "./dist/development/astro-client.js",
|
|
49
|
+
"import": "./dist/astro-client.js"
|
|
50
|
+
},
|
|
51
|
+
"./astro-server": {
|
|
52
|
+
"types": "./dist/astro-server.d.ts",
|
|
53
|
+
"development": "./dist/development/astro-server.js",
|
|
54
|
+
"import": "./dist/astro-server.js"
|
|
55
|
+
},
|
|
56
|
+
"./package.json": "./package.json",
|
|
57
|
+
"./astro-middleware": {
|
|
58
|
+
"types": "./dist/astro-middleware.d.ts",
|
|
59
|
+
"development": "./dist/development/astro-middleware.js",
|
|
60
|
+
"import": "./dist/astro-middleware.js"
|
|
61
|
+
},
|
|
62
|
+
"./astro-application": {
|
|
63
|
+
"types": "./dist/astro-application.d.ts",
|
|
64
|
+
"development": "./dist/development/astro-application.js",
|
|
65
|
+
"import": "./dist/astro-application.js"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"main": "./dist/index.js",
|
|
69
|
+
"types": "./dist/index.d.ts",
|
|
70
|
+
"files": [
|
|
71
|
+
"dist",
|
|
72
|
+
"src"
|
|
73
|
+
],
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@babel/core": "8.0.10"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@breakage/changesets": "0.1.0",
|
|
79
|
+
"@types/babel__core": "7.20.5",
|
|
80
|
+
"@types/node": "26.6.6",
|
|
81
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
82
|
+
"astro": "7.4.4",
|
|
83
|
+
"atom.io": "0.54.3",
|
|
84
|
+
"breakage": "0.10.1",
|
|
85
|
+
"esbuild": "0.28.2",
|
|
86
|
+
"eslint": "10.13.0",
|
|
87
|
+
"happy-dom": "21.0.4",
|
|
88
|
+
"playwright": "1.64.1",
|
|
89
|
+
"preact": "11.1.0",
|
|
90
|
+
"rolldown": "1.2.16",
|
|
91
|
+
"tsdown": "0.23.4",
|
|
92
|
+
"typescript": "7.0.2",
|
|
93
|
+
"vite": "8.3.5",
|
|
94
|
+
"vitest": "5.0.5"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"astro": "^7.4.2",
|
|
98
|
+
"atom.io": "^0.54.1",
|
|
99
|
+
"vite": "^8.3.5"
|
|
100
|
+
},
|
|
101
|
+
"peerDependenciesMeta": {
|
|
102
|
+
"astro": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"vite": {
|
|
106
|
+
"optional": true
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"publishConfig": {
|
|
110
|
+
"access": "public"
|
|
111
|
+
},
|
|
112
|
+
"scripts": {
|
|
113
|
+
"build": "tsdown && node scripts/size.ts",
|
|
114
|
+
"lint:eslint": "eslint",
|
|
115
|
+
"lint:oxlint": "oxlint",
|
|
116
|
+
"lint:types": "tsc -p tsconfig.json && tsc -p __tests__/fixtures/consumer/tsconfig.json",
|
|
117
|
+
"size": "node scripts/size.ts",
|
|
118
|
+
"pack:breakage": "pnpm --reporter=silent pack --out .breakage/package.tgz",
|
|
119
|
+
"test:breakage:peers": "breakage npm check",
|
|
120
|
+
"test": "vitest",
|
|
121
|
+
"test:once": "vitest run --config vitest.config.ts && pnpm test:consumer",
|
|
122
|
+
"test:consumer": "node __tests__/fixtures/consumer/check.ts",
|
|
123
|
+
"test:production": "node scripts/production-test.ts",
|
|
124
|
+
"test:browser": "astro build --root __tests__/astro && node scripts/browser-test.mjs && node scripts/dev-browser-test.mjs",
|
|
125
|
+
"test:browser:dev": "node scripts/dev-browser-test.mjs",
|
|
126
|
+
"cov": "vitest run --config vitest.config.ts --coverage",
|
|
127
|
+
"readme:write": "galley write README.mdx",
|
|
128
|
+
"readme:check": "galley check README.mdx",
|
|
129
|
+
"tonnage": "pnpm readme:write",
|
|
130
|
+
"tonnage:check": "pnpm readme:check"
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/compiler.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginObject } from "@babel/core"
|
|
2
2
|
import { transformSync, types as t } from "@babel/core"
|
|
3
3
|
|
|
4
4
|
export function compile(
|
|
5
5
|
code: string,
|
|
6
6
|
filename: string,
|
|
7
7
|
): { code: string; map: any } {
|
|
8
|
-
const plugin = ():
|
|
8
|
+
const plugin = (): PluginObject => {
|
|
9
9
|
let create: t.Identifier
|
|
10
10
|
let merge: t.Identifier
|
|
11
11
|
const generated = new WeakSet<object>()
|
|
@@ -143,7 +143,7 @@ export function compile(
|
|
|
143
143
|
)
|
|
144
144
|
flush()
|
|
145
145
|
const props =
|
|
146
|
-
chunks.length > 1
|
|
146
|
+
chunks.length > 1 || t.isArrowFunctionExpression(chunks[0])
|
|
147
147
|
? t.callExpression(merge, chunks)
|
|
148
148
|
: (chunks[0] ?? t.objectExpression([]))
|
|
149
149
|
const result = t.callExpression(create, [
|
|
@@ -157,7 +157,8 @@ export function compile(
|
|
|
157
157
|
while (fn?.findParent((parent: any) => parent.isFunction()))
|
|
158
158
|
fn = fn.findParent((parent: any) => parent.isFunction())
|
|
159
159
|
if (fn) {
|
|
160
|
-
if (fn.
|
|
160
|
+
if (fn.isFunctionDeclaration() && fn.node.id)
|
|
161
|
+
components.add(fn.node.id.name)
|
|
161
162
|
else if (
|
|
162
163
|
fn.parentPath.isVariableDeclarator() &&
|
|
163
164
|
t.isIdentifier(fn.parentPath.node.id)
|
package/src/server.ts
CHANGED
|
@@ -20,7 +20,7 @@ const escape = (value: unknown): string =>
|
|
|
20
20
|
const voidTags =
|
|
21
21
|
/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/
|
|
22
22
|
const booleans = new Set(
|
|
23
|
-
`allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate
|
|
23
|
+
`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(
|
|
24
24
|
` `,
|
|
25
25
|
),
|
|
26
26
|
)
|
|
@@ -90,26 +90,31 @@ function stringify(
|
|
|
90
90
|
)
|
|
91
91
|
throw new Error(`spa: owned content`)
|
|
92
92
|
let attribute = props[key]
|
|
93
|
+
if (ns === `html`) {
|
|
94
|
+
if (key === `defaultValue` && (type === `input` || type === `textarea`)) {
|
|
95
|
+
if (props[`value`] != null) continue
|
|
96
|
+
key = `value`
|
|
97
|
+
} else if (key === `defaultChecked` && type === `input`) {
|
|
98
|
+
if (props[`checked`] != null) continue
|
|
99
|
+
key = `checked`
|
|
100
|
+
}
|
|
101
|
+
}
|
|
93
102
|
if (key === `className`) key = `class`
|
|
94
103
|
if (key === `htmlFor`) key = `for`
|
|
95
104
|
if (!/^[^\s"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)
|
|
96
105
|
if (key === `value` && (type === `select` || type === `textarea`)) {
|
|
97
|
-
textValue = attribute
|
|
106
|
+
textValue = attribute ?? textValue
|
|
98
107
|
continue
|
|
99
108
|
}
|
|
100
109
|
if (key === `style` && attribute != null && typeof attribute !== `string`)
|
|
101
110
|
throw new TypeError(`spa: CSS string required`)
|
|
102
|
-
const boolean =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
attrs +=
|
|
110
|
-
boolean || (attribute === true && !/^(aria-|data-)/.test(key))
|
|
111
|
-
? ` ${key}=""`
|
|
112
|
-
: ` ${key}="${escape(attribute)}"`
|
|
111
|
+
const boolean =
|
|
112
|
+
ns === `html` &&
|
|
113
|
+
(booleans.has(key.toLowerCase()) ||
|
|
114
|
+
(/^(capture|download|hidden)$/.test(key) &&
|
|
115
|
+
typeof attribute === `boolean`))
|
|
116
|
+
if (attribute == null || (boolean && !attribute)) continue
|
|
117
|
+
attrs += boolean ? ` ${key}=""` : ` ${key}="${escape(attribute)}"`
|
|
113
118
|
}
|
|
114
119
|
if (
|
|
115
120
|
type === `option` &&
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-BadrFSIM.js","names":["t"],"sources":["../../src/compiler.ts","../../src/vite.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\"\nimport { transformSync, types as t } from \"@babel/core\"\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: any } {\n\tconst plugin = (): PluginObj => {\n\t\tlet create: t.Identifier\n\t\tlet merge: t.Identifier\n\t\tconst generated = new WeakSet<object>()\n\t\tconst components = new Set<string>()\n\t\tfunction name(\n\t\t\tnode: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n\t\t): t.Expression {\n\t\t\tif (t.isJSXMemberExpression(node))\n\t\t\t\treturn t.memberExpression(\n\t\t\t\t\tt.isJSXIdentifier(node.object)\n\t\t\t\t\t\t? node.object.name === `this`\n\t\t\t\t\t\t\t? t.thisExpression()\n\t\t\t\t\t\t\t: t.identifier(node.object.name)\n\t\t\t\t\t\t: name(node.object),\n\t\t\t\t\tt.identifier(node.property.name),\n\t\t\t\t)\n\t\t\tif (t.isJSXNamespacedName(node))\n\t\t\t\treturn t.stringLiteral(`${node.namespace.name}:${node.name.name}`)\n\t\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t\t? t.stringLiteral(node.name)\n\t\t\t\t: t.identifier(node.name)\n\t\t}\n\t\tfunction literal(node: t.Node): boolean {\n\t\t\treturn (\n\t\t\t\tt.isLiteral(node) &&\n\t\t\t\t(!t.isTemplateLiteral(node) || node.expressions.length === 0)\n\t\t\t)\n\t\t}\n\t\tfunction child(node: t.Expression): t.Expression {\n\t\t\treturn generated.has(node) || literal(node) || t.isFunction(node)\n\t\t\t\t? node\n\t\t\t\t: t.arrowFunctionExpression([], node)\n\t\t}\n\t\treturn {\n\t\t\tvisitor: {\n\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isArrowFunctionExpression(path.node.declaration) ||\n\t\t\t\t\t\tt.isFunctionExpression(path.node.declaration)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\tpath.replaceWithMultiple([\n\t\t\t\t\t\t\tt.variableDeclaration(`const`, [\n\t\t\t\t\t\t\t\tt.variableDeclarator(id, path.node.declaration),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tt.exportDefaultDeclaration(id),\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tProgram: {\n\t\t\t\t\tenter(path) {\n\t\t\t\t\t\tcreate = path.scope.generateUidIdentifier(`spa`)\n\t\t\t\t\t\tmerge = path.scope.generateUidIdentifier(`props`)\n\t\t\t\t\t},\n\t\t\t\t\texit(path) {\n\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\tt.importDeclaration(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tt.importSpecifier(create, t.identifier(`jsx`)),\n\t\t\t\t\t\t\t\t\tt.importSpecifier(merge, t.identifier(`merge`)),\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tt.stringLiteral(`@atom.io/spa/jsx-runtime`),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tfor (const component of components)\n\t\t\t\t\t\t\tpath.pushContainer(\n\t\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\t\tt.expressionStatement(\n\t\t\t\t\t\t\t\t\tt.assignmentExpression(\n\t\t\t\t\t\t\t\t\t\t`=`,\n\t\t\t\t\t\t\t\t\t\tt.memberExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(component),\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(`spa`),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tt.booleanLiteral(true),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"JSXElement|JSXFragment\": {\n\t\t\t\t\texit(path: any) {\n\t\t\t\t\t\tconst node = path.node as t.JSXElement | t.JSXFragment\n\t\t\t\t\t\tconst chunks: t.Expression[] = []\n\t\t\t\t\t\tlet properties: (t.ObjectProperty | t.ObjectMethod)[] = []\n\t\t\t\t\t\tconst flush = () => {\n\t\t\t\t\t\t\tif (properties.length) {\n\t\t\t\t\t\t\t\tchunks.push(t.objectExpression(properties))\n\t\t\t\t\t\t\t\tproperties = []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (t.isJSXElement(node))\n\t\t\t\t\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\t\t\t\t\tif (t.isJSXSpreadAttribute(attribute)) {\n\t\t\t\t\t\t\t\t\tflush()\n\t\t\t\t\t\t\t\t\tchunks.push(t.arrowFunctionExpression([], attribute.argument))\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst key = t.isJSXNamespacedName(attribute.name)\n\t\t\t\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t\t\t\t: attribute.name.name\n\t\t\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\t\t\tattribute.value == null\n\t\t\t\t\t\t\t\t\t\t? t.booleanLiteral(true)\n\t\t\t\t\t\t\t\t\t\t: t.isJSXExpressionContainer(attribute.value)\n\t\t\t\t\t\t\t\t\t\t\t? attribute.value.expression\n\t\t\t\t\t\t\t\t\t\t\t: attribute.value\n\t\t\t\t\t\t\t\t// The parser rejects empty attribute expressions.\n\t\t\t\t\t\t\t\tconst expression = value as t.Expression\n\t\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\t\tkey === `key` ||\n\t\t\t\t\t\t\t\t\t\tliteral(expression) ||\n\t\t\t\t\t\t\t\t\t\tt.isFunction(expression)\n\t\t\t\t\t\t\t\t\t\t? t.objectProperty(t.stringLiteral(key), expression)\n\t\t\t\t\t\t\t\t\t\t: t.objectMethod(\n\t\t\t\t\t\t\t\t\t\t\t\t`get`,\n\t\t\t\t\t\t\t\t\t\t\t\tt.stringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t\t\tt.blockStatement([t.returnStatement(expression)]),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tconst children = t.react\n\t\t\t\t\t\t\t.buildChildren(node)\n\t\t\t\t\t\t\t.map((value) => child(value as t.Expression))\n\t\t\t\t\t\tif (children.length)\n\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\tt.objectProperty(\n\t\t\t\t\t\t\t\t\tt.identifier(`children`),\n\t\t\t\t\t\t\t\t\tchildren.length === 1\n\t\t\t\t\t\t\t\t\t\t? children[0]\n\t\t\t\t\t\t\t\t\t\t: t.arrayExpression(children),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\tflush()\n\t\t\t\t\t\tconst props =\n\t\t\t\t\t\t\tchunks.length > 1\n\t\t\t\t\t\t\t\t? t.callExpression(merge, chunks)\n\t\t\t\t\t\t\t\t: (chunks[0] ?? t.objectExpression([]))\n\t\t\t\t\t\tconst result = t.callExpression(create, [\n\t\t\t\t\t\t\tt.isJSXElement(node)\n\t\t\t\t\t\t\t\t? name(node.openingElement.name)\n\t\t\t\t\t\t\t\t: t.nullLiteral(),\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tgenerated.add(result)\n\t\t\t\t\t\tlet fn = path.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\twhile (fn?.findParent((parent: any) => parent.isFunction()))\n\t\t\t\t\t\t\tfn = fn.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\tif (fn) {\n\t\t\t\t\t\t\tif (fn.node.id) components.add(fn.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isVariableDeclarator() &&\n\t\t\t\t\t\t\t\tt.isIdentifier(fn.parentPath.node.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcomponents.add(fn.parentPath.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isExportDefaultDeclaration() &&\n\t\t\t\t\t\t\t\tt.isFunctionDeclaration(fn.node)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfn.node.id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpath.replaceWith(result)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\tconst result = transformSync(code, {\n\t\tfilename,\n\t\tbabelrc: false,\n\t\tconfigFile: false,\n\t\tsourceMaps: true,\n\t\tparserOpts: { plugins: [`jsx`, `typescript`] },\n\t\tplugins: [plugin],\n\t})!\n\treturn { code: result.code!, map: result.map }\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;AAGA,SAAgB,QACf,MACA,UAC6B;CAC7B,MAAM,eAA0B;EAC/B,IAAI;EACJ,IAAI;EACJ,MAAM,4BAAY,IAAI,QAAgB;EACtC,MAAM,6BAAa,IAAI,IAAY;EACnC,SAAS,KACR,MACe;GACf,IAAIA,MAAE,sBAAsB,IAAI,GAC/B,OAAOA,MAAE,iBACRA,MAAE,gBAAgB,KAAK,MAAM,IAC1B,KAAK,OAAO,SAAS,SACpBA,MAAE,eAAe,IACjBA,MAAE,WAAW,KAAK,OAAO,IAAI,IAC9B,KAAK,KAAK,MAAM,GACnBA,MAAE,WAAW,KAAK,SAAS,IAAI,CAChC;GACD,IAAIA,MAAE,oBAAoB,IAAI,GAC7B,OAAOA,MAAE,cAAc,GAAG,KAAK,UAAU,KAAK,GAAG,KAAK,KAAK,MAAM;GAClE,OAAO,SAAS,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,GAAG,IACtDA,MAAE,cAAc,KAAK,IAAI,IACzBA,MAAE,WAAW,KAAK,IAAI;EAC1B;EACA,SAAS,QAAQ,MAAuB;GACvC,OACCA,MAAE,UAAU,IAAI,MACf,CAACA,MAAE,kBAAkB,IAAI,KAAK,KAAK,YAAY,WAAW;EAE7D;EACA,SAAS,MAAM,MAAkC;GAChD,OAAO,UAAU,IAAI,IAAI,KAAK,QAAQ,IAAI,KAAKA,MAAE,WAAW,IAAI,IAC7D,OACAA,MAAE,wBAAwB,CAAC,GAAG,IAAI;EACtC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xB;EAEA,gBAAgB,EAAE,QAAQ,QAAQ;GACjC,IAAI,QAAQ,IAAI,GAAG;IAClB,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IACtC,OAAO,CAAC;GACT;EACD;CACD;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-BadrFSIM.js","names":["t"],"sources":["../src/compiler.ts","../src/vite.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\"\nimport { transformSync, types as t } from \"@babel/core\"\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: any } {\n\tconst plugin = (): PluginObj => {\n\t\tlet create: t.Identifier\n\t\tlet merge: t.Identifier\n\t\tconst generated = new WeakSet<object>()\n\t\tconst components = new Set<string>()\n\t\tfunction name(\n\t\t\tnode: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n\t\t): t.Expression {\n\t\t\tif (t.isJSXMemberExpression(node))\n\t\t\t\treturn t.memberExpression(\n\t\t\t\t\tt.isJSXIdentifier(node.object)\n\t\t\t\t\t\t? node.object.name === `this`\n\t\t\t\t\t\t\t? t.thisExpression()\n\t\t\t\t\t\t\t: t.identifier(node.object.name)\n\t\t\t\t\t\t: name(node.object),\n\t\t\t\t\tt.identifier(node.property.name),\n\t\t\t\t)\n\t\t\tif (t.isJSXNamespacedName(node))\n\t\t\t\treturn t.stringLiteral(`${node.namespace.name}:${node.name.name}`)\n\t\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t\t? t.stringLiteral(node.name)\n\t\t\t\t: t.identifier(node.name)\n\t\t}\n\t\tfunction literal(node: t.Node): boolean {\n\t\t\treturn (\n\t\t\t\tt.isLiteral(node) &&\n\t\t\t\t(!t.isTemplateLiteral(node) || node.expressions.length === 0)\n\t\t\t)\n\t\t}\n\t\tfunction child(node: t.Expression): t.Expression {\n\t\t\treturn generated.has(node) || literal(node) || t.isFunction(node)\n\t\t\t\t? node\n\t\t\t\t: t.arrowFunctionExpression([], node)\n\t\t}\n\t\treturn {\n\t\t\tvisitor: {\n\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isArrowFunctionExpression(path.node.declaration) ||\n\t\t\t\t\t\tt.isFunctionExpression(path.node.declaration)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\tpath.replaceWithMultiple([\n\t\t\t\t\t\t\tt.variableDeclaration(`const`, [\n\t\t\t\t\t\t\t\tt.variableDeclarator(id, path.node.declaration),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tt.exportDefaultDeclaration(id),\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tProgram: {\n\t\t\t\t\tenter(path) {\n\t\t\t\t\t\tcreate = path.scope.generateUidIdentifier(`spa`)\n\t\t\t\t\t\tmerge = path.scope.generateUidIdentifier(`props`)\n\t\t\t\t\t},\n\t\t\t\t\texit(path) {\n\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\tt.importDeclaration(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tt.importSpecifier(create, t.identifier(`jsx`)),\n\t\t\t\t\t\t\t\t\tt.importSpecifier(merge, t.identifier(`merge`)),\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tt.stringLiteral(`@atom.io/spa/jsx-runtime`),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tfor (const component of components)\n\t\t\t\t\t\t\tpath.pushContainer(\n\t\t\t\t\t\t\t\t`body`,\n\t\t\t\t\t\t\t\tt.expressionStatement(\n\t\t\t\t\t\t\t\t\tt.assignmentExpression(\n\t\t\t\t\t\t\t\t\t\t`=`,\n\t\t\t\t\t\t\t\t\t\tt.memberExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(component),\n\t\t\t\t\t\t\t\t\t\t\tt.identifier(`spa`),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tt.booleanLiteral(true),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"JSXElement|JSXFragment\": {\n\t\t\t\t\texit(path: any) {\n\t\t\t\t\t\tconst node = path.node as t.JSXElement | t.JSXFragment\n\t\t\t\t\t\tconst chunks: t.Expression[] = []\n\t\t\t\t\t\tlet properties: (t.ObjectProperty | t.ObjectMethod)[] = []\n\t\t\t\t\t\tconst flush = () => {\n\t\t\t\t\t\t\tif (properties.length) {\n\t\t\t\t\t\t\t\tchunks.push(t.objectExpression(properties))\n\t\t\t\t\t\t\t\tproperties = []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (t.isJSXElement(node))\n\t\t\t\t\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\t\t\t\t\tif (t.isJSXSpreadAttribute(attribute)) {\n\t\t\t\t\t\t\t\t\tflush()\n\t\t\t\t\t\t\t\t\tchunks.push(t.arrowFunctionExpression([], attribute.argument))\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst key = t.isJSXNamespacedName(attribute.name)\n\t\t\t\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t\t\t\t: attribute.name.name\n\t\t\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\t\t\tattribute.value == null\n\t\t\t\t\t\t\t\t\t\t? t.booleanLiteral(true)\n\t\t\t\t\t\t\t\t\t\t: t.isJSXExpressionContainer(attribute.value)\n\t\t\t\t\t\t\t\t\t\t\t? attribute.value.expression\n\t\t\t\t\t\t\t\t\t\t\t: attribute.value\n\t\t\t\t\t\t\t\t// The parser rejects empty attribute expressions.\n\t\t\t\t\t\t\t\tconst expression = value as t.Expression\n\t\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\t\tkey === `key` ||\n\t\t\t\t\t\t\t\t\t\tliteral(expression) ||\n\t\t\t\t\t\t\t\t\t\tt.isFunction(expression)\n\t\t\t\t\t\t\t\t\t\t? t.objectProperty(t.stringLiteral(key), expression)\n\t\t\t\t\t\t\t\t\t\t: t.objectMethod(\n\t\t\t\t\t\t\t\t\t\t\t\t`get`,\n\t\t\t\t\t\t\t\t\t\t\t\tt.stringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t\t\tt.blockStatement([t.returnStatement(expression)]),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tconst children = t.react\n\t\t\t\t\t\t\t.buildChildren(node)\n\t\t\t\t\t\t\t.map((value) => child(value as t.Expression))\n\t\t\t\t\t\tif (children.length)\n\t\t\t\t\t\t\tproperties.push(\n\t\t\t\t\t\t\t\tt.objectProperty(\n\t\t\t\t\t\t\t\t\tt.identifier(`children`),\n\t\t\t\t\t\t\t\t\tchildren.length === 1\n\t\t\t\t\t\t\t\t\t\t? children[0]\n\t\t\t\t\t\t\t\t\t\t: t.arrayExpression(children),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\tflush()\n\t\t\t\t\t\tconst props =\n\t\t\t\t\t\t\tchunks.length > 1\n\t\t\t\t\t\t\t\t? t.callExpression(merge, chunks)\n\t\t\t\t\t\t\t\t: (chunks[0] ?? t.objectExpression([]))\n\t\t\t\t\t\tconst result = t.callExpression(create, [\n\t\t\t\t\t\t\tt.isJSXElement(node)\n\t\t\t\t\t\t\t\t? name(node.openingElement.name)\n\t\t\t\t\t\t\t\t: t.nullLiteral(),\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tgenerated.add(result)\n\t\t\t\t\t\tlet fn = path.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\twhile (fn?.findParent((parent: any) => parent.isFunction()))\n\t\t\t\t\t\t\tfn = fn.findParent((parent: any) => parent.isFunction())\n\t\t\t\t\t\tif (fn) {\n\t\t\t\t\t\t\tif (fn.node.id) components.add(fn.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isVariableDeclarator() &&\n\t\t\t\t\t\t\t\tt.isIdentifier(fn.parentPath.node.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tcomponents.add(fn.parentPath.node.id.name)\n\t\t\t\t\t\t\telse if (\n\t\t\t\t\t\t\t\tfn.parentPath.isExportDefaultDeclaration() &&\n\t\t\t\t\t\t\t\tt.isFunctionDeclaration(fn.node)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfn.node.id = path.scope.generateUidIdentifier(`Component`)\n\t\t\t\t\t\t\t\tcomponents.add(fn.node.id.name)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpath.replaceWith(result)\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\tconst result = transformSync(code, {\n\t\tfilename,\n\t\tbabelrc: false,\n\t\tconfigFile: false,\n\t\tsourceMaps: true,\n\t\tparserOpts: { plugins: [`jsx`, `typescript`] },\n\t\tplugins: [plugin],\n\t})!\n\treturn { code: result.code!, map: result.map }\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;AAGA,SAAgB,QACf,MACA,UAC6B;CAC7B,MAAM,eAA0B;EAC/B,IAAI;EACJ,IAAI;EACJ,MAAM,4BAAY,IAAI,QAAgB;EACtC,MAAM,6BAAa,IAAI,IAAY;EACnC,SAAS,KACR,MACe;GACf,IAAIA,MAAE,sBAAsB,IAAI,GAC/B,OAAOA,MAAE,iBACRA,MAAE,gBAAgB,KAAK,MAAM,IAC1B,KAAK,OAAO,SAAS,SACpBA,MAAE,eAAe,IACjBA,MAAE,WAAW,KAAK,OAAO,IAAI,IAC9B,KAAK,KAAK,MAAM,GACnBA,MAAE,WAAW,KAAK,SAAS,IAAI,CAChC;GACD,IAAIA,MAAE,oBAAoB,IAAI,GAC7B,OAAOA,MAAE,cAAc,GAAG,KAAK,UAAU,KAAK,GAAG,KAAK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