effect-start 0.25.0 → 0.26.0

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 (117) hide show
  1. package/package.json +18 -86
  2. package/dist/ChildProcess.js +0 -42
  3. package/dist/Commander.js +0 -410
  4. package/dist/ContentNegotiation.js +0 -465
  5. package/dist/Cookies.js +0 -371
  6. package/dist/Development.js +0 -94
  7. package/dist/Effectify.js +0 -27
  8. package/dist/Entity.js +0 -289
  9. package/dist/Fetch.js +0 -192
  10. package/dist/FilePathPattern.js +0 -97
  11. package/dist/FileRouter.js +0 -204
  12. package/dist/FileRouterCodegen.js +0 -298
  13. package/dist/FileSystem.js +0 -132
  14. package/dist/Http.js +0 -107
  15. package/dist/PathPattern.js +0 -451
  16. package/dist/PlatformError.js +0 -40
  17. package/dist/PlatformRuntime.js +0 -71
  18. package/dist/Route.js +0 -143
  19. package/dist/RouteBody.js +0 -92
  20. package/dist/RouteError.js +0 -76
  21. package/dist/RouteHook.js +0 -64
  22. package/dist/RouteHttp.js +0 -367
  23. package/dist/RouteHttpTracer.js +0 -90
  24. package/dist/RouteMount.js +0 -86
  25. package/dist/RouteSchema.js +0 -271
  26. package/dist/RouteSse.js +0 -94
  27. package/dist/RouteTree.js +0 -119
  28. package/dist/RouteTrie.js +0 -179
  29. package/dist/SchemaExtra.js +0 -99
  30. package/dist/Socket.js +0 -40
  31. package/dist/SqlIntrospect.js +0 -515
  32. package/dist/Start.js +0 -79
  33. package/dist/StartApp.js +0 -3
  34. package/dist/StreamExtra.js +0 -135
  35. package/dist/System.js +0 -38
  36. package/dist/TuplePathPattern.js +0 -74
  37. package/dist/Unique.js +0 -226
  38. package/dist/Values.js +0 -52
  39. package/dist/bun/BunBundle.js +0 -186
  40. package/dist/bun/BunChildProcessSpawner.js +0 -142
  41. package/dist/bun/BunImportTrackerPlugin.js +0 -91
  42. package/dist/bun/BunRoute.js +0 -157
  43. package/dist/bun/BunRuntime.js +0 -41
  44. package/dist/bun/BunServer.js +0 -285
  45. package/dist/bun/BunVirtualFilesPlugin.js +0 -54
  46. package/dist/bun/_BunEnhancedResolve.js +0 -127
  47. package/dist/bun/index.js +0 -5
  48. package/dist/bundler/Bundle.js +0 -92
  49. package/dist/bundler/BundleFiles.js +0 -154
  50. package/dist/bundler/BundleRoute.js +0 -62
  51. package/dist/client/Overlay.js +0 -33
  52. package/dist/client/ScrollState.js +0 -106
  53. package/dist/client/index.js +0 -97
  54. package/dist/console/Console.js +0 -42
  55. package/dist/console/ConsoleErrors.js +0 -211
  56. package/dist/console/ConsoleLogger.js +0 -56
  57. package/dist/console/ConsoleMetrics.js +0 -72
  58. package/dist/console/ConsoleProcess.js +0 -59
  59. package/dist/console/ConsoleStore.js +0 -72
  60. package/dist/console/ConsoleTracer.js +0 -107
  61. package/dist/console/Simulation.js +0 -784
  62. package/dist/console/index.js +0 -3
  63. package/dist/console/routes/tree.js +0 -30
  64. package/dist/datastar/actions/fetch.js +0 -536
  65. package/dist/datastar/actions/peek.js +0 -13
  66. package/dist/datastar/actions/setAll.js +0 -19
  67. package/dist/datastar/actions/toggleAll.js +0 -19
  68. package/dist/datastar/attributes/attr.js +0 -49
  69. package/dist/datastar/attributes/bind.js +0 -194
  70. package/dist/datastar/attributes/class.js +0 -54
  71. package/dist/datastar/attributes/computed.js +0 -25
  72. package/dist/datastar/attributes/effect.js +0 -10
  73. package/dist/datastar/attributes/indicator.js +0 -33
  74. package/dist/datastar/attributes/init.js +0 -27
  75. package/dist/datastar/attributes/jsonSignals.js +0 -33
  76. package/dist/datastar/attributes/on.js +0 -81
  77. package/dist/datastar/attributes/onIntersect.js +0 -53
  78. package/dist/datastar/attributes/onInterval.js +0 -31
  79. package/dist/datastar/attributes/onSignalPatch.js +0 -51
  80. package/dist/datastar/attributes/ref.js +0 -11
  81. package/dist/datastar/attributes/show.js +0 -32
  82. package/dist/datastar/attributes/signals.js +0 -18
  83. package/dist/datastar/attributes/style.js +0 -57
  84. package/dist/datastar/attributes/text.js +0 -29
  85. package/dist/datastar/engine.js +0 -1145
  86. package/dist/datastar/index.js +0 -25
  87. package/dist/datastar/utils.js +0 -250
  88. package/dist/datastar/watchers/patchElements.js +0 -486
  89. package/dist/datastar/watchers/patchSignals.js +0 -14
  90. package/dist/experimental/EncryptedCookies.js +0 -328
  91. package/dist/experimental/index.js +0 -1
  92. package/dist/hyper/Hyper.js +0 -28
  93. package/dist/hyper/HyperHtml.js +0 -165
  94. package/dist/hyper/HyperNode.js +0 -13
  95. package/dist/hyper/HyperRoute.js +0 -45
  96. package/dist/hyper/html.js +0 -30
  97. package/dist/hyper/index.js +0 -5
  98. package/dist/hyper/jsx-runtime.js +0 -14
  99. package/dist/index.js +0 -8
  100. package/dist/node/NodeFileSystem.js +0 -675
  101. package/dist/node/NodeUtils.js +0 -23
  102. package/dist/sql/Sql.js +0 -8
  103. package/dist/sql/bun/index.js +0 -142
  104. package/dist/sql/index.js +0 -1
  105. package/dist/sql/libsql/index.js +0 -156
  106. package/dist/sql/mssql/docker.js +0 -110
  107. package/dist/sql/mssql/index.js +0 -194
  108. package/dist/testing/TestLogger.js +0 -42
  109. package/dist/testing/index.js +0 -2
  110. package/dist/testing/utils.js +0 -61
  111. package/dist/x/cloudflare/CloudflareTunnel.js +0 -63
  112. package/dist/x/cloudflare/index.js +0 -1
  113. package/dist/x/tailscale/TailscaleTunnel.js +0 -94
  114. package/dist/x/tailscale/index.js +0 -1
  115. package/dist/x/tailwind/TailwindPlugin.js +0 -294
  116. package/dist/x/tailwind/compile.js +0 -210
  117. package/dist/x/tailwind/plugin.js +0 -17
@@ -1,194 +0,0 @@
1
- import { attribute, effect, getPath, mergePaths } from "../engine.js"
2
- import { aliasify, modifyCasing } from "../utils.js"
3
-
4
- const dataURIRegex = /^data:(?<mime>[^;]+);base64,(?<contents>.*)$/
5
- const empty = Symbol("empty")
6
-
7
- const aliasedBind = aliasify("bind")
8
-
9
- attribute({
10
- name: "bind",
11
- requirement: "exclusive",
12
- apply({ el, key, mods, value, error }) {
13
- const signalName = key != null ? modifyCasing(key, mods) : value
14
-
15
- let get = (el, type) => (type === "number" ? +el.value : el.value)
16
-
17
- let set = (value) => {
18
- ;(el).value = `${value}`
19
- }
20
-
21
- if (el instanceof HTMLInputElement) {
22
- switch (el.type) {
23
- case "range":
24
- case "number":
25
- get = (el, type) => (type === "string" ? el.value : +el.value)
26
- break
27
-
28
- case "checkbox":
29
- get = (el, type) => {
30
- if (el.value !== "on") {
31
- if (type === "boolean") {
32
- return el.checked
33
- } else {
34
- return el.checked ? el.value : ""
35
- }
36
- } else {
37
- if (type === "string") {
38
- return el.checked ? el.value : ""
39
- } else {
40
- return el.checked
41
- }
42
- }
43
- }
44
- set = (value) => {
45
- el.checked = typeof value === "string" ? value === el.value : value
46
- }
47
- break
48
-
49
- case "radio":
50
- if (!el.getAttribute("name")?.length) {
51
- el.setAttribute("name", signalName)
52
- }
53
-
54
- get = (el, type) =>
55
- el.checked ? (type === "number" ? +el.value : el.value) : empty
56
- set = (value) => {
57
- el.checked = value === (typeof value === "number" ? +el.value : el.value)
58
- }
59
- break
60
- case "file": {
61
- const syncSignal = () => {
62
- const files = [...(el.files || [])]
63
- const signalFiles = []
64
- Promise.all(
65
- files.map(
66
- (f) =>
67
- new Promise((resolve) => {
68
- const reader = new FileReader()
69
- reader.onload = () => {
70
- if (typeof reader.result !== "string") {
71
- throw error("InvalidFileResultType", {
72
- resultType: typeof reader.result,
73
- })
74
- }
75
- const match = reader.result.match(dataURIRegex)
76
- if (!match?.groups) {
77
- throw error("InvalidDataUri", {
78
- result: reader.result,
79
- })
80
- }
81
- signalFiles.push({
82
- name: f.name,
83
- contents: match.groups.contents,
84
- mime: match.groups.mime,
85
- })
86
- }
87
- reader.onloadend = () => resolve()
88
- reader.readAsDataURL(f)
89
- }),
90
- ),
91
- ).then(() => {
92
- mergePaths([[signalName, signalFiles]])
93
- })
94
- }
95
-
96
- el.addEventListener("change", syncSignal)
97
- el.addEventListener("input", syncSignal)
98
-
99
- return () => {
100
- el.removeEventListener("change", syncSignal)
101
- el.removeEventListener("input", syncSignal)
102
- }
103
- }
104
- }
105
- } else if (el instanceof HTMLSelectElement) {
106
- if (el.multiple) {
107
- const typeMap = new Map()
108
- get = (el) =>
109
- [...el.selectedOptions].map((option) => {
110
- const type = typeMap.get(option.value)
111
- return type === "string" || type == null ? option.value : +option.value
112
- })
113
-
114
- set = (value) => {
115
- for (const option of el.options) {
116
- if (value.includes(option.value)) {
117
- typeMap.set(option.value, "string")
118
- option.selected = true
119
- } else if (value.includes(+option.value)) {
120
- typeMap.set(option.value, "number")
121
- option.selected = true
122
- } else {
123
- option.selected = false
124
- }
125
- }
126
- }
127
- }
128
- } else if (el instanceof HTMLTextAreaElement) {
129
- // default case
130
- } else {
131
- // web component
132
- get = (el) => ("value" in el ? el.value : el.getAttribute("value"))
133
- set = (value) => {
134
- if ("value" in el) {
135
- el.value = value
136
- } else {
137
- el.setAttribute("value", value)
138
- }
139
- }
140
- }
141
-
142
- const initialValue = getPath(signalName)
143
- const type = typeof initialValue
144
-
145
- let path = signalName
146
- if (Array.isArray(initialValue) && !(el instanceof HTMLSelectElement && el.multiple)) {
147
- const signalNameKebab = key ? key : value
148
- const inputs = document.querySelectorAll(
149
- `[${aliasedBind}\\:${CSS.escape(signalNameKebab)}],[${aliasedBind}="${CSS.escape(
150
- signalNameKebab,
151
- )}"]`,
152
- )
153
-
154
- const paths = []
155
- let i = 0
156
- for (const input of inputs) {
157
- paths.push([`${path}.${i}`, get(input, "none")])
158
-
159
- if (el === input) {
160
- break
161
- }
162
- i++
163
- }
164
- mergePaths(paths, { ifMissing: true })
165
- path = `${path}.${i}`
166
- } else {
167
- mergePaths([[path, get(el, type)]], {
168
- ifMissing: true,
169
- })
170
- }
171
-
172
- const syncSignal = () => {
173
- const signalValue = getPath(path)
174
- if (signalValue != null) {
175
- const value = get(el, typeof signalValue)
176
- if (value !== empty) {
177
- mergePaths([[path, value]])
178
- }
179
- }
180
- }
181
-
182
- el.addEventListener("input", syncSignal)
183
- el.addEventListener("change", syncSignal)
184
- const cleanup = effect(() => {
185
- set(getPath(path))
186
- })
187
-
188
- return () => {
189
- cleanup()
190
- el.removeEventListener("input", syncSignal)
191
- el.removeEventListener("change", syncSignal)
192
- }
193
- },
194
- })
@@ -1,54 +0,0 @@
1
- import { attribute, effect } from "../engine.js"
2
- import { modifyCasing } from "../utils.js"
3
-
4
- attribute({
5
- name: "class",
6
- requirement: {
7
- value: "must",
8
- },
9
- returnsValue: true,
10
- apply({ key, el, mods, rx }) {
11
- key &&= modifyCasing(key, mods, "kebab")
12
-
13
- let classes
14
- const callback = () => {
15
- observer.disconnect()
16
-
17
- classes = key ? { [key]: rx() } : (rx())
18
-
19
- for (const k in classes) {
20
- const classNames = k.split(/\s+/).filter((cn) => cn.length > 0)
21
- if (classes[k]) {
22
- for (const name of classNames) {
23
- if (!el.classList.contains(name)) {
24
- el.classList.add(name)
25
- }
26
- }
27
- } else {
28
- for (const name of classNames) {
29
- if (el.classList.contains(name)) {
30
- el.classList.remove(name)
31
- }
32
- }
33
- }
34
- }
35
-
36
- observer.observe(el, { attributeFilter: ["class"] })
37
- }
38
-
39
- const observer = new MutationObserver(callback)
40
- const cleanup = effect(callback)
41
-
42
- return () => {
43
- observer.disconnect()
44
- cleanup()
45
-
46
- for (const k in classes) {
47
- const classNames = k.split(/\s+/).filter((cn) => cn.length > 0)
48
- for (const name of classNames) {
49
- el.classList.remove(name)
50
- }
51
- }
52
- }
53
- },
54
- })
@@ -1,25 +0,0 @@
1
- import { attribute, computed, mergePatch, mergePaths } from "../engine.js"
2
- import { modifyCasing, updateLeaves } from "../utils.js"
3
-
4
- attribute({
5
- name: "computed",
6
- requirement: {
7
- value: "must",
8
- },
9
- returnsValue: true,
10
- apply({ key, mods, rx, error }) {
11
- if (key) {
12
- mergePaths([[modifyCasing(key, mods), computed(rx)]])
13
- } else {
14
- const patch = Object.assign({}, rx())
15
- updateLeaves(patch, (old) => {
16
- if (typeof old === "function") {
17
- return computed(old)
18
- } else {
19
- throw error("ComputedExpectedFunction")
20
- }
21
- })
22
- mergePatch(patch)
23
- }
24
- },
25
- })
@@ -1,10 +0,0 @@
1
- import { attribute, effect } from "../engine.js"
2
-
3
- attribute({
4
- name: "effect",
5
- requirement: {
6
- key: "denied",
7
- value: "must",
8
- },
9
- apply: ({ rx }) => effect(rx),
10
- })
@@ -1,33 +0,0 @@
1
- import { attribute, DATASTAR_FETCH_EVENT, mergePaths } from "../engine.js"
2
- import { modifyCasing } from "../utils.js"
3
- import { FINISHED, STARTED } from "../actions/fetch.js"
4
-
5
- attribute({
6
- name: "indicator",
7
- requirement: "exclusive",
8
- apply({ el, key, mods, value }) {
9
- const signalName = key != null ? modifyCasing(key, mods) : value
10
-
11
- mergePaths([[signalName, false]])
12
-
13
- const watcher = ((event) => {
14
- const { type, el: elt } = event.detail
15
- if (elt !== el) {
16
- return
17
- }
18
- switch (type) {
19
- case STARTED:
20
- mergePaths([[signalName, true]])
21
- break
22
- case FINISHED:
23
- mergePaths([[signalName, false]])
24
- break
25
- }
26
- })
27
- document.addEventListener(DATASTAR_FETCH_EVENT, watcher)
28
- return () => {
29
- mergePaths([[signalName, false]])
30
- document.removeEventListener(DATASTAR_FETCH_EVENT, watcher)
31
- }
32
- },
33
- })
@@ -1,27 +0,0 @@
1
- import { attribute, beginBatch, endBatch } from "../engine.js"
2
- import { delay, modifyViewTransition, tagToMs } from "../utils.js"
3
-
4
- attribute({
5
- name: "init",
6
- requirement: {
7
- key: "denied",
8
- value: "must",
9
- },
10
- apply({ rx, mods }) {
11
- let callback = () => {
12
- beginBatch()
13
- rx()
14
- endBatch()
15
- }
16
- callback = modifyViewTransition(callback, mods)
17
- let wait = 0
18
- const delayArgs = mods.get("delay")
19
- if (delayArgs) {
20
- wait = tagToMs(delayArgs)
21
- if (wait > 0) {
22
- callback = delay(callback, wait)
23
- }
24
- }
25
- callback()
26
- },
27
- })
@@ -1,33 +0,0 @@
1
- import { attribute, effect, filtered } from "../engine.js"
2
- import { jsStrToObject } from "../utils.js"
3
-
4
- attribute({
5
- name: "json-signals",
6
- requirement: {
7
- key: "denied",
8
- },
9
- apply({ el, value, mods }) {
10
- const spaces = mods.has("terse") ? 0 : 2
11
- let filters = {}
12
- if (value) {
13
- filters = jsStrToObject(value)
14
- }
15
-
16
- const callback = () => {
17
- observer.disconnect()
18
- el.textContent = JSON.stringify(filtered(filters), null, spaces)
19
- observer.observe(el, {
20
- childList: true,
21
- characterData: true,
22
- subtree: true,
23
- })
24
- }
25
- const observer = new MutationObserver(callback)
26
- const cleanup = effect(callback)
27
-
28
- return () => {
29
- observer.disconnect()
30
- cleanup()
31
- }
32
- },
33
- })
@@ -1,81 +0,0 @@
1
- import {
2
- attribute,
3
- beginBatch,
4
- DATASTAR_FETCH_EVENT,
5
- DATASTAR_SIGNAL_PATCH_EVENT,
6
- endBatch,
7
- } from "../engine.js"
8
- import { modifyTiming, modifyViewTransition } from "../utils.js"
9
-
10
- // TODO: support leading/trailing options for debounce/throttle
11
- // e.g. { debounce: { ms: 500, leading: true, noTrailing: true } }
12
- const configToMods = (config) => {
13
- const mods = new Map()
14
- for (const [k, v] of Object.entries(config)) {
15
- if (v === true) {
16
- mods.set(k, new Set())
17
- } else if (typeof v === "number") {
18
- mods.set(k, new Set([`${v}ms`]))
19
- }
20
- }
21
- return mods
22
- }
23
-
24
- attribute({
25
- name: "on",
26
- requirement: "must",
27
- argNames: ["evt"],
28
- apply({ el, key, mods, rx, value }) {
29
- let userFn
30
- let effectiveMods = mods
31
-
32
- try {
33
- const parts = Function(`return [${value}]`)()
34
- if (typeof parts[0] === "function") {
35
- userFn = parts[0]
36
- if (parts[1]) effectiveMods = configToMods(parts[1])
37
- }
38
- } catch {}
39
-
40
- let target = el
41
- if (effectiveMods.has("window")) target = window
42
- let callback = (evt) => {
43
- if (evt) {
44
- if (effectiveMods.has("prevent")) evt.preventDefault()
45
- if (effectiveMods.has("stop")) evt.stopPropagation()
46
- }
47
- beginBatch()
48
- userFn ? userFn(evt) : rx(evt)
49
- endBatch()
50
- }
51
- callback = modifyViewTransition(callback, effectiveMods)
52
- callback = modifyTiming(callback, effectiveMods)
53
- const evtListOpts = {
54
- capture: effectiveMods.has("capture"),
55
- passive: effectiveMods.has("passive"),
56
- once: effectiveMods.has("once"),
57
- }
58
- if (effectiveMods.has("outside")) {
59
- target = document
60
- const cb = callback
61
- callback = (evt) => {
62
- if (!el.contains(evt?.target)) cb(evt)
63
- }
64
- }
65
- const eventName = key
66
- if (eventName === DATASTAR_FETCH_EVENT || eventName === DATASTAR_SIGNAL_PATCH_EVENT) {
67
- target = document
68
- }
69
- if (el instanceof HTMLFormElement && eventName === "submit") {
70
- const cb = callback
71
- callback = (evt) => {
72
- evt?.preventDefault()
73
- cb(evt)
74
- }
75
- }
76
- target.addEventListener(eventName, callback, evtListOpts)
77
- return () => {
78
- target.removeEventListener(eventName, callback)
79
- }
80
- },
81
- })
@@ -1,53 +0,0 @@
1
- import { attribute, beginBatch, endBatch } from "../engine.js"
2
- import { clamp, modifyTiming, modifyViewTransition } from "../utils.js"
3
-
4
- const once = new WeakSet()
5
-
6
- attribute({
7
- name: "on-intersect",
8
- requirement: {
9
- key: "denied",
10
- value: "must",
11
- },
12
- apply({ el, mods, rx }) {
13
- let callback = () => {
14
- beginBatch()
15
- rx()
16
- endBatch()
17
- }
18
- callback = modifyViewTransition(callback, mods)
19
- callback = modifyTiming(callback, mods)
20
- const options = { threshold: 0 }
21
- if (mods.has("full")) {
22
- options.threshold = 1
23
- } else if (mods.has("half")) {
24
- options.threshold = 0.5
25
- } else if (mods.get("threshold")) {
26
- options.threshold = clamp(Number(mods.get("threshold")), 0, 100) / 100
27
- }
28
- const exit = mods.has("exit")
29
- let observer = new IntersectionObserver((entries) => {
30
- for (const entry of entries) {
31
- if (entry.isIntersecting !== exit) {
32
- callback()
33
- if (observer && once.has(el)) {
34
- observer.disconnect()
35
- }
36
- }
37
- }
38
- }, options)
39
- observer.observe(el)
40
- if (mods.has("once")) {
41
- once.add(el)
42
- }
43
- return () => {
44
- if (!mods.has("once")) {
45
- once.delete(el)
46
- }
47
- if (observer) {
48
- observer.disconnect()
49
- observer = null
50
- }
51
- }
52
- },
53
- })
@@ -1,31 +0,0 @@
1
- import { attribute, beginBatch, endBatch } from "../engine.js"
2
- import { modifyViewTransition, tagHas, tagToMs } from "../utils.js"
3
-
4
- attribute({
5
- name: "on-interval",
6
- requirement: {
7
- key: "denied",
8
- value: "must",
9
- },
10
- apply({ mods, rx }) {
11
- let callback = () => {
12
- beginBatch()
13
- rx()
14
- endBatch()
15
- }
16
- callback = modifyViewTransition(callback, mods)
17
- let duration = 1000
18
- const durationArgs = mods.get("duration")
19
- if (durationArgs) {
20
- duration = tagToMs(durationArgs)
21
- const leading = tagHas(durationArgs, "leading", false)
22
- if (leading) {
23
- callback()
24
- }
25
- }
26
- const intervalId = setInterval(callback, duration)
27
- return () => {
28
- clearInterval(intervalId)
29
- }
30
- },
31
- })
@@ -1,51 +0,0 @@
1
- import {
2
- attribute,
3
- beginBatch,
4
- DATASTAR_SIGNAL_PATCH_EVENT,
5
- endBatch,
6
- filtered,
7
- } from "../engine.js"
8
- import { aliasify, isEmpty, jsStrToObject, modifyTiming } from "../utils.js"
9
-
10
- attribute({
11
- name: "on-signal-patch",
12
- requirement: {
13
- value: "must",
14
- },
15
- argNames: ["patch"],
16
- returnsValue: true,
17
- apply({ el, key, mods, rx, error }) {
18
- if (!!key && key !== "filter") {
19
- throw error("KeyNotAllowed")
20
- }
21
-
22
- const filterAttr = aliasify(`${this.name}-filter`)
23
- const filtersRaw = el.getAttribute(filterAttr)
24
- let filters = {}
25
- if (filtersRaw) {
26
- filters = jsStrToObject(filtersRaw)
27
- }
28
-
29
- let running = false
30
-
31
- const callback = modifyTiming((evt) => {
32
- if (running) return
33
- const watched = filtered(filters, evt.detail)
34
- if (!isEmpty(watched)) {
35
- running = true
36
- beginBatch()
37
- try {
38
- rx(watched)
39
- } finally {
40
- endBatch()
41
- running = false
42
- }
43
- }
44
- }, mods)
45
-
46
- document.addEventListener(DATASTAR_SIGNAL_PATCH_EVENT, callback)
47
- return () => {
48
- document.removeEventListener(DATASTAR_SIGNAL_PATCH_EVENT, callback)
49
- }
50
- },
51
- })
@@ -1,11 +0,0 @@
1
- import { attribute, mergePaths } from "../engine.js"
2
- import { modifyCasing } from "../utils.js"
3
-
4
- attribute({
5
- name: "ref",
6
- requirement: "exclusive",
7
- apply({ el, key, mods, value }) {
8
- const signalName = key != null ? modifyCasing(key, mods) : value
9
- mergePaths([[signalName, el]])
10
- },
11
- })
@@ -1,32 +0,0 @@
1
- import { attribute, effect } from "../engine.js"
2
-
3
- const NONE = "none"
4
- const DISPLAY = "display"
5
-
6
- attribute({
7
- name: "show",
8
- requirement: {
9
- key: "denied",
10
- value: "must",
11
- },
12
- returnsValue: true,
13
- apply({ el, rx }) {
14
- const update = () => {
15
- observer.disconnect()
16
- const shouldShow = rx()
17
- if (shouldShow) {
18
- if (el.style.display === NONE) el.style.removeProperty(DISPLAY)
19
- } else {
20
- el.style.setProperty(DISPLAY, NONE)
21
- }
22
- observer.observe(el, { attributeFilter: ["style"] })
23
- }
24
- const observer = new MutationObserver(update)
25
- const cleanup = effect(update)
26
-
27
- return () => {
28
- observer.disconnect()
29
- cleanup()
30
- }
31
- },
32
- })
@@ -1,18 +0,0 @@
1
- import { attribute, mergePatch, mergePaths } from "../engine.js"
2
- import { modifyCasing } from "../utils.js"
3
-
4
- attribute({
5
- name: "signals",
6
- returnsValue: true,
7
- apply({ key, mods, rx }) {
8
- const ifMissing = mods.has("ifmissing")
9
-
10
- if (key) {
11
- key = modifyCasing(key, mods)
12
- mergePaths([[key, rx?.()]], { ifMissing })
13
- } else {
14
- const patch = Object.assign({}, rx?.())
15
- mergePatch(patch, { ifMissing })
16
- }
17
- },
18
- })