@playcademy/sdk 0.1.12 → 0.1.13
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/dist/index.d.ts +8 -0
- package/dist/index.js +44 -0
- package/dist/types.d.ts +9 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3817,6 +3817,14 @@ declare class PlaycademyClient {
|
|
|
3817
3817
|
}) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
|
|
3818
3818
|
removeAllListeners: () => void;
|
|
3819
3819
|
getListenerCounts: () => Record<string, number>;
|
|
3820
|
+
cdn: {
|
|
3821
|
+
url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
|
|
3822
|
+
fetch: (path: string, options?: RequestInit) => Promise<Response>;
|
|
3823
|
+
json: <T = unknown>(path: string) => Promise<T>;
|
|
3824
|
+
blob: (path: string) => Promise<Blob>;
|
|
3825
|
+
text: (path: string) => Promise<string>;
|
|
3826
|
+
arrayBuffer: (path: string) => Promise<ArrayBuffer>;
|
|
3827
|
+
};
|
|
3820
3828
|
};
|
|
3821
3829
|
/** Game management methods (fetch, list, saveState, loadState, sessions) */
|
|
3822
3830
|
games: {
|
package/dist/index.js
CHANGED
|
@@ -839,6 +839,50 @@ function createRuntimeNamespace(client) {
|
|
|
839
839
|
counts[eventType] = handlers.size;
|
|
840
840
|
}
|
|
841
841
|
return counts;
|
|
842
|
+
},
|
|
843
|
+
cdn: {
|
|
844
|
+
url(pathOrStrings, ...values) {
|
|
845
|
+
const cdnBase = client["initPayload"]?.cdnBase;
|
|
846
|
+
let path;
|
|
847
|
+
if (Array.isArray(pathOrStrings) && "raw" in pathOrStrings) {
|
|
848
|
+
const strings = pathOrStrings;
|
|
849
|
+
path = strings.reduce((acc, str, i) => {
|
|
850
|
+
return acc + str + (values[i] != null ? String(values[i]) : "");
|
|
851
|
+
}, "");
|
|
852
|
+
} else {
|
|
853
|
+
path = pathOrStrings;
|
|
854
|
+
}
|
|
855
|
+
if (!cdnBase) {
|
|
856
|
+
return path.startsWith("./") ? path : "./" + path;
|
|
857
|
+
}
|
|
858
|
+
const cleanPath = path.startsWith("./") ? path.slice(2) : path;
|
|
859
|
+
return cdnBase + cleanPath;
|
|
860
|
+
},
|
|
861
|
+
fetch: async (path, options) => {
|
|
862
|
+
const cdnBase = client["initPayload"]?.cdnBase;
|
|
863
|
+
if (!cdnBase) {
|
|
864
|
+
const relativePath = path.startsWith("./") ? path : "./" + path;
|
|
865
|
+
return fetch(relativePath, options);
|
|
866
|
+
}
|
|
867
|
+
const cleanPath = path.startsWith("./") ? path.slice(2) : path;
|
|
868
|
+
return fetch(cdnBase + cleanPath, options);
|
|
869
|
+
},
|
|
870
|
+
json: async (path) => {
|
|
871
|
+
const response = await client.runtime.cdn.fetch(path);
|
|
872
|
+
return response.json();
|
|
873
|
+
},
|
|
874
|
+
blob: async (path) => {
|
|
875
|
+
const response = await client.runtime.cdn.fetch(path);
|
|
876
|
+
return response.blob();
|
|
877
|
+
},
|
|
878
|
+
text: async (path) => {
|
|
879
|
+
const response = await client.runtime.cdn.fetch(path);
|
|
880
|
+
return response.text();
|
|
881
|
+
},
|
|
882
|
+
arrayBuffer: async (path) => {
|
|
883
|
+
const response = await client.runtime.cdn.fetch(path);
|
|
884
|
+
return response.arrayBuffer();
|
|
885
|
+
}
|
|
842
886
|
}
|
|
843
887
|
};
|
|
844
888
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -4496,6 +4496,14 @@ declare class PlaycademyClient {
|
|
|
4496
4496
|
}) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
|
|
4497
4497
|
removeAllListeners: () => void;
|
|
4498
4498
|
getListenerCounts: () => Record<string, number>;
|
|
4499
|
+
cdn: {
|
|
4500
|
+
url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
|
|
4501
|
+
fetch: (path: string, options?: RequestInit) => Promise<Response>;
|
|
4502
|
+
json: <T = unknown>(path: string) => Promise<T>;
|
|
4503
|
+
blob: (path: string) => Promise<Blob>;
|
|
4504
|
+
text: (path: string) => Promise<string>;
|
|
4505
|
+
arrayBuffer: (path: string) => Promise<ArrayBuffer>;
|
|
4506
|
+
};
|
|
4499
4507
|
};
|
|
4500
4508
|
/** Game management methods (fetch, list, saveState, loadState, sessions) */
|
|
4501
4509
|
games: {
|
|
@@ -4922,6 +4930,7 @@ interface InitPayload {
|
|
|
4922
4930
|
token: string;
|
|
4923
4931
|
gameId: string;
|
|
4924
4932
|
realtimeUrl?: string;
|
|
4933
|
+
cdnBase?: string;
|
|
4925
4934
|
}
|
|
4926
4935
|
type AuthProviderType = (typeof AUTH_PROVIDER_IDS)[keyof typeof AUTH_PROVIDER_IDS];
|
|
4927
4936
|
interface AuthOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@playcademy/constants": "0.0.1",
|
|
38
38
|
"@playcademy/data": "0.0.1",
|
|
39
39
|
"@playcademy/logger": "0.0.1",
|
|
40
|
-
"@playcademy/sandbox": "0.1.
|
|
40
|
+
"@playcademy/sandbox": "0.1.9",
|
|
41
41
|
"@playcademy/test": "0.0.1",
|
|
42
42
|
"@playcademy/timeback": "0.0.1",
|
|
43
43
|
"@playcademy/utils": "0.0.1",
|
|
44
44
|
"@types/bun": "latest",
|
|
45
|
-
"playcademy": "0.
|
|
45
|
+
"playcademy": "0.14.2",
|
|
46
46
|
"rollup": "^4.50.2",
|
|
47
47
|
"rollup-plugin-dts": "^6.2.3",
|
|
48
48
|
"typescript": "^5.7.2",
|