@llui/dom 0.0.24 → 0.0.25
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedom.d.ts","sourceRoot":"","sources":["../../src/ssr/linkedom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAyB3C;;;;;;GAMG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"linkedom.d.ts","sourceRoot":"","sources":["../../src/ssr/linkedom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAyB3C;;;;;;GAMG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAmCnD"}
|
package/dist/ssr/linkedom.js
CHANGED
|
@@ -6,8 +6,13 @@
|
|
|
6
6
|
* Requires `linkedom` as an installed dependency.
|
|
7
7
|
*/
|
|
8
8
|
export async function linkedomEnv() {
|
|
9
|
-
//
|
|
10
|
-
|
|
9
|
+
// Dynamic import — linkedom is an optional peer dependency. When it
|
|
10
|
+
// is installed (workspace build, or any consumer that needs the
|
|
11
|
+
// linkedom env), TS resolves the module and infers a real type;
|
|
12
|
+
// when absent, TS errors with "Cannot find module 'linkedom'" which
|
|
13
|
+
// is the intended nudge. The explicit `as unknown as …` coerces
|
|
14
|
+
// both cases through the narrow shape the runtime actually uses.
|
|
15
|
+
const linkedomMod = (await import('linkedom'));
|
|
11
16
|
const { parseHTML } = linkedomMod;
|
|
12
17
|
const w = parseHTML('<!DOCTYPE html><html><body></body></html>');
|
|
13
18
|
return {
|
package/dist/ssr/linkedom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedom.js","sourceRoot":"","sources":["../../src/ssr/link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C,CAAC,gBAAgB;QACpC,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,mBAAmB,EAAE,CAAC,CAAC,mBAAmB;QAC1C,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC1B,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAwB,CAAA;YAC5E,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;YACzB,OAAO,QAAQ,CAAC,OAAO,CAAA;QACzB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * `@llui/dom/ssr/linkedom` — linkedom-backed `DomEnv` factory.\n *\n * Linkedom is a lightweight JSDOM alternative — smaller bundle, works\n * on Cloudflare Workers and other strict-isolate runtimes where jsdom's\n * transitive `whatwg-url` / `tr46` / `punycode` chain fails to resolve.\n */\nimport type { DomEnv } from '../dom-env.js'\n\n// Linkedom exposes a `parseHTML` function that returns a window-like\n// object with DOM constructors and a `document`. The exact shape is\n// narrower than JSDOM's but matches the DomEnv surface we need.\ninterface LinkedomWindow {\n document: {\n createElement: (tag: string) => Element\n createElementNS: (ns: string, tag: string) => Element\n createTextNode: (text: string) => Text\n createComment: (text: string) => Comment\n createDocumentFragment: () => DocumentFragment\n createRange: () => Range\n }\n Element: typeof Element\n Node: typeof Node\n Text: typeof Text\n Comment: typeof Comment\n DocumentFragment: typeof DocumentFragment\n HTMLElement: typeof HTMLElement\n HTMLTemplateElement: typeof HTMLTemplateElement\n ShadowRoot: typeof ShadowRoot\n MouseEvent: typeof MouseEvent\n}\n\n/**\n * Construct a `DomEnv` backed by a fresh linkedom instance. Each call\n * returns a new env — no process-level state, safe under concurrency\n * and compatible with Cloudflare Workers.\n *\n * Requires `linkedom` as an installed dependency.\n */\nexport async function linkedomEnv(): Promise<DomEnv> {\n // Dynamic import — linkedom is an optional peer dependency. When it\n // is installed (workspace build, or any consumer that needs the\n // linkedom env), TS resolves the module and infers a real type;\n // when absent, TS errors with \"Cannot find module 'linkedom'\" which\n // is the intended nudge. The explicit `as unknown as …` coerces\n // both cases through the narrow shape the runtime actually uses.\n const linkedomMod = (await import('linkedom')) as unknown as {\n parseHTML: (html: string) => LinkedomWindow\n }\n const { parseHTML } = linkedomMod\n const w = parseHTML('<!DOCTYPE html><html><body></body></html>')\n\n return {\n createElement: (tag) => w.document.createElement(tag),\n createElementNS: (ns, tag) => w.document.createElementNS(ns, tag),\n createTextNode: (text) => w.document.createTextNode(text),\n createComment: (text) => w.document.createComment(text),\n createDocumentFragment: () => w.document.createDocumentFragment(),\n createRange: () => w.document.createRange(),\n Element: w.Element,\n Node: w.Node,\n Text: w.Text,\n Comment: w.Comment,\n DocumentFragment: w.DocumentFragment,\n HTMLElement: w.HTMLElement,\n HTMLTemplateElement: w.HTMLTemplateElement,\n ShadowRoot: w.ShadowRoot,\n MouseEvent: w.MouseEvent,\n parseHtmlFragment: (html) => {\n const template = w.document.createElement('template') as HTMLTemplateElement\n template.innerHTML = html\n return template.content\n },\n }\n}\n"]}
|