svelte-sxo 0.0.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.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # svelte-sxo
2
+
3
+ SXO 设计系统的 Svelte 适配器。
4
+
5
+ ## 功能
6
+
7
+ - **Svelte 原生体验**: 符合 Svelte 开发习惯的组件接口。
8
+ - **零配置**: 快速集成到 Svelte 项目中。
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ pnpm add svelte-sxo @sxo/ui @sxo/engine @sxo/design
14
+ ```
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var Y=Object.defineProperty;var A=(t,e,n)=>e in t?Y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $=(t,e,n)=>A(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@sxo/ui"),v=require("svelte");function y(){}function B(t,e){for(const n in e)t[n]=e[n];return t}function M(t){return t()}function O(){return Object.create(null)}function g(t){t.forEach(M)}function N(t){return typeof t=="function"}function L(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function R(t){return Object.keys(t).length===0}function U(t,e,n,r){if(t){const o=q(t,e,n,r);return t[0](o)}}function q(t,e,n,r){return t[1]&&r?B(n.ctx.slice(),t[1](r(e))):n.ctx}function V(t,e,n,r){return t[2],e.dirty}function z(t,e,n,r,o,u){if(o){const f=q(e,n,r,u);t.p(f,o)}}function D(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let r=0;r<n;r++)e[r]=-1;return e}return-1}function F(t){t.parentNode&&t.parentNode.removeChild(t)}function G(t){return Array.from(t.childNodes)}let E;function d(t){E=t}const l=[],j=[];let a=[];const P=[],J=Promise.resolve();let x=!1;function Q(){x||(x=!0,J.then(H))}function b(t){a.push(t)}const p=new Set;let i=0;function H(){if(i!==0)return;const t=E;do{try{for(;i<l.length;){const e=l[i];i++,d(e),W(e.$$)}}catch(e){throw l.length=0,i=0,e}for(d(null),l.length=0,i=0;j.length;)j.pop()();for(let e=0;e<a.length;e+=1){const n=a[e];p.has(n)||(p.add(n),n())}a.length=0}while(l.length);for(;P.length;)P.pop()();x=!1,p.clear(),d(t)}function W(t){if(t.fragment!==null){t.update(),g(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(b)}}function X(t){const e=[],n=[];a.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),a=e}const m=new Set;let Z;function I(t,e){t&&t.i&&(m.delete(t),t.i(e))}function tt(t,e,n,r){if(t&&t.o){if(m.has(t))return;m.add(t),Z.c.push(()=>{m.delete(t)}),t.o(e)}}function et(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),b(()=>{const u=t.$$.on_mount.map(M).filter(N);t.$$.on_destroy?t.$$.on_destroy.push(...u):g(u),t.$$.on_mount=[]}),o.forEach(b)}function nt(t,e){const n=t.$$;n.fragment!==null&&(X(n.after_update),g(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function rt(t,e){t.$$.dirty[0]===-1&&(l.push(t),Q(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function ot(t,e,n,r,o,u,f=null,h=[-1]){const _=E;d(t);const s=t.$$={fragment:null,ctx:[],props:u,update:y,not_equal:o,bound:O(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(_?_.$$.context:[])),callbacks:O(),dirty:h,skip_bound:!1,root:e.target||_.$$.root};f&&f(s.root);let T=!1;if(s.ctx=n?n(t,e.props||{},(c,k,...S)=>{const C=S.length?S[0]:k;return s.ctx&&o(s.ctx[c],s.ctx[c]=C)&&(!s.skip_bound&&s.bound[c]&&s.bound[c](C),T&&rt(t,c)),k}):[],s.update(),T=!0,g(s.before_update),s.fragment=r?r(s.ctx):!1,e.target){if(e.hydrate){const c=G(e.target);s.fragment&&s.fragment.l(c),c.forEach(F)}else s.fragment&&s.fragment.c();e.intro&&I(t.$$.fragment),et(t,e.target,e.anchor),H()}d(_)}class st{constructor(){$(this,"$$");$(this,"$$set")}$destroy(){nt(this,1),this.$destroy=y}$on(e,n){if(!N(n))return y;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!R(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const ut="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ut);function ct(t){let e;const n=t[2].default,r=U(n,t,t[1],null);return{c(){r&&r.c()},m(o,u){r&&r.m(o,u),e=!0},p(o,[u]){r&&r.p&&(!e||u&2)&&z(r,n,o,o[1],e?V(n,o[1],u,null):D(o[1]),null)},i(o){e||(I(r,o),e=!0)},o(o){tt(r,o),e=!1},d(o){r&&r.d(o)}}}function ft(t,e,n){let{$$slots:r={},$$scope:o}=e;const u=Symbol("sxo-theme"),f=w.defaultTheme;return v.setContext(u,f),t.$$set=h=>{"$$scope"in h&&n(1,o=h.$$scope)},[f,o,r]}class it extends st{constructor(e){super(),ot(this,e,ft,ct,L,{theme:0})}get theme(){return this.$$.ctx[0]}}const K=Symbol("sxo-theme");function lt(t=w.defaultTheme){v.setContext(K,t)}function at(){return v.getContext(K)||w.defaultTheme}exports.ThemeProvider=it;exports.setTheme=lt;exports.useTheme=at;
@@ -0,0 +1,4 @@
1
+ import { ThemeContext } from '../../../packages/ui/src';
2
+ export declare function setTheme(theme?: ThemeContext): void;
3
+ export declare function useTheme(): ThemeContext;
4
+ export { default as ThemeProvider } from './ThemeProvider.svelte';
package/dist/index.js ADDED
@@ -0,0 +1,308 @@
1
+ var A = Object.defineProperty;
2
+ var B = (t, e, n) => e in t ? A(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var g = (t, e, n) => B(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { defaultTheme as w } from "@sxo/ui";
5
+ import { setContext as N, getContext as L } from "svelte";
6
+ function y() {
7
+ }
8
+ function R(t, e) {
9
+ for (const n in e) t[n] = e[n];
10
+ return (
11
+ /** @type {T & S} */
12
+ t
13
+ );
14
+ }
15
+ function M(t) {
16
+ return t();
17
+ }
18
+ function C() {
19
+ return /* @__PURE__ */ Object.create(null);
20
+ }
21
+ function $(t) {
22
+ t.forEach(M);
23
+ }
24
+ function P(t) {
25
+ return typeof t == "function";
26
+ }
27
+ function U(t, e) {
28
+ return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
29
+ }
30
+ function V(t) {
31
+ return Object.keys(t).length === 0;
32
+ }
33
+ function q(t, e, n, r) {
34
+ if (t) {
35
+ const o = H(t, e, n, r);
36
+ return t[0](o);
37
+ }
38
+ }
39
+ function H(t, e, n, r) {
40
+ return t[1] && r ? R(n.ctx.slice(), t[1](r(e))) : n.ctx;
41
+ }
42
+ function z(t, e, n, r) {
43
+ return t[2], e.dirty;
44
+ }
45
+ function D(t, e, n, r, o, u) {
46
+ if (o) {
47
+ const c = H(e, n, r, u);
48
+ t.p(c, o);
49
+ }
50
+ }
51
+ function F(t) {
52
+ if (t.ctx.length > 32) {
53
+ const e = [], n = t.ctx.length / 32;
54
+ for (let r = 0; r < n; r++)
55
+ e[r] = -1;
56
+ return e;
57
+ }
58
+ return -1;
59
+ }
60
+ function G(t) {
61
+ t.parentNode && t.parentNode.removeChild(t);
62
+ }
63
+ function J(t) {
64
+ return Array.from(t.childNodes);
65
+ }
66
+ let E;
67
+ function d(t) {
68
+ E = t;
69
+ }
70
+ const l = [], O = [];
71
+ let a = [];
72
+ const j = [], Q = /* @__PURE__ */ Promise.resolve();
73
+ let x = !1;
74
+ function W() {
75
+ x || (x = !0, Q.then(I));
76
+ }
77
+ function b(t) {
78
+ a.push(t);
79
+ }
80
+ const p = /* @__PURE__ */ new Set();
81
+ let i = 0;
82
+ function I() {
83
+ if (i !== 0)
84
+ return;
85
+ const t = E;
86
+ do {
87
+ try {
88
+ for (; i < l.length; ) {
89
+ const e = l[i];
90
+ i++, d(e), X(e.$$);
91
+ }
92
+ } catch (e) {
93
+ throw l.length = 0, i = 0, e;
94
+ }
95
+ for (d(null), l.length = 0, i = 0; O.length; ) O.pop()();
96
+ for (let e = 0; e < a.length; e += 1) {
97
+ const n = a[e];
98
+ p.has(n) || (p.add(n), n());
99
+ }
100
+ a.length = 0;
101
+ } while (l.length);
102
+ for (; j.length; )
103
+ j.pop()();
104
+ x = !1, p.clear(), d(t);
105
+ }
106
+ function X(t) {
107
+ if (t.fragment !== null) {
108
+ t.update(), $(t.before_update);
109
+ const e = t.dirty;
110
+ t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(b);
111
+ }
112
+ }
113
+ function Z(t) {
114
+ const e = [], n = [];
115
+ a.forEach((r) => t.indexOf(r) === -1 ? e.push(r) : n.push(r)), n.forEach((r) => r()), a = e;
116
+ }
117
+ const m = /* @__PURE__ */ new Set();
118
+ let tt;
119
+ function K(t, e) {
120
+ t && t.i && (m.delete(t), t.i(e));
121
+ }
122
+ function et(t, e, n, r) {
123
+ if (t && t.o) {
124
+ if (m.has(t)) return;
125
+ m.add(t), tt.c.push(() => {
126
+ m.delete(t);
127
+ }), t.o(e);
128
+ }
129
+ }
130
+ function nt(t, e, n) {
131
+ const { fragment: r, after_update: o } = t.$$;
132
+ r && r.m(e, n), b(() => {
133
+ const u = t.$$.on_mount.map(M).filter(P);
134
+ t.$$.on_destroy ? t.$$.on_destroy.push(...u) : $(u), t.$$.on_mount = [];
135
+ }), o.forEach(b);
136
+ }
137
+ function rt(t, e) {
138
+ const n = t.$$;
139
+ n.fragment !== null && (Z(n.after_update), $(n.on_destroy), n.fragment && n.fragment.d(e), n.on_destroy = n.fragment = null, n.ctx = []);
140
+ }
141
+ function ot(t, e) {
142
+ t.$$.dirty[0] === -1 && (l.push(t), W(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31;
143
+ }
144
+ function st(t, e, n, r, o, u, c = null, _ = [-1]) {
145
+ const h = E;
146
+ d(t);
147
+ const s = t.$$ = {
148
+ fragment: null,
149
+ ctx: [],
150
+ // state
151
+ props: u,
152
+ update: y,
153
+ not_equal: o,
154
+ bound: C(),
155
+ // lifecycle
156
+ on_mount: [],
157
+ on_destroy: [],
158
+ on_disconnect: [],
159
+ before_update: [],
160
+ after_update: [],
161
+ context: new Map(e.context || (h ? h.$$.context : [])),
162
+ // everything else
163
+ callbacks: C(),
164
+ dirty: _,
165
+ skip_bound: !1,
166
+ root: e.target || h.$$.root
167
+ };
168
+ c && c(s.root);
169
+ let v = !1;
170
+ if (s.ctx = n ? n(t, e.props || {}, (f, k, ...S) => {
171
+ const T = S.length ? S[0] : k;
172
+ return s.ctx && o(s.ctx[f], s.ctx[f] = T) && (!s.skip_bound && s.bound[f] && s.bound[f](T), v && ot(t, f)), k;
173
+ }) : [], s.update(), v = !0, $(s.before_update), s.fragment = r ? r(s.ctx) : !1, e.target) {
174
+ if (e.hydrate) {
175
+ const f = J(e.target);
176
+ s.fragment && s.fragment.l(f), f.forEach(G);
177
+ } else
178
+ s.fragment && s.fragment.c();
179
+ e.intro && K(t.$$.fragment), nt(t, e.target, e.anchor), I();
180
+ }
181
+ d(h);
182
+ }
183
+ class ut {
184
+ constructor() {
185
+ /**
186
+ * ### PRIVATE API
187
+ *
188
+ * Do not use, may change at any time
189
+ *
190
+ * @type {any}
191
+ */
192
+ g(this, "$$");
193
+ /**
194
+ * ### PRIVATE API
195
+ *
196
+ * Do not use, may change at any time
197
+ *
198
+ * @type {any}
199
+ */
200
+ g(this, "$$set");
201
+ }
202
+ /** @returns {void} */
203
+ $destroy() {
204
+ rt(this, 1), this.$destroy = y;
205
+ }
206
+ /**
207
+ * @template {Extract<keyof Events, string>} K
208
+ * @param {K} type
209
+ * @param {((e: Events[K]) => void) | null | undefined} callback
210
+ * @returns {() => void}
211
+ */
212
+ $on(e, n) {
213
+ if (!P(n))
214
+ return y;
215
+ const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
216
+ return r.push(n), () => {
217
+ const o = r.indexOf(n);
218
+ o !== -1 && r.splice(o, 1);
219
+ };
220
+ }
221
+ /**
222
+ * @param {Partial<Props>} props
223
+ * @returns {void}
224
+ */
225
+ $set(e) {
226
+ this.$$set && !V(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
227
+ }
228
+ }
229
+ const ft = "4";
230
+ typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(ft);
231
+ function ct(t) {
232
+ let e;
233
+ const n = (
234
+ /*#slots*/
235
+ t[2].default
236
+ ), r = q(
237
+ n,
238
+ t,
239
+ /*$$scope*/
240
+ t[1],
241
+ null
242
+ );
243
+ return {
244
+ c() {
245
+ r && r.c();
246
+ },
247
+ m(o, u) {
248
+ r && r.m(o, u), e = !0;
249
+ },
250
+ p(o, [u]) {
251
+ r && r.p && (!e || u & /*$$scope*/
252
+ 2) && D(
253
+ r,
254
+ n,
255
+ o,
256
+ /*$$scope*/
257
+ o[1],
258
+ e ? z(
259
+ n,
260
+ /*$$scope*/
261
+ o[1],
262
+ u,
263
+ null
264
+ ) : F(
265
+ /*$$scope*/
266
+ o[1]
267
+ ),
268
+ null
269
+ );
270
+ },
271
+ i(o) {
272
+ e || (K(r, o), e = !0);
273
+ },
274
+ o(o) {
275
+ et(r, o), e = !1;
276
+ },
277
+ d(o) {
278
+ r && r.d(o);
279
+ }
280
+ };
281
+ }
282
+ function it(t, e, n) {
283
+ let { $$slots: r = {}, $$scope: o } = e;
284
+ const u = Symbol("sxo-theme"), c = w;
285
+ return N(u, c), t.$$set = (_) => {
286
+ "$$scope" in _ && n(1, o = _.$$scope);
287
+ }, [c, o, r];
288
+ }
289
+ class _t extends ut {
290
+ constructor(e) {
291
+ super(), st(this, e, it, ct, U, { theme: 0 });
292
+ }
293
+ get theme() {
294
+ return this.$$.ctx[0];
295
+ }
296
+ }
297
+ const Y = Symbol("sxo-theme");
298
+ function ht(t = w) {
299
+ N(Y, t);
300
+ }
301
+ function mt() {
302
+ return L(Y) || w;
303
+ }
304
+ export {
305
+ _t as ThemeProvider,
306
+ ht as setTheme,
307
+ mt as useTheme
308
+ };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "svelte-sxo",
3
+ "version": "0.0.0",
4
+ "description": "Svelte adaptor for SXO Design System.",
5
+ "keywords": [
6
+ "sxo",
7
+ "design-system",
8
+ "ui",
9
+ "components",
10
+ "svelte"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "sxo team",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "@sxo/ui": "0.0.0"
22
+ },
23
+ "peerDependencies": {
24
+ "svelte": "^4.0.0"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/doki-land/sxo-engine.git",
29
+ "directory": "adaptors/svelte-sxo"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/doki-land/sxo-engine/issues"
33
+ },
34
+ "homepage": "https://github.com/doki-land/sxo-engine/tree/main/adaptors/svelte-sxo#readme",
35
+ "svelte": "./dist/index.js",
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "import": "./dist/index.js",
43
+ "require": "./dist/index.cjs"
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
48
+ "svelte": "^4.2.20",
49
+ "typescript": "^5.0.0",
50
+ "vite": "^5.0.0",
51
+ "vite-plugin-dts": "^4.0.0"
52
+ },
53
+ "type": "module",
54
+ "scripts": {
55
+ "build": "vite build",
56
+ "dev": "vite build --watch"
57
+ }
58
+ }