@localess/js-client 0.1.0 → 0.2.1-next.20241219-223225.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 CHANGED
@@ -26,7 +26,7 @@ npm install @localess/js-client@latest
26
26
  yarn add @localess/js-client@latest
27
27
  ````
28
28
 
29
- ## Usage
29
+ ## Client
30
30
 
31
31
  ````ts
32
32
  import {localessClient} from "@localess/js-client";
@@ -50,6 +50,17 @@ llClient.getContentById('FRnIT7CUABoRCdSVVGGs')
50
50
  llClient.getTranslations('en')
51
51
  ````
52
52
 
53
+ ## Sync with Visual Editor
54
+
55
+ It will automatically inject Localess Sync Script in to HTML page.
56
+
57
+ ````ts
58
+ import {loadLocalessSync} from "@localess/js-client";
59
+
60
+ // A fully qualified domain name with protocol (http/https) and port.
61
+ loadLocalessSync('https://my-localess.web.app')
62
+ ````
63
+
53
64
  ## Proxy
54
65
 
55
66
  If you are behind a proxy, make sure to set the environment variables before using the client.
@@ -0,0 +1,88 @@
1
+ import { Content, ContentAsset, Links, Translations } from "./models";
2
+ export type LocalessClientOptions = {
3
+ /**
4
+ * A fully qualified domain name with protocol (http/https) and port.
5
+ *
6
+ * Example: https://my-localess.web.app
7
+ */
8
+ origin: string;
9
+ /**
10
+ * Localess space ID, cna be found in the Localess Space settings
11
+ */
12
+ spaceId: string;
13
+ /**
14
+ * Localess API token, can be found in the Localess Space settings
15
+ */
16
+ token: string;
17
+ /**
18
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
19
+ */
20
+ version?: 'draft' | string;
21
+ /**
22
+ * Enable debug mode
23
+ */
24
+ debug?: boolean;
25
+ };
26
+ export type LinksFetchParams = {
27
+ /**
28
+ * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
29
+ * @example 'DOCUMENT'
30
+ */
31
+ kind?: 'DOCUMENT' | 'FOLDER';
32
+ /**
33
+ * Content parent slug.
34
+ * @example 'legal/policy'
35
+ */
36
+ parentSlug?: string;
37
+ /**
38
+ * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
39
+ * @example false
40
+ */
41
+ excludeChildren?: boolean;
42
+ };
43
+ export type ContentFetchParams = {
44
+ /**
45
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
46
+ * Overrides the version set in the client options.
47
+ */
48
+ version?: 'draft' | string;
49
+ /**
50
+ * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
51
+ *
52
+ * Example: en
53
+ */
54
+ locale?: string;
55
+ };
56
+ /**
57
+ * Create a Localess API Client
58
+ * @param {LocalessClientOptions} options connection details
59
+ */
60
+ export declare function localessClient(options: LocalessClientOptions): {
61
+ /**
62
+ * Get all links
63
+ * @param params{LinksFetchParams} - Fetch parameters
64
+ * @returns {Promise<Links>}
65
+ */
66
+ getLinks(params?: LinksFetchParams): Promise<Links>;
67
+ /**
68
+ * Get content by SLUG
69
+ * @param slug{string} - Content SLUG
70
+ * @param params{ContentFetchParams} - Fetch parameters
71
+ * @returns {Promise<Content>}
72
+ */
73
+ getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
74
+ /**
75
+ * Get content by ID
76
+ * @param id{string} - Content ID
77
+ * @param params{ContentFetchParams} - Fetch parameters
78
+ * @returns {Promise<Content>}
79
+ */
80
+ getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
81
+ /**
82
+ * Get translations for the given locale
83
+ * @param locale{string} - Locale identifier (ISO 639-1)
84
+ */
85
+ getTranslations(locale: string): Promise<Translations>;
86
+ syncScriptUrl(): string;
87
+ assetLink(asset: ContentAsset | string): string;
88
+ };
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.localessClient = void 0;
7
+ const utils_1 = require("./utils");
8
+ const node_fetch_1 = __importDefault(require("node-fetch"));
9
+ const proxy_agent_1 = require("proxy-agent");
10
+ const LOG_GROUP = `${utils_1.FG_BLUE}[Localess:Client]${utils_1.RESET}`;
11
+ /**
12
+ * Create a Localess API Client
13
+ * @param {LocalessClientOptions} options connection details
14
+ */
15
+ function localessClient(options) {
16
+ if (options.debug) {
17
+ console.log(LOG_GROUP, 'Client Options : ', options);
18
+ }
19
+ const fetchOptions = {
20
+ redirect: 'follow',
21
+ };
22
+ if ((0, utils_1.proxyURIFromEnv)()) {
23
+ if (options.debug) {
24
+ console.log(LOG_GROUP, 'Proxy Agent Enabled');
25
+ }
26
+ fetchOptions.agent = new proxy_agent_1.ProxyAgent();
27
+ }
28
+ return {
29
+ /**
30
+ * Get all links
31
+ * @param params{LinksFetchParams} - Fetch parameters
32
+ * @returns {Promise<Links>}
33
+ */
34
+ async getLinks(params) {
35
+ if (options.debug) {
36
+ console.log(LOG_GROUP, 'getLinks() params : ' + params);
37
+ }
38
+ let kind = '';
39
+ if (params?.kind) {
40
+ kind = `&kind=${params.kind}`;
41
+ }
42
+ let parentSlug = '';
43
+ if (params?.parentSlug) {
44
+ parentSlug = `&parentSlug=${params.parentSlug}`;
45
+ }
46
+ let excludeChildren = '';
47
+ if (params?.excludeChildren) {
48
+ excludeChildren = `&excludeChildren=${params.excludeChildren}`;
49
+ }
50
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}${kind}${parentSlug}${excludeChildren}`;
51
+ if (options.debug) {
52
+ console.log(LOG_GROUP, 'getLinks fetch url : ', url);
53
+ }
54
+ try {
55
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
56
+ if (options.debug) {
57
+ console.log(LOG_GROUP, 'getLinks status : ', response.status);
58
+ }
59
+ const data = await response.json();
60
+ return data;
61
+ }
62
+ catch (error) {
63
+ console.error(LOG_GROUP, 'getLinks error : ', error);
64
+ return {};
65
+ }
66
+ },
67
+ /**
68
+ * Get content by SLUG
69
+ * @param slug{string} - Content SLUG
70
+ * @param params{ContentFetchParams} - Fetch parameters
71
+ * @returns {Promise<Content>}
72
+ */
73
+ async getContentBySlug(slug, params) {
74
+ if (options.debug) {
75
+ console.log(LOG_GROUP, 'getContentBySlug() slug : ', slug);
76
+ console.log(LOG_GROUP, 'getContentBySlug() params : ', params);
77
+ }
78
+ let version = '';
79
+ // Options
80
+ if (options?.version && options.version == 'draft') {
81
+ version = `&version=${options.version}`;
82
+ }
83
+ // Params
84
+ if (params?.version && params.version == 'draft') {
85
+ version = `&version=${params.version}`;
86
+ }
87
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
88
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
89
+ if (options.debug) {
90
+ console.log(LOG_GROUP, 'getContentBySlug fetch url : ', url);
91
+ }
92
+ try {
93
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
94
+ if (options.debug) {
95
+ console.log(LOG_GROUP, 'getContentBySlug status : ', response.status);
96
+ }
97
+ const data = await response.json();
98
+ return data;
99
+ }
100
+ catch (error) {
101
+ console.error(LOG_GROUP, 'getContentBySlug error : ', error);
102
+ return {};
103
+ }
104
+ },
105
+ /**
106
+ * Get content by ID
107
+ * @param id{string} - Content ID
108
+ * @param params{ContentFetchParams} - Fetch parameters
109
+ * @returns {Promise<Content>}
110
+ */
111
+ async getContentById(id, params) {
112
+ if (options.debug) {
113
+ console.log(LOG_GROUP, 'getContentById() id : ', id);
114
+ console.log(LOG_GROUP, 'getContentById() params : ', params);
115
+ }
116
+ let version = '';
117
+ // Options
118
+ if (options?.version && options.version == 'draft') {
119
+ version = `&version=${options.version}`;
120
+ }
121
+ // Params
122
+ if (params?.version && params.version == 'draft') {
123
+ version = `&version=${params.version}`;
124
+ }
125
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
126
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
127
+ if (options.debug) {
128
+ console.log(LOG_GROUP, 'getContentById fetch url : ', url);
129
+ }
130
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
131
+ if (options.debug) {
132
+ console.log(LOG_GROUP, 'getContentById status : ', response.status);
133
+ }
134
+ const data = await response.json();
135
+ return data;
136
+ },
137
+ /**
138
+ * Get translations for the given locale
139
+ * @param locale{string} - Locale identifier (ISO 639-1)
140
+ */
141
+ async getTranslations(locale) {
142
+ if (options.debug) {
143
+ console.log(LOG_GROUP, 'getTranslations() locale : ', locale);
144
+ }
145
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
146
+ if (options.debug) {
147
+ console.log(LOG_GROUP, 'getTranslations fetch url : ', url);
148
+ }
149
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
150
+ if (options.debug) {
151
+ console.log(LOG_GROUP, 'getTranslations status : ', response.status);
152
+ }
153
+ const data = await response.json();
154
+ return data;
155
+ },
156
+ syncScriptUrl() {
157
+ return `${options.origin}/scripts/sync-v1.js`;
158
+ },
159
+ assetLink(asset) {
160
+ if (typeof asset === 'string') {
161
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
162
+ }
163
+ else {
164
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
165
+ }
166
+ }
167
+ };
168
+ }
169
+ exports.localessClient = localessClient;
170
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAwD;AACxD,4DAA8C;AAC9C,6CAAuC;AA4DvC,MAAM,SAAS,GAAG,GAAG,eAAO,oBAAoB,aAAK,EAAE,CAAA;AAEvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAA8B;IAC3D,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,YAAY,GAAgB;QAChC,QAAQ,EA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QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE,YAAY,CAAC,CAAA;YAC/C,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACvE,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAoB,CAAC;QAC9B,CAAC;QAED,aAAa;YACX,OAAO,GAAG,OAAO,CAAC,MAAM,qBAAqB,CAAA;QAC/C,CAAC;QAED,SAAS,CAAC,KAA4B;YACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,EAAE,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA7JD,wCA6JC"}
@@ -0,0 +1,7 @@
1
+ export type ContentDataSkeleton = {
2
+ _id: string;
3
+ schema: string;
4
+ };
5
+ export declare function llEditable(content: ContentDataSkeleton): {
6
+ 'data-ll-id': string;
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.llEditable = void 0;
4
+ function llEditable(content) {
5
+ return {
6
+ 'data-ll-id': content._id
7
+ };
8
+ }
9
+ exports.llEditable = llEditable;
10
+ //# sourceMappingURL=editable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editable.js","sourceRoot":"","sources":["../../src/editable.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,OAA4B;IACrD,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,GAAG;KAC1B,CAAA;AACH,CAAC;AAJD,gCAIC"}
@@ -1,88 +1,7 @@
1
- import { Content, ContentAsset, Links, Translations } from "./models";
2
1
  export * from './models';
3
- export type LocalessClientOptions = {
4
- /**
5
- * A fully qualified domain name with protocol (http/https) and port.
6
- *
7
- * Example: https://my-localess.web.app
8
- */
9
- origin: string;
10
- /**
11
- * Localess space ID, cna be found in the Localess Space settings
12
- */
13
- spaceId: string;
14
- /**
15
- * Localess API token, can be found in the Localess Space settings
16
- */
17
- token: string;
18
- /**
19
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
20
- */
21
- version?: 'draft' | string;
22
- /**
23
- * Enable debug mode
24
- */
25
- debug?: boolean;
26
- };
27
- export type LinksFetchParams = {
28
- /**
29
- * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
30
- * @example 'DOCUMENT'
31
- */
32
- kind?: 'DOCUMENT' | 'FOLDER';
33
- /**
34
- * Content parent slug.
35
- * @example 'legal/policy'
36
- */
37
- parentSlug?: string;
38
- /**
39
- * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
40
- * @example false
41
- */
42
- excludeChildren?: boolean;
43
- };
44
- export type ContentFetchParams = {
45
- /**
46
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
47
- * Overrides the version set in the client options.
48
- */
49
- version?: 'draft' | string;
50
- /**
51
- * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
52
- *
53
- * Example: en
54
- */
55
- locale?: string;
56
- };
57
- export declare function localessClient(options: LocalessClientOptions): {
58
- /**
59
- * Get all links
60
- * @param params{LinksFetchParams} - Fetch parameters
61
- * @returns {Promise<Links>}
62
- */
63
- getLinks(params?: LinksFetchParams): Promise<Links>;
64
- /**
65
- * Get content by SLUG
66
- * @param slug{string} - Content SLUG
67
- * @param params{ContentFetchParams} - Fetch parameters
68
- * @returns {Promise<Content>}
69
- */
70
- getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
71
- /**
72
- * Get content by ID
73
- * @param id{string} - Content ID
74
- * @param params{ContentFetchParams} - Fetch parameters
75
- * @returns {Promise<Content>}
76
- */
77
- getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
78
- /**
79
- * Get translations for the given locale
80
- * @param locale{string} - Locale identifier (ISO 639-1)
81
- */
82
- getTranslations(locale: string): Promise<Translations>;
83
- syncScriptUrl(): string;
84
- assetLink(asset: ContentAsset | string): string;
85
- };
2
+ export * from './client';
3
+ export * from './editable';
4
+ export * from './sync';
86
5
  declare global {
87
6
  type EventType = 'input' | 'save' | 'publish' | 'change';
88
7
  type EventCallback = (event: EventToApp) => void;
package/dist/cjs/index.js CHANGED
@@ -13,169 +13,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.localessClient = void 0;
21
- const proxy_agent_1 = require("proxy-agent");
22
- const node_fetch_1 = __importDefault(require("node-fetch"));
23
- const utils_1 = require("./utils");
24
17
  __exportStar(require("./models"), exports);
25
- const LOG_GROUP = `${utils_1.FG_BLUE}[Localess:Client]${utils_1.RESET}`;
26
- function localessClient(options) {
27
- if (options.debug) {
28
- console.log(LOG_GROUP, 'Client Options : ', options);
29
- }
30
- const fetchOptions = {
31
- redirect: 'follow',
32
- };
33
- if ((0, utils_1.proxyURIFromEnv)()) {
34
- if (options.debug) {
35
- console.log(LOG_GROUP, 'Proxy Agent Enabled');
36
- }
37
- fetchOptions.agent = new proxy_agent_1.ProxyAgent();
38
- }
39
- return {
40
- /**
41
- * Get all links
42
- * @param params{LinksFetchParams} - Fetch parameters
43
- * @returns {Promise<Links>}
44
- */
45
- async getLinks(params) {
46
- if (options.debug) {
47
- console.log(LOG_GROUP, 'getLinks() params : ' + params);
48
- }
49
- let kind = '';
50
- if (params?.kind) {
51
- kind = `&kind=${params.kind}`;
52
- }
53
- let parentSlug = '';
54
- if (params?.parentSlug) {
55
- parentSlug = `&parentSlug=${params.parentSlug}`;
56
- }
57
- let excludeChildren = '';
58
- if (params?.excludeChildren) {
59
- excludeChildren = `&excludeChildren=${params.excludeChildren}`;
60
- }
61
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}${kind}${parentSlug}${excludeChildren}`;
62
- if (options.debug) {
63
- console.log(LOG_GROUP, 'getLinks fetch url : ', url);
64
- }
65
- try {
66
- const response = await (0, node_fetch_1.default)(url, fetchOptions);
67
- if (options.debug) {
68
- console.log(LOG_GROUP, 'getLinks status : ', response.status);
69
- }
70
- const data = await response.json();
71
- return data;
72
- }
73
- catch (error) {
74
- console.error(LOG_GROUP, 'getLinks error : ', error);
75
- return {};
76
- }
77
- },
78
- /**
79
- * Get content by SLUG
80
- * @param slug{string} - Content SLUG
81
- * @param params{ContentFetchParams} - Fetch parameters
82
- * @returns {Promise<Content>}
83
- */
84
- async getContentBySlug(slug, params) {
85
- if (options.debug) {
86
- console.log(LOG_GROUP, 'getContentBySlug() slug : ', slug);
87
- console.log(LOG_GROUP, 'getContentBySlug() params : ', params);
88
- }
89
- let version = '';
90
- // Options
91
- if (options?.version && options.version == 'draft') {
92
- version = `&version=${options.version}`;
93
- }
94
- // Params
95
- if (params?.version && params.version == 'draft') {
96
- version = `&version=${params.version}`;
97
- }
98
- const locale = params?.locale ? `&locale=${params.locale}` : '';
99
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
100
- if (options.debug) {
101
- console.log(LOG_GROUP, 'getContentBySlug fetch url : ', url);
102
- }
103
- try {
104
- const response = await (0, node_fetch_1.default)(url, fetchOptions);
105
- if (options.debug) {
106
- console.log(LOG_GROUP, 'getContentBySlug status : ', response.status);
107
- }
108
- const data = await response.json();
109
- return data;
110
- }
111
- catch (error) {
112
- console.error(LOG_GROUP, 'getContentBySlug error : ', error);
113
- return {};
114
- }
115
- },
116
- /**
117
- * Get content by ID
118
- * @param id{string} - Content ID
119
- * @param params{ContentFetchParams} - Fetch parameters
120
- * @returns {Promise<Content>}
121
- */
122
- async getContentById(id, params) {
123
- if (options.debug) {
124
- console.log(LOG_GROUP, 'getContentById() id : ', id);
125
- console.log(LOG_GROUP, 'getContentById() params : ', params);
126
- }
127
- let version = '';
128
- // Options
129
- if (options?.version && options.version == 'draft') {
130
- version = `&version=${options.version}`;
131
- }
132
- // Params
133
- if (params?.version && params.version == 'draft') {
134
- version = `&version=${params.version}`;
135
- }
136
- const locale = params?.locale ? `&locale=${params.locale}` : '';
137
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
138
- if (options.debug) {
139
- console.log(LOG_GROUP, 'getContentById fetch url : ', url);
140
- }
141
- const response = await (0, node_fetch_1.default)(url, fetchOptions);
142
- if (options.debug) {
143
- console.log(LOG_GROUP, 'getContentById status : ', response.status);
144
- }
145
- const data = await response.json();
146
- return data;
147
- },
148
- /**
149
- * Get translations for the given locale
150
- * @param locale{string} - Locale identifier (ISO 639-1)
151
- */
152
- async getTranslations(locale) {
153
- if (options.debug) {
154
- console.log(LOG_GROUP, 'getTranslations() locale : ', locale);
155
- }
156
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
157
- if (options.debug) {
158
- console.log(LOG_GROUP, 'getTranslations fetch url : ', url);
159
- }
160
- const response = await (0, node_fetch_1.default)(url, fetchOptions);
161
- if (options.debug) {
162
- console.log(LOG_GROUP, 'getTranslations status : ', response.status);
163
- }
164
- const data = await response.json();
165
- return data;
166
- },
167
- syncScriptUrl() {
168
- return `${options.origin}/scripts/sync-v1.js`;
169
- },
170
- assetLink(asset) {
171
- if (typeof asset === 'string') {
172
- return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
173
- }
174
- else {
175
- return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
176
- }
177
- }
178
- };
179
- }
180
- exports.localessClient = localessClient;
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./editable"), exports);
20
+ __exportStar(require("./sync"), exports);
181
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,6CAAuC;AACvC,4DAA8C;AAE9C,mCAAwD;AAExD,2CAAyB;AA2DzB,MAAM,SAAS,GAAG,GAAG,eAAO,oBAAoB,aAAK,EAAE,CAAA;AAEvD,SAAgB,cAAc,CAAC,OAA8B;IAC3D,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,YAAY,GAAgB;QAChC,QAAQ,EAAE,QAAQ;KACnB,CAAC;IACF,IAAI,IAAA,uBAAe,GAAE,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;QAChD,CAAC;QACD,YAAY,CAAC,KAAK,GAAG,IAAI,wBAAU,EAAE,CAAC;IACxC,CAAC;IAED,OAAO;QAEL;;;;WAIG;QACH,KAAK,CAAC,QAAQ,CAAC,MAAyB;YACtC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,sBAAsB,GAAG,MAAM,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;gBACjB,IAAI,GAAG,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC;YAChC,CAAC;Y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AAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA7JD,wCA6JC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B;AAC3B,yCAAuB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Inject Localess Sync Script in Header
3
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
4
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
5
+ */
6
+ export declare function loadLocalessSync(origin: string, force?: boolean): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadLocalessSync = void 0;
4
+ const JS_SYNC_ID = 'localess-js-sync';
5
+ /**
6
+ * Inject Localess Sync Script in Header
7
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
8
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
9
+ */
10
+ function loadLocalessSync(origin, force = false) {
11
+ const isServer = typeof window === 'undefined';
12
+ if (isServer)
13
+ return; // Skip Server Injection
14
+ if (window.top === window.self)
15
+ return; // Skip if the page is not loaded in Visual Editor
16
+ const isSyncLoaded = typeof window.localess !== 'undefined';
17
+ if (isSyncLoaded)
18
+ return; // Skip if Sync is already loaded
19
+ const scriptEl = document.getElementById(JS_SYNC_ID);
20
+ if (scriptEl)
21
+ return; // Skip if script is already loaded
22
+ const script = document.createElement('script');
23
+ script.id = JS_SYNC_ID;
24
+ script.type = 'text/javascript';
25
+ script.src = `${origin}/scripts/sync-v1.js`;
26
+ script.async = true;
27
+ script.onerror = (error) => console.error(error);
28
+ script.onload = (event) => console.info('Localess Sync Script loaded');
29
+ document.head.appendChild(script);
30
+ }
31
+ exports.loadLocalessSync = loadLocalessSync;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translations } from "./models";
2
+ export type LocalessClientOptions = {
3
+ /**
4
+ * A fully qualified domain name with protocol (http/https) and port.
5
+ *
6
+ * Example: https://my-localess.web.app
7
+ */
8
+ origin: string;
9
+ /**
10
+ * Localess space ID, cna be found in the Localess Space settings
11
+ */
12
+ spaceId: string;
13
+ /**
14
+ * Localess API token, can be found in the Localess Space settings
15
+ */
16
+ token: string;
17
+ /**
18
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
19
+ */
20
+ version?: 'draft' | string;
21
+ /**
22
+ * Enable debug mode
23
+ */
24
+ debug?: boolean;
25
+ };
26
+ export type LinksFetchParams = {
27
+ /**
28
+ * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
29
+ * @example 'DOCUMENT'
30
+ */
31
+ kind?: 'DOCUMENT' | 'FOLDER';
32
+ /**
33
+ * Content parent slug.
34
+ * @example 'legal/policy'
35
+ */
36
+ parentSlug?: string;
37
+ /**
38
+ * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
39
+ * @example false
40
+ */
41
+ excludeChildren?: boolean;
42
+ };
43
+ export type ContentFetchParams = {
44
+ /**
45
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
46
+ * Overrides the version set in the client options.
47
+ */
48
+ version?: 'draft' | string;
49
+ /**
50
+ * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
51
+ *
52
+ * Example: en
53
+ */
54
+ locale?: string;
55
+ };
56
+ /**
57
+ * Create a Localess API Client
58
+ * @param {LocalessClientOptions} options connection details
59
+ */
60
+ export declare function localessClient(options: LocalessClientOptions): {
61
+ /**
62
+ * Get all links
63
+ * @param params{LinksFetchParams} - Fetch parameters
64
+ * @returns {Promise<Links>}
65
+ */
66
+ getLinks(params?: LinksFetchParams): Promise<Links>;
67
+ /**
68
+ * Get content by SLUG
69
+ * @param slug{string} - Content SLUG
70
+ * @param params{ContentFetchParams} - Fetch parameters
71
+ * @returns {Promise<Content>}
72
+ */
73
+ getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
74
+ /**
75
+ * Get content by ID
76
+ * @param id{string} - Content ID
77
+ * @param params{ContentFetchParams} - Fetch parameters
78
+ * @returns {Promise<Content>}
79
+ */
80
+ getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
81
+ /**
82
+ * Get translations for the given locale
83
+ * @param locale{string} - Locale identifier (ISO 639-1)
84
+ */
85
+ getTranslations(locale: string): Promise<Translations>;
86
+ syncScriptUrl(): string;
87
+ assetLink(asset: ContentAsset | string): string;
88
+ };
package/dist/client.js ADDED
@@ -0,0 +1,163 @@
1
+ import { FG_BLUE, proxyURIFromEnv, RESET } from "./utils";
2
+ import fetch from "node-fetch";
3
+ import { ProxyAgent } from "proxy-agent";
4
+ const LOG_GROUP = `${FG_BLUE}[Localess:Client]${RESET}`;
5
+ /**
6
+ * Create a Localess API Client
7
+ * @param {LocalessClientOptions} options connection details
8
+ */
9
+ export function localessClient(options) {
10
+ if (options.debug) {
11
+ console.log(LOG_GROUP, 'Client Options : ', options);
12
+ }
13
+ const fetchOptions = {
14
+ redirect: 'follow',
15
+ };
16
+ if (proxyURIFromEnv()) {
17
+ if (options.debug) {
18
+ console.log(LOG_GROUP, 'Proxy Agent Enabled');
19
+ }
20
+ fetchOptions.agent = new ProxyAgent();
21
+ }
22
+ return {
23
+ /**
24
+ * Get all links
25
+ * @param params{LinksFetchParams} - Fetch parameters
26
+ * @returns {Promise<Links>}
27
+ */
28
+ async getLinks(params) {
29
+ if (options.debug) {
30
+ console.log(LOG_GROUP, 'getLinks() params : ' + params);
31
+ }
32
+ let kind = '';
33
+ if (params?.kind) {
34
+ kind = `&kind=${params.kind}`;
35
+ }
36
+ let parentSlug = '';
37
+ if (params?.parentSlug) {
38
+ parentSlug = `&parentSlug=${params.parentSlug}`;
39
+ }
40
+ let excludeChildren = '';
41
+ if (params?.excludeChildren) {
42
+ excludeChildren = `&excludeChildren=${params.excludeChildren}`;
43
+ }
44
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}${kind}${parentSlug}${excludeChildren}`;
45
+ if (options.debug) {
46
+ console.log(LOG_GROUP, 'getLinks fetch url : ', url);
47
+ }
48
+ try {
49
+ const response = await fetch(url, fetchOptions);
50
+ if (options.debug) {
51
+ console.log(LOG_GROUP, 'getLinks status : ', response.status);
52
+ }
53
+ const data = await response.json();
54
+ return data;
55
+ }
56
+ catch (error) {
57
+ console.error(LOG_GROUP, 'getLinks error : ', error);
58
+ return {};
59
+ }
60
+ },
61
+ /**
62
+ * Get content by SLUG
63
+ * @param slug{string} - Content SLUG
64
+ * @param params{ContentFetchParams} - Fetch parameters
65
+ * @returns {Promise<Content>}
66
+ */
67
+ async getContentBySlug(slug, params) {
68
+ if (options.debug) {
69
+ console.log(LOG_GROUP, 'getContentBySlug() slug : ', slug);
70
+ console.log(LOG_GROUP, 'getContentBySlug() params : ', params);
71
+ }
72
+ let version = '';
73
+ // Options
74
+ if (options?.version && options.version == 'draft') {
75
+ version = `&version=${options.version}`;
76
+ }
77
+ // Params
78
+ if (params?.version && params.version == 'draft') {
79
+ version = `&version=${params.version}`;
80
+ }
81
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
82
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
83
+ if (options.debug) {
84
+ console.log(LOG_GROUP, 'getContentBySlug fetch url : ', url);
85
+ }
86
+ try {
87
+ const response = await fetch(url, fetchOptions);
88
+ if (options.debug) {
89
+ console.log(LOG_GROUP, 'getContentBySlug status : ', response.status);
90
+ }
91
+ const data = await response.json();
92
+ return data;
93
+ }
94
+ catch (error) {
95
+ console.error(LOG_GROUP, 'getContentBySlug error : ', error);
96
+ return {};
97
+ }
98
+ },
99
+ /**
100
+ * Get content by ID
101
+ * @param id{string} - Content ID
102
+ * @param params{ContentFetchParams} - Fetch parameters
103
+ * @returns {Promise<Content>}
104
+ */
105
+ async getContentById(id, params) {
106
+ if (options.debug) {
107
+ console.log(LOG_GROUP, 'getContentById() id : ', id);
108
+ console.log(LOG_GROUP, 'getContentById() params : ', params);
109
+ }
110
+ let version = '';
111
+ // Options
112
+ if (options?.version && options.version == 'draft') {
113
+ version = `&version=${options.version}`;
114
+ }
115
+ // Params
116
+ if (params?.version && params.version == 'draft') {
117
+ version = `&version=${params.version}`;
118
+ }
119
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
120
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
121
+ if (options.debug) {
122
+ console.log(LOG_GROUP, 'getContentById fetch url : ', url);
123
+ }
124
+ const response = await fetch(url, fetchOptions);
125
+ if (options.debug) {
126
+ console.log(LOG_GROUP, 'getContentById status : ', response.status);
127
+ }
128
+ const data = await response.json();
129
+ return data;
130
+ },
131
+ /**
132
+ * Get translations for the given locale
133
+ * @param locale{string} - Locale identifier (ISO 639-1)
134
+ */
135
+ async getTranslations(locale) {
136
+ if (options.debug) {
137
+ console.log(LOG_GROUP, 'getTranslations() locale : ', locale);
138
+ }
139
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
140
+ if (options.debug) {
141
+ console.log(LOG_GROUP, 'getTranslations fetch url : ', url);
142
+ }
143
+ const response = await fetch(url, fetchOptions);
144
+ if (options.debug) {
145
+ console.log(LOG_GROUP, 'getTranslations status : ', response.status);
146
+ }
147
+ const data = await response.json();
148
+ return data;
149
+ },
150
+ syncScriptUrl() {
151
+ return `${options.origin}/scripts/sync-v1.js`;
152
+ },
153
+ assetLink(asset) {
154
+ if (typeof asset === 'string') {
155
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
156
+ }
157
+ else {
158
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
159
+ }
160
+ }
161
+ };
162
+ }
163
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[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ataSkeleton): {
6
+ 'data-ll-id': string;
7
+ };
@@ -0,0 +1,6 @@
1
+ export function llEditable(content) {
2
+ return {
3
+ 'data-ll-id': content._id
4
+ };
5
+ }
6
+ //# sourceMappingURL=editable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editable.js","sourceRoot":"","sources":["../src/editable.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,OAA4B;IACrD,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,GAAG;KAC1B,CAAA;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,88 +1,7 @@
1
- import { Content, ContentAsset, Links, Translations } from "./models";
2
1
  export * from './models';
3
- export type LocalessClientOptions = {
4
- /**
5
- * A fully qualified domain name with protocol (http/https) and port.
6
- *
7
- * Example: https://my-localess.web.app
8
- */
9
- origin: string;
10
- /**
11
- * Localess space ID, cna be found in the Localess Space settings
12
- */
13
- spaceId: string;
14
- /**
15
- * Localess API token, can be found in the Localess Space settings
16
- */
17
- token: string;
18
- /**
19
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
20
- */
21
- version?: 'draft' | string;
22
- /**
23
- * Enable debug mode
24
- */
25
- debug?: boolean;
26
- };
27
- export type LinksFetchParams = {
28
- /**
29
- * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
30
- * @example 'DOCUMENT'
31
- */
32
- kind?: 'DOCUMENT' | 'FOLDER';
33
- /**
34
- * Content parent slug.
35
- * @example 'legal/policy'
36
- */
37
- parentSlug?: string;
38
- /**
39
- * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
40
- * @example false
41
- */
42
- excludeChildren?: boolean;
43
- };
44
- export type ContentFetchParams = {
45
- /**
46
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
47
- * Overrides the version set in the client options.
48
- */
49
- version?: 'draft' | string;
50
- /**
51
- * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
52
- *
53
- * Example: en
54
- */
55
- locale?: string;
56
- };
57
- export declare function localessClient(options: LocalessClientOptions): {
58
- /**
59
- * Get all links
60
- * @param params{LinksFetchParams} - Fetch parameters
61
- * @returns {Promise<Links>}
62
- */
63
- getLinks(params?: LinksFetchParams): Promise<Links>;
64
- /**
65
- * Get content by SLUG
66
- * @param slug{string} - Content SLUG
67
- * @param params{ContentFetchParams} - Fetch parameters
68
- * @returns {Promise<Content>}
69
- */
70
- getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
71
- /**
72
- * Get content by ID
73
- * @param id{string} - Content ID
74
- * @param params{ContentFetchParams} - Fetch parameters
75
- * @returns {Promise<Content>}
76
- */
77
- getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
78
- /**
79
- * Get translations for the given locale
80
- * @param locale{string} - Locale identifier (ISO 639-1)
81
- */
82
- getTranslations(locale: string): Promise<Translations>;
83
- syncScriptUrl(): string;
84
- assetLink(asset: ContentAsset | string): string;
85
- };
2
+ export * from './client';
3
+ export * from './editable';
4
+ export * from './sync';
86
5
  declare global {
87
6
  type EventType = 'input' | 'save' | 'publish' | 'change';
88
7
  type EventCallback = (event: EventToApp) => void;
package/dist/index.js CHANGED
@@ -1,160 +1,5 @@
1
- import { ProxyAgent } from 'proxy-agent';
2
- import fetch from 'node-fetch';
3
- import { FG_BLUE, proxyURIFromEnv, RESET } from "./utils";
4
1
  export * from './models';
5
- const LOG_GROUP = `${FG_BLUE}[Localess:Client]${RESET}`;
6
- export function localessClient(options) {
7
- if (options.debug) {
8
- console.log(LOG_GROUP, 'Client Options : ', options);
9
- }
10
- const fetchOptions = {
11
- redirect: 'follow',
12
- };
13
- if (proxyURIFromEnv()) {
14
- if (options.debug) {
15
- console.log(LOG_GROUP, 'Proxy Agent Enabled');
16
- }
17
- fetchOptions.agent = new ProxyAgent();
18
- }
19
- return {
20
- /**
21
- * Get all links
22
- * @param params{LinksFetchParams} - Fetch parameters
23
- * @returns {Promise<Links>}
24
- */
25
- async getLinks(params) {
26
- if (options.debug) {
27
- console.log(LOG_GROUP, 'getLinks() params : ' + params);
28
- }
29
- let kind = '';
30
- if (params?.kind) {
31
- kind = `&kind=${params.kind}`;
32
- }
33
- let parentSlug = '';
34
- if (params?.parentSlug) {
35
- parentSlug = `&parentSlug=${params.parentSlug}`;
36
- }
37
- let excludeChildren = '';
38
- if (params?.excludeChildren) {
39
- excludeChildren = `&excludeChildren=${params.excludeChildren}`;
40
- }
41
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}${kind}${parentSlug}${excludeChildren}`;
42
- if (options.debug) {
43
- console.log(LOG_GROUP, 'getLinks fetch url : ', url);
44
- }
45
- try {
46
- const response = await fetch(url, fetchOptions);
47
- if (options.debug) {
48
- console.log(LOG_GROUP, 'getLinks status : ', response.status);
49
- }
50
- const data = await response.json();
51
- return data;
52
- }
53
- catch (error) {
54
- console.error(LOG_GROUP, 'getLinks error : ', error);
55
- return {};
56
- }
57
- },
58
- /**
59
- * Get content by SLUG
60
- * @param slug{string} - Content SLUG
61
- * @param params{ContentFetchParams} - Fetch parameters
62
- * @returns {Promise<Content>}
63
- */
64
- async getContentBySlug(slug, params) {
65
- if (options.debug) {
66
- console.log(LOG_GROUP, 'getContentBySlug() slug : ', slug);
67
- console.log(LOG_GROUP, 'getContentBySlug() params : ', params);
68
- }
69
- let version = '';
70
- // Options
71
- if (options?.version && options.version == 'draft') {
72
- version = `&version=${options.version}`;
73
- }
74
- // Params
75
- if (params?.version && params.version == 'draft') {
76
- version = `&version=${params.version}`;
77
- }
78
- const locale = params?.locale ? `&locale=${params.locale}` : '';
79
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
80
- if (options.debug) {
81
- console.log(LOG_GROUP, 'getContentBySlug fetch url : ', url);
82
- }
83
- try {
84
- const response = await fetch(url, fetchOptions);
85
- if (options.debug) {
86
- console.log(LOG_GROUP, 'getContentBySlug status : ', response.status);
87
- }
88
- const data = await response.json();
89
- return data;
90
- }
91
- catch (error) {
92
- console.error(LOG_GROUP, 'getContentBySlug error : ', error);
93
- return {};
94
- }
95
- },
96
- /**
97
- * Get content by ID
98
- * @param id{string} - Content ID
99
- * @param params{ContentFetchParams} - Fetch parameters
100
- * @returns {Promise<Content>}
101
- */
102
- async getContentById(id, params) {
103
- if (options.debug) {
104
- console.log(LOG_GROUP, 'getContentById() id : ', id);
105
- console.log(LOG_GROUP, 'getContentById() params : ', params);
106
- }
107
- let version = '';
108
- // Options
109
- if (options?.version && options.version == 'draft') {
110
- version = `&version=${options.version}`;
111
- }
112
- // Params
113
- if (params?.version && params.version == 'draft') {
114
- version = `&version=${params.version}`;
115
- }
116
- const locale = params?.locale ? `&locale=${params.locale}` : '';
117
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
118
- if (options.debug) {
119
- console.log(LOG_GROUP, 'getContentById fetch url : ', url);
120
- }
121
- const response = await fetch(url, fetchOptions);
122
- if (options.debug) {
123
- console.log(LOG_GROUP, 'getContentById status : ', response.status);
124
- }
125
- const data = await response.json();
126
- return data;
127
- },
128
- /**
129
- * Get translations for the given locale
130
- * @param locale{string} - Locale identifier (ISO 639-1)
131
- */
132
- async getTranslations(locale) {
133
- if (options.debug) {
134
- console.log(LOG_GROUP, 'getTranslations() locale : ', locale);
135
- }
136
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
137
- if (options.debug) {
138
- console.log(LOG_GROUP, 'getTranslations fetch url : ', url);
139
- }
140
- const response = await fetch(url, fetchOptions);
141
- if (options.debug) {
142
- console.log(LOG_GROUP, 'getTranslations status : ', response.status);
143
- }
144
- const data = await response.json();
145
- return data;
146
- },
147
- syncScriptUrl() {
148
- return `${options.origin}/scripts/sync-v1.js`;
149
- },
150
- assetLink(asset) {
151
- if (typeof asset === 'string') {
152
- return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
153
- }
154
- else {
155
- return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
156
- }
157
- }
158
- };
159
- }
2
+ export * from './client';
3
+ export * from './editable';
4
+ export * from './sync';
160
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,KAAoB,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAC,MAAM,SAAS,CAAC;AAExD,cAAc,UAAU,CAAC;AA2DzB,MAAM,SAAS,GAAG,GAAG,OAAO,oBAAoB,KAAK,EAAE,CAAA;AAEvD,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,YAAY,GAAgB;QAChC,QAAQ,EAAE,QAAQ;KACnB,CAAC;IACF,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;QAChD,CAAC;QACD,YAAY,CAAC,KAAK,GAAG,IAAI,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,OAAO;QAEL;;;;WAIG;QACH,KAAK,CAAC,QAAQ,CAAC,MAAyB;YACtC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,sBAAsB,GAAG,MAAM,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;gBACjB,IAAI,GAAG,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC;YACh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AM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
package/dist/sync.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Inject Localess Sync Script in Header
3
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
4
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
5
+ */
6
+ export declare function loadLocalessSync(origin: string, force?: boolean): void;
package/dist/sync.js ADDED
@@ -0,0 +1,28 @@
1
+ const JS_SYNC_ID = 'localess-js-sync';
2
+ /**
3
+ * Inject Localess Sync Script in Header
4
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
5
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
6
+ */
7
+ export function loadLocalessSync(origin, force = false) {
8
+ const isServer = typeof window === 'undefined';
9
+ if (isServer)
10
+ return; // Skip Server Injection
11
+ if (window.top === window.self)
12
+ return; // Skip if the page is not loaded in Visual Editor
13
+ const isSyncLoaded = typeof window.localess !== 'undefined';
14
+ if (isSyncLoaded)
15
+ return; // Skip if Sync is already loaded
16
+ const scriptEl = document.getElementById(JS_SYNC_ID);
17
+ if (scriptEl)
18
+ return; // Skip if script is already loaded
19
+ const script = document.createElement('script');
20
+ script.id = JS_SYNC_ID;
21
+ script.type = 'text/javascript';
22
+ script.src = `${origin}/scripts/sync-v1.js`;
23
+ script.async = true;
24
+ script.onerror = (error) => console.error(error);
25
+ script.onload = (event) => console.info('Localess Sync Script loaded');
26
+ document.head.appendChild(script);
27
+ }
28
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,QAAiB,KAAK;IACrE,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IAC/C,IAAI,QAAQ;QAAE,OAAO,CAAC,wBAAwB;IAC9C,IAAI,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI;QAAE,OAAO,CAAC,kDAAkD;IAC1F,MAAM,YAAY,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;IAC5D,IAAI,YAAY;QAAE,OAAO,CAAC,iCAAiC;IAC3D,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,QAAQ;QAAE,OAAO,CAAC,mCAAmC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC;IACvB,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,MAAM,CAAC,GAAG,GAAG,GAAG,MAAM,qBAAqB,CAAA;IAC3C,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IAEpB,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAEvE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/js-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.1-next.20241219-223225.0",
4
4
  "description": "Universal JavaScript/TypeScript SDK for Localess's API.",
5
5
  "keywords": [
6
6
  "localess",