effect-start 0.19.0 → 0.20.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.
Files changed (144) hide show
  1. package/README.md +3 -3
  2. package/dist/Development.d.ts +3 -3
  3. package/dist/Development.js +3 -2
  4. package/dist/Effectify.d.ts +212 -0
  5. package/dist/Effectify.js +19 -0
  6. package/dist/FilePathPattern.d.ts +29 -0
  7. package/dist/FilePathPattern.js +86 -0
  8. package/dist/FileRouter.d.ts +39 -41
  9. package/dist/FileRouter.js +104 -158
  10. package/dist/FileRouterCodegen.d.ts +7 -8
  11. package/dist/FileRouterCodegen.js +97 -66
  12. package/dist/PlatformError.d.ts +46 -0
  13. package/dist/PlatformError.js +43 -0
  14. package/dist/PlatformRuntime.d.ts +23 -0
  15. package/dist/PlatformRuntime.js +42 -0
  16. package/dist/RouteBody.d.ts +1 -1
  17. package/dist/Start.d.ts +34 -3
  18. package/dist/Start.js +31 -6
  19. package/dist/bun/BunPlatformHttpServer.d.ts +10 -0
  20. package/dist/bun/BunPlatformHttpServer.js +53 -0
  21. package/dist/bun/BunRoute.d.ts +3 -5
  22. package/dist/bun/BunRoute.js +9 -17
  23. package/dist/bun/BunRuntime.d.ts +2 -1
  24. package/dist/bun/BunRuntime.js +10 -5
  25. package/dist/bun/BunServer.d.ts +33 -0
  26. package/dist/bun/BunServer.js +133 -0
  27. package/dist/bun/BunServerRequest.d.ts +60 -0
  28. package/dist/bun/BunServerRequest.js +252 -0
  29. package/dist/bun/index.d.ts +1 -1
  30. package/dist/bun/index.js +1 -1
  31. package/dist/datastar/actions/fetch.d.ts +30 -0
  32. package/dist/datastar/actions/fetch.js +411 -0
  33. package/dist/datastar/actions/peek.d.ts +1 -0
  34. package/dist/datastar/actions/peek.js +14 -0
  35. package/dist/datastar/actions/setAll.d.ts +1 -0
  36. package/dist/datastar/actions/setAll.js +13 -0
  37. package/dist/datastar/actions/toggleAll.d.ts +1 -0
  38. package/dist/datastar/actions/toggleAll.js +13 -0
  39. package/dist/datastar/attributes/attr.d.ts +1 -0
  40. package/dist/datastar/attributes/attr.js +49 -0
  41. package/dist/datastar/attributes/bind.d.ts +1 -0
  42. package/dist/datastar/attributes/bind.js +183 -0
  43. package/dist/datastar/attributes/class.d.ts +1 -0
  44. package/dist/datastar/attributes/class.js +50 -0
  45. package/dist/datastar/attributes/computed.d.ts +1 -0
  46. package/dist/datastar/attributes/computed.js +27 -0
  47. package/dist/datastar/attributes/effect.d.ts +1 -0
  48. package/dist/datastar/attributes/effect.js +10 -0
  49. package/dist/datastar/attributes/indicator.d.ts +1 -0
  50. package/dist/datastar/attributes/indicator.js +32 -0
  51. package/dist/datastar/attributes/init.d.ts +1 -0
  52. package/dist/datastar/attributes/init.js +27 -0
  53. package/dist/datastar/attributes/jsonSignals.d.ts +1 -0
  54. package/dist/datastar/attributes/jsonSignals.js +31 -0
  55. package/dist/datastar/attributes/on.d.ts +1 -0
  56. package/dist/datastar/attributes/on.js +59 -0
  57. package/dist/datastar/attributes/onIntersect.d.ts +1 -0
  58. package/dist/datastar/attributes/onIntersect.js +54 -0
  59. package/dist/datastar/attributes/onInterval.d.ts +1 -0
  60. package/dist/datastar/attributes/onInterval.js +31 -0
  61. package/dist/datastar/attributes/onSignalPatch.d.ts +1 -0
  62. package/dist/datastar/attributes/onSignalPatch.js +44 -0
  63. package/dist/datastar/attributes/ref.d.ts +1 -0
  64. package/dist/datastar/attributes/ref.js +11 -0
  65. package/dist/datastar/attributes/show.d.ts +1 -0
  66. package/dist/datastar/attributes/show.js +32 -0
  67. package/dist/datastar/attributes/signals.d.ts +1 -0
  68. package/dist/datastar/attributes/signals.js +18 -0
  69. package/dist/datastar/attributes/style.d.ts +1 -0
  70. package/dist/datastar/attributes/style.js +56 -0
  71. package/dist/datastar/attributes/text.d.ts +1 -0
  72. package/dist/datastar/attributes/text.js +27 -0
  73. package/dist/datastar/engine.d.ts +156 -0
  74. package/dist/datastar/engine.js +971 -0
  75. package/dist/datastar/index.d.ts +24 -0
  76. package/dist/datastar/index.js +24 -0
  77. package/dist/datastar/load.d.ts +24 -0
  78. package/dist/datastar/load.js +24 -0
  79. package/dist/datastar/utils.d.ts +51 -0
  80. package/dist/datastar/utils.js +205 -0
  81. package/dist/datastar/watchers/patchElements.d.ts +1 -0
  82. package/dist/datastar/watchers/patchElements.js +420 -0
  83. package/dist/datastar/watchers/patchSignals.d.ts +1 -0
  84. package/dist/datastar/watchers/patchSignals.js +15 -0
  85. package/dist/index.d.ts +1 -1
  86. package/dist/index.js +1 -1
  87. package/dist/node/NodeFileSystem.d.ts +7 -0
  88. package/dist/node/NodeFileSystem.js +420 -0
  89. package/dist/node/NodeUtils.d.ts +2 -0
  90. package/dist/node/NodeUtils.js +20 -0
  91. package/dist/x/tailwind/plugin.js +1 -1
  92. package/package.json +11 -7
  93. package/src/Development.ts +26 -25
  94. package/src/{node/Effectify.ts → Effectify.ts} +10 -3
  95. package/src/FilePathPattern.ts +115 -0
  96. package/src/FileRouter.ts +178 -255
  97. package/src/FileRouterCodegen.ts +135 -92
  98. package/src/{node/PlatformError.ts → PlatformError.ts} +34 -19
  99. package/src/PlatformRuntime.ts +97 -0
  100. package/src/RouteBody.ts +1 -1
  101. package/src/RouteHttp.ts +3 -1
  102. package/src/Start.ts +61 -14
  103. package/src/bun/BunPlatformHttpServer.ts +88 -0
  104. package/src/bun/BunRoute.ts +12 -22
  105. package/src/bun/BunRuntime.ts +21 -5
  106. package/src/bun/BunServer.ts +228 -0
  107. package/src/bun/index.ts +1 -1
  108. package/src/datastar/README.md +18 -0
  109. package/src/datastar/actions/fetch.ts +609 -0
  110. package/src/datastar/actions/peek.ts +17 -0
  111. package/src/datastar/actions/setAll.ts +20 -0
  112. package/src/datastar/actions/toggleAll.ts +20 -0
  113. package/src/datastar/attributes/attr.ts +50 -0
  114. package/src/datastar/attributes/bind.ts +220 -0
  115. package/src/datastar/attributes/class.ts +57 -0
  116. package/src/datastar/attributes/computed.ts +33 -0
  117. package/src/datastar/attributes/effect.ts +11 -0
  118. package/src/datastar/attributes/indicator.ts +39 -0
  119. package/src/datastar/attributes/init.ts +35 -0
  120. package/src/datastar/attributes/jsonSignals.ts +38 -0
  121. package/src/datastar/attributes/on.ts +71 -0
  122. package/src/datastar/attributes/onIntersect.ts +65 -0
  123. package/src/datastar/attributes/onInterval.ts +39 -0
  124. package/src/datastar/attributes/onSignalPatch.ts +63 -0
  125. package/src/datastar/attributes/ref.ts +12 -0
  126. package/src/datastar/attributes/show.ts +33 -0
  127. package/src/datastar/attributes/signals.ts +22 -0
  128. package/src/datastar/attributes/style.ts +63 -0
  129. package/src/datastar/attributes/text.ts +30 -0
  130. package/src/datastar/engine.ts +1341 -0
  131. package/src/datastar/index.ts +25 -0
  132. package/src/datastar/utils.ts +286 -0
  133. package/src/datastar/watchers/patchElements.ts +554 -0
  134. package/src/datastar/watchers/patchSignals.ts +15 -0
  135. package/src/index.ts +1 -1
  136. package/src/node/{FileSystem.ts → NodeFileSystem.ts} +2 -2
  137. package/src/node/{Utils.ts → NodeUtils.ts} +2 -0
  138. package/src/x/tailwind/plugin.ts +1 -1
  139. package/src/FileRouterCodegen.todo.ts +0 -1133
  140. package/src/FileRouterPattern.ts +0 -59
  141. package/src/RouterPattern.ts +0 -416
  142. package/src/StartApp.ts +0 -47
  143. package/src/bun/BunHttpServer.ts +0 -303
  144. /package/src/bun/{BunHttpServer_web.ts → BunServerRequest.ts} +0 -0
@@ -0,0 +1,420 @@
1
+ import { watcher } from "../engine.js";
2
+ import { aliasify, isHTMLOrSVG, supportsViewTransitions, } from "../utils.js";
3
+ const isValidType = (arr, value) => arr.includes(value);
4
+ const PATCH_MODES = [
5
+ "remove",
6
+ "outer",
7
+ "inner",
8
+ "replace",
9
+ "prepend",
10
+ "append",
11
+ "before",
12
+ "after",
13
+ ];
14
+ const NAMESPACES = ["html", "svg", "mathml"];
15
+ watcher({
16
+ name: "datastar-patch-elements",
17
+ apply(ctx, { selector = "", mode = "outer", namespace = "html", useViewTransition = "", elements = "", }) {
18
+ if (!isValidType(PATCH_MODES, mode)) {
19
+ throw ctx.error("PatchElementsInvalidMode", { mode });
20
+ }
21
+ if (!selector && mode !== "outer" && mode !== "replace") {
22
+ throw ctx.error("PatchElementsExpectedSelector");
23
+ }
24
+ if (!isValidType(NAMESPACES, namespace)) {
25
+ throw ctx.error("PatchElementsInvalidNamespace", { namespace });
26
+ }
27
+ const args2 = {
28
+ selector,
29
+ mode,
30
+ namespace,
31
+ useViewTransition: useViewTransition.trim() === "true",
32
+ elements,
33
+ };
34
+ if (supportsViewTransitions && useViewTransition) {
35
+ document.startViewTransition(() => onPatchElements(ctx, args2));
36
+ }
37
+ else {
38
+ onPatchElements(ctx, args2);
39
+ }
40
+ },
41
+ });
42
+ const onPatchElements = ({ error }, { selector, mode, namespace, elements }) => {
43
+ const elementsWithSvgsRemoved = elements.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim, "");
44
+ const hasHtml = /<\/html>/.test(elementsWithSvgsRemoved);
45
+ const hasHead = /<\/head>/.test(elementsWithSvgsRemoved);
46
+ const hasBody = /<\/body>/.test(elementsWithSvgsRemoved);
47
+ const wrapperTag = namespace === "svg"
48
+ ? "svg"
49
+ : namespace === "mathml"
50
+ ? "math"
51
+ : "";
52
+ const wrappedEls = wrapperTag
53
+ ? `<${wrapperTag}>${elements}</${wrapperTag}>`
54
+ : elements;
55
+ const newDocument = new DOMParser().parseFromString(hasHtml || hasHead || hasBody
56
+ ? elements
57
+ : `<body><template>${wrappedEls}</template></body>`, "text/html");
58
+ let newContent = document.createDocumentFragment();
59
+ if (hasHtml) {
60
+ newContent.appendChild(newDocument.documentElement);
61
+ }
62
+ else if (hasHead && hasBody) {
63
+ newContent.appendChild(newDocument.head);
64
+ newContent.appendChild(newDocument.body);
65
+ }
66
+ else if (hasHead) {
67
+ newContent.appendChild(newDocument.head);
68
+ }
69
+ else if (hasBody) {
70
+ newContent.appendChild(newDocument.body);
71
+ }
72
+ else if (wrapperTag) {
73
+ const wrapperEl = newDocument
74
+ .querySelector("template")
75
+ .content
76
+ .querySelector(wrapperTag);
77
+ for (const child of wrapperEl.childNodes) {
78
+ newContent.appendChild(child);
79
+ }
80
+ }
81
+ else {
82
+ newContent = newDocument.querySelector("template").content;
83
+ }
84
+ if (!selector && (mode === "outer" || mode === "replace")) {
85
+ for (const child of newContent.children) {
86
+ let target;
87
+ if (child instanceof HTMLHtmlElement) {
88
+ target = document.documentElement;
89
+ }
90
+ else if (child instanceof HTMLBodyElement) {
91
+ target = document.body;
92
+ }
93
+ else if (child instanceof HTMLHeadElement) {
94
+ target = document.head;
95
+ }
96
+ else {
97
+ target = document.getElementById(child.id);
98
+ if (!target) {
99
+ console.warn(error("PatchElementsNoTargetsFound"), {
100
+ element: { id: child.id },
101
+ });
102
+ continue;
103
+ }
104
+ }
105
+ applyToTargets(mode, child, [target]);
106
+ }
107
+ }
108
+ else {
109
+ const targets = document.querySelectorAll(selector);
110
+ if (!targets.length) {
111
+ console.warn(error("PatchElementsNoTargetsFound"), { selector });
112
+ return;
113
+ }
114
+ applyToTargets(mode, newContent, targets);
115
+ }
116
+ };
117
+ const scripts = new WeakSet();
118
+ for (const script of document.querySelectorAll("script")) {
119
+ scripts.add(script);
120
+ }
121
+ const execute = (target) => {
122
+ const elScripts = target instanceof HTMLScriptElement
123
+ ? [target]
124
+ : target.querySelectorAll("script");
125
+ for (const old of elScripts) {
126
+ if (!scripts.has(old)) {
127
+ const script = document.createElement("script");
128
+ for (const { name, value } of old.attributes) {
129
+ script.setAttribute(name, value);
130
+ }
131
+ script.text = old.text;
132
+ old.replaceWith(script);
133
+ scripts.add(script);
134
+ }
135
+ }
136
+ };
137
+ const applyPatchMode = (targets, element, action) => {
138
+ for (const target of targets) {
139
+ const cloned = element.cloneNode(true);
140
+ execute(cloned);
141
+ // @ts-ignore
142
+ target[action](cloned);
143
+ }
144
+ };
145
+ const applyToTargets = (mode, element, targets) => {
146
+ switch (mode) {
147
+ case "remove":
148
+ for (const target of targets) {
149
+ target.remove();
150
+ }
151
+ break;
152
+ case "outer":
153
+ case "inner":
154
+ for (const target of targets) {
155
+ morph(target, element.cloneNode(true), mode);
156
+ execute(target);
157
+ }
158
+ break;
159
+ case "replace":
160
+ applyPatchMode(targets, element, "replaceWith");
161
+ break;
162
+ case "prepend":
163
+ case "append":
164
+ case "before":
165
+ case "after":
166
+ applyPatchMode(targets, element, mode);
167
+ }
168
+ };
169
+ const ctxIdMap = new Map();
170
+ const ctxPersistentIds = new Set();
171
+ const oldIdTagNameMap = new Map();
172
+ const duplicateIds = new Set();
173
+ const ctxPantry = document.createElement("div");
174
+ ctxPantry.hidden = true;
175
+ const aliasedIgnoreMorph = aliasify("ignore-morph");
176
+ const aliasedIgnoreMorphAttr = `[${aliasedIgnoreMorph}]`;
177
+ const morph = (oldElt, newContent, mode = "outer") => {
178
+ if ((isHTMLOrSVG(oldElt)
179
+ && isHTMLOrSVG(newContent)
180
+ && oldElt.hasAttribute(aliasedIgnoreMorph)
181
+ && newContent.hasAttribute(aliasedIgnoreMorph))
182
+ || oldElt.parentElement?.closest(aliasedIgnoreMorphAttr)) {
183
+ return;
184
+ }
185
+ const normalizedElt = document.createElement("div");
186
+ normalizedElt.append(newContent);
187
+ document.body.insertAdjacentElement("afterend", ctxPantry);
188
+ const oldIdElements = oldElt.querySelectorAll("[id]");
189
+ for (const { id, tagName } of oldIdElements) {
190
+ if (oldIdTagNameMap.has(id)) {
191
+ duplicateIds.add(id);
192
+ }
193
+ else {
194
+ oldIdTagNameMap.set(id, tagName);
195
+ }
196
+ }
197
+ if (oldElt instanceof Element && oldElt.id) {
198
+ if (oldIdTagNameMap.has(oldElt.id)) {
199
+ duplicateIds.add(oldElt.id);
200
+ }
201
+ else {
202
+ oldIdTagNameMap.set(oldElt.id, oldElt.tagName);
203
+ }
204
+ }
205
+ ctxPersistentIds.clear();
206
+ const newIdElements = normalizedElt.querySelectorAll("[id]");
207
+ for (const { id, tagName } of newIdElements) {
208
+ if (ctxPersistentIds.has(id)) {
209
+ duplicateIds.add(id);
210
+ }
211
+ else if (oldIdTagNameMap.get(id) === tagName) {
212
+ ctxPersistentIds.add(id);
213
+ }
214
+ }
215
+ for (const id of duplicateIds) {
216
+ ctxPersistentIds.delete(id);
217
+ }
218
+ oldIdTagNameMap.clear();
219
+ duplicateIds.clear();
220
+ ctxIdMap.clear();
221
+ const parent = mode === "outer" ? oldElt.parentElement : oldElt;
222
+ populateIdMapWithTree(parent, oldIdElements);
223
+ populateIdMapWithTree(normalizedElt, newIdElements);
224
+ morphChildren(parent, normalizedElt, mode === "outer" ? oldElt : null, oldElt.nextSibling);
225
+ ctxPantry.remove();
226
+ };
227
+ const morphChildren = (oldParent, newParent, insertionPoint = null, endPoint = null) => {
228
+ if (oldParent instanceof HTMLTemplateElement
229
+ && newParent instanceof HTMLTemplateElement) {
230
+ oldParent = oldParent.content;
231
+ newParent = newParent.content;
232
+ }
233
+ insertionPoint ??= oldParent.firstChild;
234
+ for (const newChild of newParent.childNodes) {
235
+ if (insertionPoint && insertionPoint !== endPoint) {
236
+ const bestMatch = findBestMatch(newChild, insertionPoint, endPoint);
237
+ if (bestMatch) {
238
+ if (bestMatch !== insertionPoint) {
239
+ let cursor = insertionPoint;
240
+ while (cursor && cursor !== bestMatch) {
241
+ const tempNode = cursor;
242
+ cursor = cursor.nextSibling;
243
+ removeNode(tempNode);
244
+ }
245
+ }
246
+ morphNode(bestMatch, newChild);
247
+ insertionPoint = bestMatch.nextSibling;
248
+ continue;
249
+ }
250
+ }
251
+ if (newChild instanceof Element && ctxPersistentIds.has(newChild.id)) {
252
+ const movedChild = document.getElementById(newChild.id);
253
+ let current = movedChild;
254
+ while ((current = current.parentNode)) {
255
+ const idSet = ctxIdMap.get(current);
256
+ if (idSet) {
257
+ idSet.delete(newChild.id);
258
+ if (!idSet.size) {
259
+ ctxIdMap.delete(current);
260
+ }
261
+ }
262
+ }
263
+ moveBefore(oldParent, movedChild, insertionPoint);
264
+ morphNode(movedChild, newChild);
265
+ insertionPoint = movedChild.nextSibling;
266
+ continue;
267
+ }
268
+ if (ctxIdMap.has(newChild)) {
269
+ const namespaceURI = newChild.namespaceURI;
270
+ const tagName = newChild.tagName;
271
+ const newEmptyChild = namespaceURI && namespaceURI !== "http://www.w3.org/1999/xhtml"
272
+ ? document.createElementNS(namespaceURI, tagName)
273
+ : document.createElement(tagName);
274
+ oldParent.insertBefore(newEmptyChild, insertionPoint);
275
+ morphNode(newEmptyChild, newChild);
276
+ insertionPoint = newEmptyChild.nextSibling;
277
+ }
278
+ else {
279
+ const newClonedChild = document.importNode(newChild, true);
280
+ oldParent.insertBefore(newClonedChild, insertionPoint);
281
+ insertionPoint = newClonedChild.nextSibling;
282
+ }
283
+ }
284
+ while (insertionPoint && insertionPoint !== endPoint) {
285
+ const tempNode = insertionPoint;
286
+ insertionPoint = insertionPoint.nextSibling;
287
+ removeNode(tempNode);
288
+ }
289
+ };
290
+ const findBestMatch = (node, startPoint, endPoint) => {
291
+ let bestMatch = null;
292
+ let nextSibling = node.nextSibling;
293
+ let siblingSoftMatchCount = 0;
294
+ let displaceMatchCount = 0;
295
+ const nodeMatchCount = ctxIdMap.get(node)?.size || 0;
296
+ let cursor = startPoint;
297
+ while (cursor && cursor !== endPoint) {
298
+ if (isSoftMatch(cursor, node)) {
299
+ let isIdSetMatch = false;
300
+ const oldSet = ctxIdMap.get(cursor);
301
+ const newSet = ctxIdMap.get(node);
302
+ if (newSet && oldSet) {
303
+ for (const id of oldSet) {
304
+ if (newSet.has(id)) {
305
+ isIdSetMatch = true;
306
+ break;
307
+ }
308
+ }
309
+ }
310
+ if (isIdSetMatch) {
311
+ return cursor;
312
+ }
313
+ if (!bestMatch && !ctxIdMap.has(cursor)) {
314
+ if (!nodeMatchCount) {
315
+ return cursor;
316
+ }
317
+ bestMatch = cursor;
318
+ }
319
+ }
320
+ displaceMatchCount += ctxIdMap.get(cursor)?.size || 0;
321
+ if (displaceMatchCount > nodeMatchCount) {
322
+ break;
323
+ }
324
+ if (bestMatch === null && nextSibling && isSoftMatch(cursor, nextSibling)) {
325
+ siblingSoftMatchCount++;
326
+ nextSibling = nextSibling.nextSibling;
327
+ if (siblingSoftMatchCount >= 2) {
328
+ bestMatch = undefined;
329
+ }
330
+ }
331
+ cursor = cursor.nextSibling;
332
+ }
333
+ return bestMatch || null;
334
+ };
335
+ const isSoftMatch = (oldNode, newNode) => oldNode.nodeType === newNode.nodeType
336
+ && oldNode.tagName === newNode.tagName
337
+ && (!oldNode.id
338
+ || oldNode.id === newNode.id);
339
+ const removeNode = (node) => {
340
+ ctxIdMap.has(node)
341
+ ? moveBefore(ctxPantry, node, null)
342
+ : node.parentNode?.removeChild(node);
343
+ };
344
+ const moveBefore =
345
+ // @ts-expect-error
346
+ removeNode.call.bind(ctxPantry.moveBefore ?? ctxPantry.insertBefore);
347
+ const aliasedPreserveAttr = aliasify("preserve-attr");
348
+ const morphNode = (oldNode, newNode) => {
349
+ const type = newNode.nodeType;
350
+ if (type === 1) {
351
+ const oldElt = oldNode;
352
+ const newElt = newNode;
353
+ const shouldScopeChildren = oldElt.hasAttribute("data-scope-children");
354
+ if (oldElt.hasAttribute(aliasedIgnoreMorph)
355
+ && newElt.hasAttribute(aliasedIgnoreMorph)) {
356
+ return oldNode;
357
+ }
358
+ if (oldElt instanceof HTMLInputElement
359
+ && newElt instanceof HTMLInputElement
360
+ && newElt.type !== "file") {
361
+ if (newElt.getAttribute("value") !== oldElt.getAttribute("value")) {
362
+ oldElt.value = newElt.getAttribute("value") ?? "";
363
+ }
364
+ }
365
+ else if (oldElt instanceof HTMLTextAreaElement
366
+ && newElt instanceof HTMLTextAreaElement) {
367
+ if (newElt.value !== oldElt.value) {
368
+ oldElt.value = newElt.value;
369
+ }
370
+ if (oldElt.firstChild && oldElt.firstChild.nodeValue !== newElt.value) {
371
+ oldElt.firstChild.nodeValue = newElt.value;
372
+ }
373
+ }
374
+ const preserveAttrs = (newNode.getAttribute(aliasedPreserveAttr) ?? "")
375
+ .split(" ");
376
+ for (const { name, value } of newElt.attributes) {
377
+ if (oldElt.getAttribute(name) !== value
378
+ && !preserveAttrs.includes(name)) {
379
+ oldElt.setAttribute(name, value);
380
+ }
381
+ }
382
+ for (let i = oldElt.attributes.length - 1; i >= 0; i--) {
383
+ const { name } = oldElt.attributes[i];
384
+ if (!newElt.hasAttribute(name) && !preserveAttrs.includes(name)) {
385
+ oldElt.removeAttribute(name);
386
+ }
387
+ }
388
+ if (shouldScopeChildren && !oldElt.hasAttribute("data-scope-children")) {
389
+ oldElt.setAttribute("data-scope-children", "");
390
+ }
391
+ if (!oldElt.isEqualNode(newElt)) {
392
+ morphChildren(oldElt, newElt);
393
+ }
394
+ if (shouldScopeChildren) {
395
+ oldElt.dispatchEvent(new CustomEvent("datastar:scope-children", { bubbles: false }));
396
+ }
397
+ }
398
+ if (type === 8 || type === 3) {
399
+ if (oldNode.nodeValue !== newNode.nodeValue) {
400
+ oldNode.nodeValue = newNode.nodeValue;
401
+ }
402
+ }
403
+ return oldNode;
404
+ };
405
+ const populateIdMapWithTree = (root, elements) => {
406
+ for (const elt of elements) {
407
+ if (ctxPersistentIds.has(elt.id)) {
408
+ let current = elt;
409
+ while (current && current !== root) {
410
+ let idSet = ctxIdMap.get(current);
411
+ if (!idSet) {
412
+ idSet = new Set();
413
+ ctxIdMap.set(current, idSet);
414
+ }
415
+ idSet.add(elt.id);
416
+ current = current.parentElement;
417
+ }
418
+ }
419
+ }
420
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { watcher } from "../engine.js";
2
+ import { mergePatch } from "../engine.js";
3
+ import { jsStrToObject } from "../utils.js";
4
+ watcher({
5
+ name: "datastar-patch-signals",
6
+ apply({ error }, { signals, onlyIfMissing }) {
7
+ if (signals) {
8
+ const ifMissing = onlyIfMissing?.trim() === "true";
9
+ mergePatch(jsStrToObject(signals), { ifMissing });
10
+ }
11
+ else {
12
+ throw error("PatchSignalsExpectedSignals");
13
+ }
14
+ },
15
+ });
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export * as Bundle from "./bundler/Bundle.ts";
2
2
  export * as Development from "./Development.ts";
3
3
  export * as Entity from "./Entity.ts";
4
4
  export * as FileRouter from "./FileRouter.ts";
5
- export * as Unique from "./Unique.ts";
6
5
  export * as Route from "./Route.ts";
7
6
  export * as Start from "./Start.ts";
7
+ export * as Unique from "./Unique.ts";
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@ export * as Bundle from "./bundler/Bundle.js";
2
2
  export * as Development from "./Development.js";
3
3
  export * as Entity from "./Entity.js";
4
4
  export * as FileRouter from "./FileRouter.js";
5
- export * as Unique from "./Unique.js";
6
5
  export * as Route from "./Route.js";
7
6
  export * as Start from "./Start.js";
7
+ export * as Unique from "./Unique.js";
@@ -0,0 +1,7 @@
1
+ import * as FileSystem from "@effect/platform/FileSystem";
2
+ import * as Layer from "effect/Layer";
3
+ import * as NFS from "node:fs";
4
+ import * as PlatformError from "../PlatformError.ts";
5
+ export declare const layer: Layer.Layer<FileSystem.FileSystem, never, never>;
6
+ export { FileSystem, PlatformError as Error, };
7
+ export declare function handleErrnoException(module: PlatformError.SystemError["module"], method: string): (err: NodeJS.ErrnoException, [path]: [path: NFS.PathLike | number, ...args: Array<any>]) => PlatformError.PlatformError;