Initial Svelte support

main
Jackson Morgan 4 months ago
parent 84bd3d7cf0
commit b28e71faad
  1. 582
      package-lock.json
  2. 74
      packages/svelte/Readme.md
  3. 3
      packages/svelte/example/src/App.svelte
  4. 4
      packages/svelte/example/src/ldoSvelteMethods.ts
  5. 4
      packages/svelte/example/test-server/configs/components-config/unauthenticatedServer.json
  6. 0
      packages/svelte/example/test-server/configs/template/base/.acl.hbs
  7. 0
      packages/svelte/example/test-server/configs/template/base/link-query/main-profile.ttl
  8. 0
      packages/svelte/example/test-server/configs/template/base/link-query/other-profile.ttl
  9. 0
      packages/svelte/example/test-server/configs/template/base/link-query/third-profile.ttl
  10. 0
      packages/svelte/example/test-server/configs/template/base/profile/card.acl.hbs
  11. 31
      packages/svelte/example/test-server/runServer.ts
  12. 14
      packages/svelte/jest.config.cjs
  13. 86
      packages/svelte/jest.config.js
  14. 5
      packages/svelte/jest.setup.ts
  15. 27
      packages/svelte/package.json
  16. 132
      packages/svelte/src/methods/useLdo.ts
  17. 2
      packages/svelte/src/methods/useLinkQuery.ts
  18. 12
      packages/svelte/src/methods/useMatchObject.ts
  19. 12
      packages/svelte/src/methods/useMatchSubject.ts
  20. 2
      packages/svelte/src/methods/useSubscribeToResource.ts
  21. 10
      packages/svelte/tsconfig.cjs.json
  22. 11
      packages/svelte/tsconfig.esm.json
  23. 58
      packages/svelte/tsconfig.json
  24. 57
      packages/svelte/vite.config.ts
  25. 19
      packages/test-solid-server/package.json
  26. 13
      packages/test-solid-server/tsconfig.build.json
  27. 10
      packages/test-solid-server/tsconfig.cjs.json
  28. 11
      packages/test-solid-server/tsconfig.esm.json

582
package-lock.json generated

@ -31625,12 +31625,387 @@
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^4.5.0",
"vite-node": "^3.1.4",
"vite-plugin-dts": "^3.8.1"
},
"peerDependencies": {
"svelte": "^3.50.0"
}
},
"packages/svelte/node_modules/@esbuild/android-arm": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.4.tgz",
"integrity": "sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/android-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.4.tgz",
"integrity": "sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/android-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.4.tgz",
"integrity": "sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/darwin-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.4.tgz",
"integrity": "sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/darwin-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.4.tgz",
"integrity": "sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/freebsd-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.4.tgz",
"integrity": "sha512-yYq+39NlTRzU2XmoPW4l5Ifpl9fqSk0nAJYM/V/WUGPEFfek1epLHJIkTQM6bBs1swApjO5nWgvr843g6TjxuQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/freebsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.4.tgz",
"integrity": "sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-arm": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.4.tgz",
"integrity": "sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.4.tgz",
"integrity": "sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-ia32": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.4.tgz",
"integrity": "sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-loong64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.4.tgz",
"integrity": "sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-mips64el": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.4.tgz",
"integrity": "sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-ppc64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.4.tgz",
"integrity": "sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-riscv64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.4.tgz",
"integrity": "sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-s390x": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.4.tgz",
"integrity": "sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/linux-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.4.tgz",
"integrity": "sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/netbsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.4.tgz",
"integrity": "sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/openbsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.4.tgz",
"integrity": "sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/sunos-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.4.tgz",
"integrity": "sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/win32-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.4.tgz",
"integrity": "sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/win32-ia32": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.4.tgz",
"integrity": "sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@esbuild/win32-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.4.tgz",
"integrity": "sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"packages/svelte/node_modules/@types/jest": {
"version": "29.5.14",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz",
@ -31655,6 +32030,75 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"packages/svelte/node_modules/esbuild": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.4.tgz",
"integrity": "sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.25.4",
"@esbuild/android-arm": "0.25.4",
"@esbuild/android-arm64": "0.25.4",
"@esbuild/android-x64": "0.25.4",
"@esbuild/darwin-arm64": "0.25.4",
"@esbuild/darwin-x64": "0.25.4",
"@esbuild/freebsd-arm64": "0.25.4",
"@esbuild/freebsd-x64": "0.25.4",
"@esbuild/linux-arm": "0.25.4",
"@esbuild/linux-arm64": "0.25.4",
"@esbuild/linux-ia32": "0.25.4",
"@esbuild/linux-loong64": "0.25.4",
"@esbuild/linux-mips64el": "0.25.4",
"@esbuild/linux-ppc64": "0.25.4",
"@esbuild/linux-riscv64": "0.25.4",
"@esbuild/linux-s390x": "0.25.4",
"@esbuild/linux-x64": "0.25.4",
"@esbuild/netbsd-arm64": "0.25.4",
"@esbuild/netbsd-x64": "0.25.4",
"@esbuild/openbsd-arm64": "0.25.4",
"@esbuild/openbsd-x64": "0.25.4",
"@esbuild/sunos-x64": "0.25.4",
"@esbuild/win32-arm64": "0.25.4",
"@esbuild/win32-ia32": "0.25.4",
"@esbuild/win32-x64": "0.25.4"
}
},
"packages/svelte/node_modules/fdir": {
"version": "6.4.4",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz",
"integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"packages/svelte/node_modules/picomatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"packages/svelte/node_modules/pretty-format": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",
@ -31677,6 +32121,144 @@
"dev": true,
"license": "MIT"
},
"packages/svelte/node_modules/rollup": {
"version": "4.41.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.0.tgz",
"integrity": "sha512-HqMFpUbWlf/tvcxBFNKnJyzc7Lk+XO3FGc3pbNBLqEbOz0gPLRgcrlS3UF4MfUrVlstOaP/q0kM6GVvi+LrLRg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.7"
},
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"optionalDependencies": {
"@rollup/rollup-android-arm-eabi": "4.41.0",
"@rollup/rollup-android-arm64": "4.41.0",
"@rollup/rollup-darwin-arm64": "4.41.0",
"@rollup/rollup-darwin-x64": "4.41.0",
"@rollup/rollup-freebsd-arm64": "4.41.0",
"@rollup/rollup-freebsd-x64": "4.41.0",
"@rollup/rollup-linux-arm-gnueabihf": "4.41.0",
"@rollup/rollup-linux-arm-musleabihf": "4.41.0",
"@rollup/rollup-linux-arm64-gnu": "4.41.0",
"@rollup/rollup-linux-arm64-musl": "4.41.0",
"@rollup/rollup-linux-loongarch64-gnu": "4.41.0",
"@rollup/rollup-linux-powerpc64le-gnu": "4.41.0",
"@rollup/rollup-linux-riscv64-gnu": "4.41.0",
"@rollup/rollup-linux-riscv64-musl": "4.41.0",
"@rollup/rollup-linux-s390x-gnu": "4.41.0",
"@rollup/rollup-linux-x64-gnu": "4.41.0",
"@rollup/rollup-linux-x64-musl": "4.41.0",
"@rollup/rollup-win32-arm64-msvc": "4.41.0",
"@rollup/rollup-win32-ia32-msvc": "4.41.0",
"@rollup/rollup-win32-x64-msvc": "4.41.0",
"fsevents": "~2.3.2"
}
},
"packages/svelte/node_modules/vite-node": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.1.4.tgz",
"integrity": "sha512-6enNwYnpyDo4hEgytbmc6mYWHXDHYEn0D1/rw4Q+tnHUGtKTJsn8T1YkX6Q18wI5LCrS8CTYlBaiCqxOy2kvUA==",
"dev": true,
"license": "MIT",
"dependencies": {
"cac": "^6.7.14",
"debug": "^4.4.0",
"es-module-lexer": "^1.7.0",
"pathe": "^2.0.3",
"vite": "^5.0.0 || ^6.0.0"
},
"bin": {
"vite-node": "vite-node.mjs"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"packages/svelte/node_modules/vite-node/node_modules/vite": {
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "^0.25.0",
"fdir": "^6.4.4",
"picomatch": "^4.0.2",
"postcss": "^8.5.3",
"rollup": "^4.34.9",
"tinyglobby": "^0.2.13"
},
"bin": {
"vite": "bin/vite.js"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
},
"funding": {
"url": "https://github.com/vitejs/vite?sponsor=1"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"peerDependencies": {
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
"jiti": ">=1.21.0",
"less": "*",
"lightningcss": "^1.21.0",
"sass": "*",
"sass-embedded": "*",
"stylus": "*",
"sugarss": "*",
"terser": "^5.16.0",
"tsx": "^4.8.1",
"yaml": "^2.4.2"
},
"peerDependenciesMeta": {
"@types/node": {
"optional": true
},
"jiti": {
"optional": true
},
"less": {
"optional": true
},
"lightningcss": {
"optional": true
},
"sass": {
"optional": true
},
"sass-embedded": {
"optional": true
},
"stylus": {
"optional": true
},
"sugarss": {
"optional": true
},
"terser": {
"optional": true
},
"tsx": {
"optional": true
},
"yaml": {
"optional": true
}
}
},
"packages/test-solid-server": {
"name": "@ldo/test-solid-server",
"version": "1.0.0-alpha.11",

@ -0,0 +1,74 @@
# @ldo/svelte
## Installation
```
npm i @ldo/svelte @ldo/solid
```
## Usage
(see the "example" folder for a full example)
Initialize your LDO methods
```typescript
import { createLdoSvelteMethods } from "@ldo/svelte";
import { solidConnectedPlugin } from "@ldo/connected-solid";
export const {
dataset,
useLdo,
useMatchObject,
useMatchSubject,
useResource,
useSubject,
useSubscribeToResource,
useLinkQuery,
} = createLdoSvelteMethods([solidConnectedPlugin]);
// At some point when you log in, you'll need to set context on the dataset with
// the authentication information. For example, in Solid, you would run:
// dataset.setContext("solid", { fetch: authFetch });
```
Use them in your svelte components
```svelte
<script lang="ts">
import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes.js";
// Assuming these are the Svelte-specific functions/stores from your @ldo/svelte library
import { useResource, useSubject } from "./ldoSvelteMethods.js";
const SAMPLE_DATA_URI =
"http://localhost:3004/example/link-query/main-profile.ttl";
const resource = useResource(SAMPLE_DATA_URI);
const webId = `${SAMPLE_DATA_URI}#me`;
const profile = useSubject(SolidProfileShapeShapeType, webId);
$: friendArray = $profile?.knows?.toArray() || [];
$: firstFriendId =
friendArray.length > 0 ? friendArray[0]?.["@id"] : undefined;
</script>
<h1>LDO Svelte Support Demo</h1>
{#if $resource.isLoading() || !$profile}
<p>loading</p>
{:else}
<div>
{#if firstFriendId}
<p>{firstFriendId}</p>
{:else}
<p>No friend found or friend has no @id.</p>
{/if}
<ul>
{#each friendArray as friend (friend["@id"])}
<li>{friend["@id"]}</li>
{:else}
<li>No friends listed.</li>
{/each}
</ul>
</div>
{/if}
```

@ -3,7 +3,7 @@
// Assuming these are the Svelte-specific functions/stores from your @ldo/svelte library
import { useResource, useSubject } from "./ldoSvelteMethods.js";
const SAMPLE_DATA_URI =
"http://example.com/example/link-query/main-profile.ttl";
"http://localhost:3004/example/link-query/main-profile.ttl";
const resource = useResource(SAMPLE_DATA_URI);
const webId = `${SAMPLE_DATA_URI}#me`;
@ -13,6 +13,7 @@
friendArray.length > 0 ? friendArray[0]?.["@id"] : undefined;
</script>
<h1>LDO Svelte Support Demo</h1>
{#if $resource.isLoading() || !$profile}
<p>loading</p>
{:else}

@ -11,3 +11,7 @@ export const {
useSubscribeToResource,
useLinkQuery,
} = createLdoSvelteMethods([solidConnectedPlugin]);
// At some point when you log in, you'll need to set context on the dataset with
// the authentication information. For example, in Solid, you would run:
// dataset.setContext("solid", { fetch: authFetch });

@ -16,7 +16,7 @@
"css:config/identity/ownership/token.json",
"css:config/identity/pod/static.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/authorization/allow-all.json",
"css:config/ldp/handler/default.json",
"css:config/ldp/metadata-parser/default.json",
"css:config/ldp/metadata-writer/default.json",
@ -25,7 +25,7 @@
"css:config/storage/key-value/resource-store.json",
"css:config/storage/location/root.json",
"css:config/storage/middleware/default.json",
"css:config/util/auxiliary/acl.json",
"css:config/util/auxiliary/empty.json",
"css:config/util/identifiers/suffix.json",
"css:config/util/index/default.json",
"css:config/util/logging/winston.json",

@ -1,4 +1,6 @@
import { createApp } from "@ldo/test-solid-server/dist/createServer";
// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9
import type { App } from "@solid/community-server";
import { AppRunner, resolveModulePath } from "@solid/community-server";
import path from "path";
import { fileURLToPath } from "url";
@ -16,3 +18,30 @@ async function run() {
await app.start();
}
run();
export async function createApp(
port: number,
customConfigPath?: string,
): Promise<App> {
if (process.env.SERVER) {
return {
start: () => {},
stop: () => {},
} as App;
}
const appRunner = new AppRunner();
return appRunner.create({
loaderProperties: {
mainModulePath: resolveModulePath(""),
typeChecking: false,
},
config: customConfigPath ?? resolveModulePath("config/file-root.json"),
variableBindings: {},
shorthand: {
port: port,
seedConfig: path.join(__dirname, "configs", "solid-css-seed.json"),
rootFilePath: path.join(__dirname, `./data${port}`),
},
});
}

@ -0,0 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// packages/dataset/jest.config.cjs
const sharedConfig = require("../../jest.config.js");
module.exports = {
...sharedConfig,
rootDir: "./", // Sets context for this package
collectCoverageFrom: [
"src/**/*.ts",
"!src/**/*.d.ts",
// "!src/index.ts", // Optional, if index.ts only re-exports
],
modulePathIgnorePatterns: ["<rootDir>/dist/"],
};

@ -1,86 +0,0 @@
// packages/svelte/jest.config.js
/** @type {import('jest').Config} */
const config = {
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ["src/**/*.{ts,svelte}"], // Focus coverage on your source files
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: ["json", "text", "lcov", "html"],
// The test environment that will be used for testing (jsdom for browser-like environment)
testEnvironment: "jest-environment-jsdom",
// A list of paths to modules that run some code to configure or set up the testing framework
// before each test file in the suite.
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
// The glob patterns Jest uses to detect test files
testMatch: [
"<rootDir>/src/**/*.test.ts",
"<rootDir>/src/**/*.spec.ts",
"<rootDir>/test/**/*.test.ts", // Or wherever your tests are located
"<rootDir>/test/**/*.spec.ts",
],
// An array of file extensions your modules use
moduleFileExtensions: ["ts", "js", "svelte", "json"],
// A map from regular expressions to module names or to arrays of module names
// that allow to stub out resources with a single module
moduleNameMapper: {
// Alias for SvelteKit-style $lib imports (if you use them)
"^\\$lib(.*)$": "<rootDir>/src$1",
// Mock CSS imports to prevent errors
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
// You can add mocks for other static assets if needed
// '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
},
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.svelte$": [
"svelte-jester", // Uses your svelte-jester@^5.0.0
{
preprocess: true, // This will automatically use svelte.config.js
// Set to false if svelte.config.js is not found or not to be used.
// You could also pass preprocess options directly here:
// preprocess: require('svelte-preprocess')({ typescript: true })
},
],
"^.+\\.ts$": [
// Changed from (ts|tsx) as tsx is less common in Svelte libs
"ts-jest",
{
tsconfig: "<rootDir>/tsconfig.json", // Points to your package's tsconfig for type-safety
// Example: disabling some TS diagnostics if they are noisy in tests
// diagnostics: {
// ignoreCodes: ['TS151001']
// }
},
],
// If you have .js files that need transpilation (e.g. using modern JS features not supported by Node version running Jest)
// you might add a babel-jest transformer here. For a library mostly in TS, this might not be needed.
// '^.+\\.js$': 'babel-jest',
},
// An array of regexp pattern strings that are matched against all source file paths before transformation.
// If the file path matches any of the patterns, it will not be transformed.
// This is important for node_modules that are published as ES modules but Jest runs in CJS by default.
transformIgnorePatterns: [
"/node_modules/(?!(svelte-routing|another-es-module-package)/)", // Adjust if you use ESM-only deps
],
// Indicates whether each individual test should be reported during the run
verbose: true,
// Optionally, if your project or tests are pure ESM, you might explore ESM support in Jest:
// preset: 'ts-jest/presets/default-esm', // or 'ts-jest/presets/default-esm-legacy'
// extensionsToTreatAsEsm: ['.ts', '.svelte'],
// moduleNameMapper for ESM often needs to handle .js extensions in imports.
};
export default config;

@ -1,5 +0,0 @@
// packages/svelte/jest.setup.js
// Extends Jest's expect method with matchers from @testing-library/jest-dom
// For example, to use `expect(element).toHaveTextContent(/react/i)`
import "@testing-library/jest-dom";

@ -2,19 +2,27 @@
"name": "@ldo/svelte",
"version": "1.0.0-alpha.11",
"description": "A Svelte library for LDO.",
"main": "dist/index.js",
"module": "dist/index.mjs",
"svelte": "src/index.ts",
"types": "dist/index.d.ts",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"svelte": "src/index.ts",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"dev": "concurrently \"npm run dev:pod\" \"npm run dev:app\"",
"dev:pod": "tsx ./example/test-server/runServer.ts",
"dev:pod": "vite-node ./example/test-server/runServer.ts",
"dev:app": "vite --config vite.config.example.ts",
"build": "rimraf dist && vite build",
"build:example": "vite build --config vite.config.example.ts example",
"test": "jest",
"test:watch": "jest --watch",
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"test": "jest --coverage",
"lint": "eslint . --ext .js,.ts,.svelte --fix --no-error-on-unmatched-pattern",
"format": "prettier --write .",
"prepublishOnly": "npm run build"
@ -49,6 +57,7 @@
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^4.5.0",
"vite-node": "^3.1.4",
"vite-plugin-dts": "^3.8.1"
},
"peerDependencies": {

@ -1,10 +1,11 @@
import {
changeData,
// changeData,
type ConnectedLdoDataset,
type ConnectedLdoTransactionDataset,
type ConnectedPlugin,
} from "@ldo/connected";
import { type LdoBase, type ShapeType } from "@ldo/ldo";
import { getDataset, type LdoBase, type ShapeType } from "@ldo/ldo";
import type { SubjectNode } from "@ldo/rdf-utils";
/**
@ -79,69 +80,68 @@ export interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
export function createUseLdo<Plugins extends ConnectedPlugin[]>(
dataset: ConnectedLdoDataset<Plugins>,
) {
throw new Error("Not Implemented");
// const toReturn = {
// dataset,
// /**
// * Gets a resource
// */
// getResource: dataset.getResource.bind(dataset),
// /**
// * Set the context
// */
// setContext: dataset.setContext.bind(dataset),
// /**
// * Returns a Linked Data Object for a subject
// * @param shapeType The shape type for the data
// * @param subject Subject Node
// * @returns A Linked Data Object
// */
// getSubject<Type extends LdoBase>(
// shapeType: ShapeType<Type>,
// subject: string | SubjectNode,
// ): Type {
// return dataset.usingType(shapeType).fromSubject(subject);
// },
// /**
// * Begins tracking changes to eventually commit for a new subject
// * @param shapeType The shape type that defines the created data
// * @param subject The RDF subject for a Linked Data Object
// * @param resources Any number of resources to which this data should be written
// * @returns A Linked Data Object to modify and commit
// */
// createData<Type extends LdoBase>(
// shapeType: ShapeType<Type>,
// subject: string | SubjectNode,
// resource: Plugins[number]["types"]["resource"],
// ...additionalResources: Plugins[number]["types"]["resource"][]
// ): Type {
// return dataset.createData(
// shapeType,
// subject,
// resource,
// ...additionalResources,
// );
// },
// /**
// * Begins tracking changes to eventually commit
// * @param input A linked data object to track changes on
// * @param resources
// */
// changeData: changeData,
// /**
// * Commits the transaction to the global dataset, syncing all subscribing
// * components and Solid Pods
// */
// commitData(
// input: LdoBase,
// ): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]> {
// const inputDataset = getDataset(
// input,
// ) as ConnectedLdoTransactionDataset<Plugins>;
// return inputDataset.commitToRemote();
// },
// };
// return function useLdo(): UseLdoMethods<Plugins> {
// throw new Error("Not Implemented");
// };
const toReturn = {
dataset,
/**
* Gets a resource
*/
getResource: dataset.getResource.bind(dataset),
/**
* Set the context
*/
setContext: dataset.setContext.bind(dataset),
/**
* Returns a Linked Data Object for a subject
* @param shapeType The shape type for the data
* @param subject Subject Node
* @returns A Linked Data Object
*/
getSubject<Type extends LdoBase>(
shapeType: ShapeType<Type>,
subject: string | SubjectNode,
): Type {
return dataset.usingType(shapeType).fromSubject(subject);
},
/**
* Begins tracking changes to eventually commit for a new subject
* @param shapeType The shape type that defines the created data
* @param subject The RDF subject for a Linked Data Object
* @param resources Any number of resources to which this data should be written
* @returns A Linked Data Object to modify and commit
*/
createData<Type extends LdoBase>(
shapeType: ShapeType<Type>,
subject: string | SubjectNode,
resource: Plugins[number]["types"]["resource"],
...additionalResources: Plugins[number]["types"]["resource"][]
): Type {
return dataset.createData(
shapeType,
subject,
resource,
...additionalResources,
);
},
/**
* Begins tracking changes to eventually commit
* @param input A linked data object to track changes on
* @param resources
*/
changeData: changeData,
/**
* Commits the transaction to the global dataset, syncing all subscribing
* components and Solid Pods
*/
commitData(
input: LdoBase,
): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]> {
const inputDataset = getDataset(
input,
) as ConnectedLdoTransactionDataset<Plugins>;
return inputDataset.commitToRemote();
},
};
return function useLdo(): UseLdoMethods<Plugins> {
return toReturn;
};
}

@ -29,6 +29,6 @@ export function createUseLinkQuery<Plugins extends ConnectedPlugin[]>(
startingSubject: SubjectNode | string,
linkQuery: QueryInput,
): ExpandDeep<LQReturn<Type, QueryInput>> | undefined {
throw new Error("Not Implemented");
throw new Error("Link Query is Not Implemented for Svelte");
};
}

@ -1,6 +1,8 @@
import type { LdoBase, LdSet, ShapeType } from "@ldo/ldo";
import type { LdoBase, LdoBuilder, LdSet, ShapeType } from "@ldo/ldo";
import type { QuadMatch } from "@ldo/rdf-utils";
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
import type { Readable } from "svelte/store";
import { useTrackingProxy } from "../util/useTrackingProxy";
/**
* @internal
@ -19,7 +21,11 @@ export function createUseMatchObject<Plugins extends ConnectedPlugin[]>(
subject?: QuadMatch[0] | string,
predicate?: QuadMatch[1] | string,
graph?: QuadMatch[3] | string,
): LdSet<Type> {
throw new Error("Not Implemented");
): Readable<LdSet<Type>> {
const matchObject = (builder: LdoBuilder<Type>) => {
return builder.matchObject(subject, predicate, graph);
};
return useTrackingProxy(shapeType, matchObject, dataset);
};
}

@ -1,6 +1,8 @@
import type { LdoBase, LdSet, ShapeType } from "@ldo/ldo";
import type { LdoBase, LdoBuilder, LdSet, ShapeType } from "@ldo/ldo";
import type { QuadMatch } from "@ldo/rdf-utils";
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
import { useTrackingProxy } from "../util/useTrackingProxy";
import type { Readable } from "svelte/store";
/**
* @internal
@ -19,7 +21,11 @@ export function createUseMatchSubject<Plugins extends ConnectedPlugin[]>(
predicate?: QuadMatch[1] | string,
object?: QuadMatch[2] | string,
graph?: QuadMatch[3] | string,
): LdSet<Type> {
throw new Error("Not Implemented");
): Readable<LdSet<Type>> {
const matchSubject = (builder: LdoBuilder<Type>) => {
return builder.matchSubject(predicate, object, graph);
};
return useTrackingProxy(shapeType, matchSubject, dataset);
};
}

@ -12,6 +12,6 @@ export function createUseSubscribeToResource<Plugins extends ConnectedPlugin[]>(
* Starts a subscription to a resource.
*/
return function useSubscribeToResource(...uris: string[]): void {
throw new Error("Not Implemented");
throw new Error("Subscribe to Resource is Not Implemented for Svelte");
};
}

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.cjs.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"rootDir": "./src"
},
"include": [
"src"
]
}

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist/esm",
"rootDir": "./src",
"declarationDir": "./dist/types"
},
"include": [
"src"
]
}

@ -1,58 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"baseUrl": ".",
"paths": {
"$lib": [
"src"
],
"$lib/*": [
"src/*"
],
// Add this path alias for your library:
"@ldo/svelte": [
"src/index.ts"
], // Points to your library's main entry point for types
"@ldo/svelte/*": [
"src/*"
] // Allows importing submodules like '@ldo/svelte/store' if you structure that way
},
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"lib": [
"DOM",
"ESNext"
],
"types": [
"jest",
"@testing-library/jest-dom",
"@types/node",
"svelte" // Added "svelte" to ensure Svelte's global types are picked up
]
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.svelte",
"tests/**/*.ts",
"tests/**/*.svelte",
"example/src/**/*.ts",
"example/src/**/*.svelte",
"vite.config.ts",
"vite.config.example.ts",
"jest.config.js"
],
"exclude": [
"node_modules",
"dist",
"dist-example"
]
}

@ -1,57 +0,0 @@
// packages/my-svelte-lib/vite.config.ts
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import sveltePreprocess from "svelte-preprocess";
import dts from "vite-plugin-dts";
import path from "path";
import pkg from "./package.json" assert { type: "json" }; // Updated import
const ldoAndRdfDeps = Object.keys(pkg.dependencies || {}).filter(
(dep) => dep.startsWith("@ldo/") || dep.startsWith("@rdfjs/"),
);
const externalDeps = [
...Object.keys(pkg.peerDependencies || {}),
...ldoAndRdfDeps,
/^svelte(\/.+)?$/,
];
export default defineConfig({
plugins: [
svelte({
preprocess: sveltePreprocess({
typescript: true,
}),
}),
dts({
outDir: "dist",
insertTypesEntry: true,
}),
],
build: {
outDir: "dist",
sourcemap: true,
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: "LdoSvelte",
fileName: (format) => {
if (format === "es") return "index.mjs";
if (format === "cjs") return "index.cjs";
return `index.${format}.js`;
},
formats: ["es", "cjs"],
},
rollupOptions: {
external: externalDeps,
output: {
exports: "auto",
},
},
},
resolve: {
dedupe: ["svelte"],
alias: {
$lib: path.resolve(__dirname, "src"),
},
},
});

@ -3,12 +3,23 @@
"version": "1.0.0-alpha.11",
"description": "A solid server to be used in jest tests",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc --project tsconfig.build.json && npm run copy-configs",
"build": "rimraf dist && npm run build:cjs && npm run build:esm && npm run copy-configs",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"prepublishOnly": "npm run build",
"copy-configs": "cp -r src/configs dist/configs",
"copy-configs": "cp -r src/configs dist/cjs/configs && cp -r src/configs dist/esm/configs",
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern"
},
"repository": {

@ -1,13 +0,0 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": [
"./src"
],
"exclude": [
"./dist",
"./coverage"
]
}

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.cjs.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"rootDir": "./src"
},
"include": [
"src"
]
}

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist/esm",
"rootDir": "./src",
"declarationDir": "./dist/types"
},
"include": [
"src"
]
}
Loading…
Cancel
Save