@teipublisher/pb-components 3.0.3 → 3.0.5
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/CHANGELOG.md +15 -0
- package/dist/jinn-codemirror-b4fb2138.js +1 -0
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-components-bundle.js +299 -291
- package/dist/pb-odd-editor.js +1 -1
- package/package.json +1 -1
- package/src/authority/airtable.js +41 -8
- package/dist/_commonjsHelpers-0ffd9bcf.js +0 -1
- package/dist/jinn-codemirror-671bcda7.js +0 -1
package/dist/pb-odd-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as e,N as t,j as o,k as i,l as s,A as a,L as r,c as n,h as l,b as d,w as p,p as c}from"./pb-mixin-886ece32.js";import{E as h,T as u,D as m,p as b}from"./vaadin-element-mixin-beb74ffd.js";import{h as g,c as v,F as f,k as y,x as w,y as _,P as x}from"./paper-inky-focus-behavior-fa16796b.js";import{a as $}from"./paper-listbox-5f5d1cec.js";import{a as S}from"./paper-checkbox-645e1077.js";import"./paper-icon-button-984162bd.js";import"./jinn-codemirror-
|
|
1
|
+
import{f as e,N as t,j as o,k as i,l as s,A as a,L as r,c as n,h as l,b as d,w as p,p as c}from"./pb-mixin-886ece32.js";import{E as h,T as u,D as m,p as b}from"./vaadin-element-mixin-beb74ffd.js";import{h as g,c as v,F as f,k as y,x as w,y as _,P as x}from"./paper-inky-focus-behavior-fa16796b.js";import{a as $}from"./paper-listbox-5f5d1cec.js";import{a as S}from"./paper-checkbox-645e1077.js";import"./paper-icon-button-984162bd.js";import"./jinn-codemirror-b4fb2138.js";import{t as E,g as C}from"./pb-i18n-4cc00bfe.js";const k=(()=>{if("undefined"==typeof self)return!1;if("top"in self&&self!==top)try{top}catch(e){return!1}return"showOpenFilePicker"in self})();k?Promise.resolve().then((function(){return O})):Promise.resolve().then((function(){return T})),k?Promise.resolve().then((function(){return I})):Promise.resolve().then((function(){return z}));const A=k?Promise.resolve().then((function(){return j})):Promise.resolve().then((function(){return L}));async function P(...e){return(await A).default(...e)}const R=async e=>{const t=await e.getFile();return t.handle=e,t};var O={__proto__:null,default:async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((e,o)=>{t[o]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map(i=>{t[o].accept[i]=e.extensions||[]}):t[o].accept["*/*"]=e.extensions||[]});const o=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=await Promise.all(o.map(R));return e[0].multiple?i:i[0]}};function B(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(B=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var o=this.s.return;return void 0===o?Promise.resolve({value:e,done:!0}):t(o.apply(this.s,arguments))},throw:function(e){var o=this.s.return;return void 0===o?Promise.reject(e):t(o.apply(this.s,arguments))}},new B(e)}const M=async(e,t,o=e.name,i)=>{const s=[],a=[];var r,n=!1,l=!1;try{for(var d,p=function(e){var t,o,i,s=2;for("undefined"!=typeof Symbol&&(o=Symbol.asyncIterator,i=Symbol.iterator);s--;){if(o&&null!=(t=e[o]))return t.call(e);if(i&&null!=(t=e[i]))return new B(t.call(e));o="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());n=!(d=await p.next()).done;n=!1){const r=d.value,n=`${o}/${r.name}`;"file"===r.kind?a.push(r.getFile().then(t=>(t.directoryHandle=e,t.handle=r,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>n})))):"directory"!==r.kind||!t||i&&i(r)||s.push(M(r,t,n,i))}}catch(e){l=!0,r=e}finally{try{n&&null!=p.return&&await p.return()}finally{if(l)throw r}}return[...(await Promise.all(s)).flat(),...await Promise.all(a)]};var I={__proto__:null,default:async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:M(t,e.recursive,void 0,e.skipDirectory)}},j={__proto__:null,default:async(e,t=[{}],o=null,i=!1,s=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const a=[];let r=null;if(e instanceof Blob&&e.type?r=e.type:e.headers&&e.headers.get("content-type")&&(r=e.headers.get("content-type")),t.forEach((e,t)=>{a[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&r&&e.mimeTypes.push(r),e.mimeTypes.map(o=>{a[t].accept[o]=e.extensions||[]})):r?a[t].accept[r]=e.extensions||[]:a[t].accept["*/*"]=e.extensions||[]}),o)try{await o.getFile()}catch(e){if(o=null,i)throw e}const n=o||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!o&&s&&s(n);const l=await n.createWritable();if("stream"in e){const t=e.stream();return await t.pipeTo(l),n}return"body"in e?(await e.body.pipeTo(l),n):(await l.write(await e),await l.close(),n)}},T={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,o)=>{const i=document.createElement("input");i.type="file";const s=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();i.multiple=e[0].multiple||!1,i.accept=s||"",i.style.display="none",document.body.append(i);const a=e=>{"function"==typeof r&&r(),t(e)},r=e[0].legacySetup&&e[0].legacySetup(a,()=>r(o),i),n=()=>{window.removeEventListener("focus",n),i.remove()};i.addEventListener("click",()=>{window.addEventListener("focus",n)}),i.addEventListener("change",()=>{window.removeEventListener("focus",n),i.remove(),a(i.multiple?Array.from(i.files):i.files[0])}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},z={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,o)=>{const i=document.createElement("input");i.type="file",i.webkitdirectory=!0;const s=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(s,()=>a(o),i);i.addEventListener("change",()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter(t=>t.webkitRelativePath.split("/").every(t=>!e[0].skipDirectory({name:t,kind:"directory"})))):t=t.filter(e=>2===e.webkitRelativePath.split("/").length),s(t)}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},L={__proto__:null,default:async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const o=document.createElement("a");let i=e;"body"in e&&(i=await async function(e,t){const o=e.getReader(),i=new ReadableStream({start:e=>async function t(){return o.read().then(({done:o,value:i})=>{if(!o)return e.enqueue(i),t();e.close()})}()}),s=new Response(i),a=await s.blob();return o.releaseLock(),new Blob([a],{type:t})}(e.body,e.headers.get("content-type"))),o.download=t.fileName||"Untitled",o.href=URL.createObjectURL(await i);const s=()=>{"function"==typeof a&&a()},a=t.legacySetup&&t.legacySetup(s,()=>a(),o);return o.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(o.href),3e4),s()}),o.click(),null}};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
package/package.json
CHANGED
|
@@ -49,25 +49,55 @@ export class Airtable extends Registry {
|
|
|
49
49
|
this.infoExpr = getTemplate(configElem, '.info');
|
|
50
50
|
this.detailExpr = getTemplate(configElem, '.detail');
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Will be filled later, when airtable initialises
|
|
54
|
+
* @type {(table: string) => any}
|
|
55
|
+
*/
|
|
56
|
+
this.base = null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A promise that resolves when this class is initialised.
|
|
60
|
+
*
|
|
61
|
+
* @type {Promise<void>}
|
|
62
|
+
*/
|
|
63
|
+
this._airtableIsInitialized = this._init();
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @returns {Promise<void>}
|
|
68
|
+
*/
|
|
69
|
+
async _init() {
|
|
56
70
|
window.ESGlobalBridge.requestAvailability();
|
|
71
|
+
// ESGlobalBridge sets the `imports['airtable'] to true when it's fully loaded.
|
|
72
|
+
if (window.ESGlobalBridge.instance.imports['airtable'] === true) {
|
|
73
|
+
// We already have it
|
|
74
|
+
this._initAirtable();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
57
77
|
const path = resolveURL('../lib/airtable.browser.js');
|
|
78
|
+
// ESGlobalBridge#load returns a promise as well, but that will resolve a load immediately if a
|
|
79
|
+
// load is already pending but not resolved yet. Use the events to wait for a pending load to
|
|
80
|
+
// resolve instead.
|
|
58
81
|
window.ESGlobalBridge.instance.load('airtable', path);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
await new Promise(resolve =>
|
|
83
|
+
window.addEventListener('es-bridge-airtable-loaded', resolve, {
|
|
84
|
+
once: true,
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
this._initAirtable();
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
_initAirtable() {
|
|
65
|
-
const
|
|
66
|
-
this.base = new
|
|
91
|
+
const AirtableLib = require('airtable');
|
|
92
|
+
this.base = new AirtableLib({ apiKey: this.apiKey }).base(this.baseKey);
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
async query(key) {
|
|
70
96
|
key = key.toLowerCase();
|
|
97
|
+
|
|
98
|
+
// Make sure airtable is initialised and we have the this.base functions set up
|
|
99
|
+
await this._airtableIsInitialized;
|
|
100
|
+
|
|
71
101
|
const results = [];
|
|
72
102
|
const filter = this.filterExpr ? expandTemplate(this.filterExpr, { key }) : null;
|
|
73
103
|
const options = {
|
|
@@ -112,7 +142,10 @@ export class Airtable extends Registry {
|
|
|
112
142
|
});
|
|
113
143
|
}
|
|
114
144
|
|
|
115
|
-
info(key, container) {
|
|
145
|
+
async info(key, container) {
|
|
146
|
+
// Make sure airtable is initialised and we have the this.base functions set up
|
|
147
|
+
await this._airtableIsInitialized;
|
|
148
|
+
|
|
116
149
|
return new Promise((resolve, reject) => {
|
|
117
150
|
this.base(this.table).find(key, (err, record) => {
|
|
118
151
|
if (err) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,o){return e(o={exports:{}},o.exports),o.exports}function n(e){return e&&e.default||e}export{e as a,t as c,n as g,o as u};
|